Redis-cluster集群【第四篇】:redis-cluster集群配置(二)

2015-11-21 01:25:03 · 作者: · 浏览: 11
nf
sed ?'s/6379/7006/g' 6379.conf > 7006/redis.conf
sed ?'s/6379/7007/g' 6379.conf > 7007/redis.conf
sed ?'s/6379/7008/g' 6379.conf > 7008/redis.conf
?
?
for i in `seq 7001 7009`;do cd /opt/$i && /usr/local/bin/redis-server redis.conf ; done
?
2、安装管理工具, 源码自带了一个管理Cluster集群的工具是用ruby写的所以需要安装ruby
?
yum -y install ruby rubygems
安装ruby的管理工具redis
gem install redis?
?
3、复制管理工具
?
cp /opt/redis-3.0.4/src/redis-trib.rb /usr/local/bin/redis-trib
查看redis-trib帮助
redis-trib help
?
4、创建集群 ?7001-7006 ? 6个redis为集群node ? 7007-7008 ? “2个redis为back node”
?
[root@server.tianshuai.com]$ redis-trib create --replicas 1 192.168.0.201:7001 192.168.0.201:7002 192.168.0.201:7003 192.168.0.201:7004 192.168.0.201:7005 192.168.0.201:7006
>>> Creating cluster
Connecting to node 192.168.0.201:7001: OK
Connecting to node 192.168.0.201:7002: OK
Connecting to node 192.168.0.201:7003: OK
Connecting to node 192.168.0.201:7004: OK
Connecting to node 192.168.0.201:7005: OK
Connecting to node 192.168.0.201:7006: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.0.201:7001
192.168.0.201:7002
192.168.0.201:7003 
Adding replica 192.168.0.201:7004 to 192.168.0.201:7001
Adding replica 192.168.0.201:7005 to 192.168.0.201:7002
Adding replica 192.168.0.201:7006 to 192.168.0.201:7003
M: 699f318027f87f3c49d48e44116820e673bd306a 192.168.0.201:7001  
   slots:0-5460 (5461 slots) master
M: 96892fd3f51292e922383ddb6e8018e2f772deed 192.168.0.201:7002
   slots:5461-10922 (5462 slots) master
M: f702fd03c1e3643db7e385915842533ba5aab98d 192.168.0.201:7003
   slots:10923-16383 (5461 slots) master
S: d0994ce7ef68c0834030334afcd60013773f2e77 192.168.0.201:7004  
   replicates 699f318027f87f3c49d48e44116820e673bd306a
S: d880581504caff4a002242b2b259d5242b8569fc 192.168.0.201:7005
   replicates 96892fd3f51292e922383ddb6e8018e2f772deed
S: a77b16c4f140c0f5c17c907ce7ee5e42ee2a7b02 192.168.0.201:7006
   replicates f702fd03c1e3643db7e385915842533ba5aab98d
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 192.168.0.201:7001) M: 699f318027f87f3c49d48e44116820e673bd306a 192.168.0.201:7001 slots:0-5460 (5461 slots) master M: 96892fd3f51292e922383ddb6e8018e2f772deed 192.168.0.201:7002 slots:5461-10922 (5462 slots) master M: f702fd03c1e3643db7e385915842533ba5aab98d 192.168.0.201:7003 slots:10923-16383 (5461 slots) master M: d0994ce7ef68c0834030334afcd60013773f2e77 192.168.0.201:7004 slots: (0 slots) master replicates 699f318027f87f3c49d48e44116820e673bd306a M: d880581504caff4a002242b2b259d5242b8569fc 192.168.0.201:7005 slots: (0 slots) master replicates 96892fd3f51292e922383ddb6e8018e2f772deed M: a77b16c4f140c0f5c17c907ce7ee5e42ee2a7b02 192.168.0.201:7006 slots: (0 slots) master replicates f702fd03c1e3643db7e385915842533ba5aab98d [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. #create --replicas 1这里--replicas 1 是指定复制几份,相当于每