今天终于要开始集群安装了。
1.单机版安装路径:
/usr/local/redis
2.redis路径
/usr/redis/redis-3.0.0
1.新建集群文件夹
mkdir /usr/local/redis-cluster
2.进入redis安装路径下的redis/bin文件夹下,执行copy操作
cp -r bin ../redis-cluster/redis01
cp -r bin ../redis-cluster/redis02
cp -r bin ../redis-cluster/redis03
cp -r bin ../redis-cluster/redis04
cp -r bin ../redis-cluster/redis05
cp -r bin ../redis-cluster/redis06
3.进入redis01-redis06文件下,更新每个redis.conf文件,修改端口号为7001-7006,以及打开每个配置文件内的cluster-enable
4.将创建集群的ruby脚本复制到redis-cluster下,这边需要进入redis的原始文件下/redis/redis-3.0.0
cd /usr/redis/redis-3.0.0/src
5.复制
cp *.rb /usr/local/redis-cluster/
6.回到redis-cluster下,创建startall.sh用于一起启动
vim startall.sh
cd redis01
./redis-server redis.conf
cd ..
cd redis02
./redis-server redis.conf
cd ..
cd redis03
./redis-server redis.conf
cd ..
cd redis04
./redis-server redis.conf
cd ..
cd redis05
./redis-server redis.conf
cd ..
cd redis06
./redis-server redis.conf
cd ..
7.赋予权限
chmod +x startall.sh
8.脚本启动
./startall.sh
9.查看状态
ps aux|grep redis
[root@localhost redis-cluster]# ps -aux | grep redis
root 9129 0.0 0.0 131616 2356 ? Ssl 17:02 0:00 ./redis-server *:7001 [cluster]
root 9131 0.0 0.0 131616 2352 ? Ssl 17:02 0:00 ./redis-server *:7002 [cluster]
root 9133 0.0 0.0 131616 2356 ? Ssl 17:02 0:00 ./redis-server *:7003 [cluster]
root 9139 0.0 0.0 131616 2360 ? Ssl 17:02 0:00 ./redis-server *:7004 [cluster]
root 9141 0.0 0.0 131616 2360 ? Ssl 17:02 0:00 ./redis-server *:7005 [cluster]
root 9145 0.0 0.0 131616 2356 ? Ssl 17:02 0:00 ./redis-server *:7006 [cluster]
root 9165 0.0 0.0 112656 984 pts/0 R+ 17:02 0:00 grep --color=auto redis
10.安装gem
gem install redis
11.创建集群
./redis-trib.rb create --replicas 1 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 127.0.0.1:7006
12结果,出现选择是否设置,yes
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7001
127.0.0.1:7002
127.0.0.1:7003
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
Adding replica 127.0.0.1:7006 to 127.0.0.1:7003
M: 4f3dd6ac051fd53588a0a54513c1a834e591e94f 127.0.0.1:7001
slots:0-5460 (5461 slots) master
M: ee69242ebf2ca320b28794a8b2eb6019b9bf0acc 127.0.0.1:7002
slots:5461-10922 (5462 slots) master
M: 7ac8d14d1a644f3099eefccb73f604e56e4728c1 127.0.0.1:7003
slots:10923-16383 (5461 slots) master
S: a15b4aeb80133aa940bae0d1e81798852442c317 127.0.0.1:7004
replicates 4f3dd6ac051fd53588a0a54513c1a834e591e94f
S: afc075dc730f434df6815cca778cc6d3c97f7f7a 127.0.0.1:7005
replicates ee69242ebf2ca320b28794a8b2eb6019b9bf0acc
S: 7a6e1f12d4ccd1637de1f66792c697e177cb0cd9 127.0.0.1:7006
replicates 7ac8d14d1a644f3099eefccb73f604e56e4728c1
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join......
>>> Performing Cluster Check (using node 127.0.0.1:7001)
M: 4f3dd6ac051fd53588a0a54513c1a834e591e94f 127.0.0.1:7001
slots:0-5460 (5461 slots) master
M: ee69242ebf2ca320b28794a8b2eb6019b9bf0acc 127.0.0.1:7002
slots:5461-10922 (5462 slots) master
M: 7ac8d14d1a644f3099eefccb73f604e56e4728c1 127.0.0.1:7003
slots:10923-16383 (5461 slots) master
M: a15b4aeb80133aa940bae0d1e81798852442c317 127.0.0.1:7004
slots: (0 slots) master
replicates 4f3dd6ac051fd53588a0a54513c1a834e591e94f
M: afc075dc730f434df6815cca778cc6d3c97f7f7a 127.0.0.1:7005
slots: (0 slots) master
replicates ee69242ebf2ca320b28794a8b2eb6019b9bf0acc
M: 7a6e1f12d4ccd1637de1f66792c697e177cb0cd9 127.0.0.1:7006
slots: (0 slots) master
replicates 7ac8d14d1a644f3099eefccb73f604e56e4728c1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
13.集群时三主三从模式。后续继续基于此测试。