安裝redis(win7+叢集安裝)
一、安裝win7版本
1.下載redis
github下載地址:https://github.com/MicrosoftArchive/redis/releases
網盤下載地址:連結:https://pan.baidu.com/s/15NtjKtc_5t37azTTmQqsvQ 提取碼:p8le
2.將檔案進行解壓
解壓完成後的檔案如下圖所示:
3.
(1)點選資料夾內redis-server.exe資料夾,出現如下圖所示介面:
(2)點選資料夾內redis-cli.sh出現如下介面
set mykey abc
get mykey
ok!!win7版本安裝完成
安裝配置參考:
二、安裝liunx叢集模式
參考部落格:1.https://www.cnblogs.com/liuyansheng/p/6169849.html
2.https://www.cnblogs.com/lilongsheng1125/p/4978478.html
(要讓叢集正常工作至少需要3個主節點,在這裡我們要建立6個redis節點,其中三個為主節點,三個為從節點,對應的redis節點的ip和埠對應關係如下)
127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
1.下載redis
官網下載 http://download.redis.io/releases/ 或者
百度網盤連結:https://pan.baidu.com/s/11pIiMpLmuqV5t39FeaC7zg 提取碼:pu8h
2.將檔案上傳到伺服器並解壓、編譯
tar -xvf redis-3.0.5.tar.gz
cd redis-3.0.5
#如果不加引數,linux下會報錯
make MALLOC=libc
3.新建6個資料夾
mkdir -p redis/cluster/
mkdir 7000 7000 7002 7003 7004 7005
4.複製並修改配置檔案
cp ~/redis-3.0.5/redis-server ~/redis-3.0.5/redis-server ~/redis/cluster/7000 cp ~/redis-3.0.5/redis-server ~/redis-3.0.5/redis-server ~/redis/cluster/7001 cp ~/redis-3.0.5/redis-server ~/redis-3.0.5/redis-server ~/redis/cluster/7002 cp ~/redis-3.0.5/redis-server ~/redis-3.0.5/redis-server ~/redis/cluster/7003 cp ~/redis-3.0.5/redis-server ~/redis-3.0.5/redis-server ~/redis/cluster/7004 cp ~/redis-3.0.5/redis-server ~/redis-3.0.5/redis-server ~/redis/cluster/7005
修改conf檔案’
port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
開啟server.conf檔案vi server.conf
在命令列模式下使用:set nu
然後:number
跳轉到指定行數
行數分別為:port 46 cluster-enabled 637 cluster-config-file 645 cluster-node-timeout 651 在末尾新增 appendonly yes appendfilename "appendonly.aof"
5.啟動redis例項
cd ~/redis/cluster/7000
redis-server redis.conf
cd ~/redis/cluster/7001
redis-server redis.conf
cd ~/redis/cluster/7002
redis-server redis.conf
cd ~/redis/cluster/7003
redis-server redis.conf
cd ~/redis/cluster/7004
redis-server redis.conf
cd ~/redis/cluster/7005
redis-server redis.conf
檢視啟動狀況
ps -aux |grep redis
hadoop 2165 0.1 0.4 137456 7856 ? Sl 12:43 0:02 redis-server *:7000 [cluster]
hadoop 2202 0.1 0.4 137456 7848 ? Sl 12:44 0:02 redis-server *:7001 [cluster]
hadoop 2293 0.1 0.4 137456 7848 ? Sl 12:45 0:02 redis-server *:7003 [cluster]
hadoop 2296 0.1 0.4 137456 7848 ? Sl 12:45 0:02 redis-server *:7004 [cluster]
hadoop 2299 0.1 0.4 137456 7852 ? Sl 12:45 0:02 redis-server *:7005 [cluster]
hadoop 2326 0.1 0.4 137456 7848 ? Sl 12:46 0:02 redis-server *:7002 [cluster]
hadoop 2809 0.0 0.0 103256 872 pts/6 S+ 13:17 0:00 grep redis
6.安裝ruby環境
yum install -y ruby
yum install -y ruby-devel ruby-docs ruby-ri ruby-rdoc
yum install -y rubygems
gem install redis
7.建立叢集
進入cd redis-3.0.5/src
輸入命令:./redis-trib.rb create --replicas 1 192.168.124.10:7000 192.168.124.10:7001 192.168.124.10:7002 192.168.124.10:7003 192.168.124.10:7004 192.168.124.10:7005
報錯:/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require’: no such file to load – redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from ./redis-trib.rb:25
執行:gem install redis
出現:ERROR: Error installing redis: redis requires Ruby version >= 2.2.2.
錯誤原因:ruby版本太低
解決方法:刪除rubyyum -y remove ruby
7.1 安裝ruby工具:rvm
參考文章:http://blog.51cto.com/wujianwei/2150208
1.執行命令
curl -L get.rvm.io | bash -s stable
出現:` % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 24361 100 24361 0 0 6116 0 0:00:03 0:00:03 --:–:-- 22411
Downloading https://github.com/rvm/rvm/archive/1.29.4.tar.gz
curl: (35) SSL connect error
Could not download ‘https://github.com/rvm/rvm/archive/1.29.4.tar.gz’.
curl returned status ‘35’.
Downloading https://bitbucket.org/mpapis/rvm/get/1.29.4.tar.gz
Downloading https://bitbucket.org/mpapis/rvm/downloads/1.29.4.tar.gz.asc
gpg: directory /home/hadoop/.gnupg' created gpg: new configuration file
/home/hadoop/.gnupg/gpg.conf’ created
gpg: WARNING: options in /home/hadoop/.gnupg/gpg.conf' are not yet active during this run gpg: keyring
/home/hadoop/.gnupg/pubring.gpg’ created
gpg: Signature made Mon 02 Jul 2018 03:41:26 AM CST using RSA key ID BF04FF17
gpg: Can’t check signature: No public key
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
GPG signature verification failed for ‘/home/hadoop/.rvm/archives/rvm-1.29.4.tgz’ - ‘https://bitbucket.org/mpapis/rvm/downloads/1.29.4.tar.gz.asc’! Try to install GPG v2 and then fetch the public key:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
or if it fails:
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
the key can be compared with:
https://rvm.io/mpapis.asc
https://keybase.io/mpapis
NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.`
2.出現curl: (35) SSL connect error問題
原因nss版本太久,解決方案
升級nss版本:
yum -y update nss
注意此處:
3.輸入命令:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
出現:
4.再次執行:
curl -L get.rvm.io | bash -s stable
出現如下資訊,表示安裝成功
5.找到最後兩行source提示,根據此命令輸入:
source /home/hadoop/.rvm/scripts/rvm
7.2安裝ruby
1.列出rvm可安裝的版本:[[email protected] src]$ rvm list known
出現ruby資訊:
2. 輸入安裝命令:rvm install 2.3.7
出錯:Searching for binary rubies, this might take some time. No binary rubies available for: centos/6/x86_64/ruby-2.3.7. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Installing requirements for centos. Installing required packages: patch, autoconf, automake, bison, gcc-c++, libffi-devel, libtool, patch, readline-devel, sqlite-devel, zlib-devel, openssl-devel..hadoop password required for 'yum install -y patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel openssl-devel': hadoop password required for 'yum install -y patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel openssl-devel': hadoop password required for 'yum install -y patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel openssl-devel': . Error running 'requirements_centos_libs_install patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel openssl-devel', please read /home/hadoop/.rvm/log/1541040720_ruby-2.3.7/package_install_patch_autoconf_automake_bison_gcc-c++_libffi-devel_libtool_patch_readline-devel_sqlite-devel_zlib-devel_openssl-devel.log Requirements installation failed with status: 1.
解決方案:執行sudo yum install -y patch libyaml-devel autoconf patch readline-devel libffi-devel openssl-devel automake libtool bison sqlite-devel
3.重新執行: rvm install 2.3.7
出現如下介面
根據提示輸入 rvm docs generate-ri
4.安裝redis-dump
gem install redis-dump
8.輸入命令 進入redis/src目錄下
./redis-trib.rb create --replicas 1 192.168.124.10:7000 192.168.124.10:7001 192.168.124.10:7002 192.168.124.10:7003 192.168.124.10:7004 192.168.124.10:7005