ubuntu16.04安裝redis叢集
阿新 • • 發佈:2018-12-25
注:伺服器已經安裝好redis 。目錄在 /usr/redis-3.2.6
首先安裝需要的環境
apt-get install ruby
apt-get install rubygems
sudo gem install redis
1、建立叢集需要的目錄並拷貝redis
# mkdir -p /usr/local/cluster
# mkdir -p /usr/local/cluster/6000
# mkdir -p /usr/local/cluster/6001
# mkdir -p /usr/local/cluster/6002
# mkdir -p /usr/local/cluster/6003
# mkdir -p /usr/local/cluster/6004
# mkdir -p /usr/local/cluster/6005
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6000/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6001/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6002/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6003/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6004/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6005/
2、修改配置檔案redis.conf
# vi /usr/local/cluster/6000/redis.conf
修改配置檔案中的下面選項(把有註釋的開啟 )
daemonize yes
port 6000
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
3、用6000/redis.conf覆蓋6001,6002,6003,6004,6005目錄下的redis.conf
4、再修改6001,6002,6003,6004,6005目錄下的redis.conf中的port,使得redis.conf中的port與其父目錄名稱一致,比如
6001/redis.conf中的port為6001
5、啟動6個redis
# cd /usr/local/cluster/6000/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6001/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6002/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6003/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6004/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6005/src
# redis-server ../redis.conf
6、建立redis叢集
# cd /usr/redis-3.2.6/src
首先安裝需要的環境
apt-get install ruby
apt-get install rubygems
sudo gem install redis
1、建立叢集需要的目錄並拷貝redis
# mkdir -p /usr/local/cluster
# mkdir -p /usr/local/cluster/6000
# mkdir -p /usr/local/cluster/6001
# mkdir -p /usr/local/cluster/6002
# mkdir -p /usr/local/cluster/6003
# mkdir -p /usr/local/cluster/6004
# mkdir -p /usr/local/cluster/6005
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6000/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6001/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6002/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6003/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6004/
# cp -rf /usr/redis-3.2.6/* /usr/local/cluster/6005/
2、修改配置檔案redis.conf
# vi /usr/local/cluster/6000/redis.conf
修改配置檔案中的下面選項(把有註釋的開啟
daemonize yes
port 6000
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
3、用6000/redis.conf覆蓋6001,6002,6003,6004,6005目錄下的redis.conf
4、再修改6001,6002,6003,6004,6005目錄下的redis.conf中的port,使得redis.conf中的port與其父目錄名稱一致,比如
6001/redis.conf中的port為6001
5、啟動6個redis
# cd /usr/local/cluster/6000/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6001/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6002/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6003/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6004/src
# redis-server ../redis.conf
# cd /usr/local/cluster/6005/src
# redis-server ../redis.conf
6、建立redis叢集
# cd /usr/redis-3.2.6/src
# ./redis-trib.rb create --replicas 1 127.0.0.1:6000 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 127.0.0.1:6004 127.0.0.1:6005
7、測試