前言:
该篇中主要讲解一下redis的容错以及数据的迁移(横向拓展)
redis 集群信息
在前面章节中讲到将Node加入到cluster以后打印了如下日志:
[root@localhost src]# ./redis-trib.rb create --replicas 1 192.168.1.103:7000 192.168.1.103:7001 192.168.1.103:7002 192.168.1.103:7003 192.168.1.103:7004 192.168.1.103:7005
>>> Creating cluster
Connecting to node 192.168.1.103:7000: OK
Connecting to node 192.168.1.103:7001: OK
Connecting to node 192.168.1.103:7002: OK
Connecting to node 192.168.1.103:7003: OK
Connecting to node 192.168.1.103:7004: OK
Connecting to node 192.168.1.103:7005: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.103:7000
192.168.1.103:7001
192.168.1.103:7002
Adding replica 192.168.1.103:7003 to 192.168.1.103:7000
Adding replica 192.168.1.103:7004 to 192.168.1.103:7001
Adding replica 192.168.1.103:7005 to 192.168.1.103:7002
M 4bc092eb4731152d15172b065c74c7a795fe6304 192.168.1.103:7000
slots:0-5460(5461 slots) master
M: f37ec54101536425ce8798e041ad75a582d7e153 192.168.1.103:7001
slots:5461-10922 (5462 slots) master
M: 7b0ca3978858454051ad572aa816eec450f31a53 192.168.1.103:7002
slots:10923-16383 (5461 slots) master
S: 778e649f47fa98f6d1f6b1f1043812c6685dc4a8 192.168.1.103:7003
replicates 4bc092eb4731152d15172b065c74c7a795fe6304
S: 907feee1b665554cadc64921c7fcb8c05b8a5ab6 192.168.1.103:7004
replicates f37ec54101536425ce8798e041ad75a582d7e153
S: b2bea8ede402e2112cced7d7cea52127f18edef2 192.168.1.103:7005
replicates 7b0ca3978858454051ad572aa816eec450f31a53
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.1.103:7000)
M: 4bc092eb4731152d15172b065c74c7a795fe6304 192.168.1.103:7000
slots:0-5460 (5461 slots) master
M: f37ec54101536425ce8798e041ad75a582d7e153 192.168.1.103:7001
slots:5461-10922 (5462 slots) master
M: 7b0ca3978858454051ad572aa816eec450f31a53 192.168.1.103:7002
slots:10923-16383 (5461 slots) master
M: 778e649f47fa98f6d1f6b1f1043812c6685dc4a8 192.168.1.103:7003
slots: (0 slots) master
replicates 4bc092eb4731152d15172b065c74c7a795fe6304
M: 907feee1b665554cadc64921c7fcb8c05b8a5ab6 192.168.1.103:7004
slots: (0 slots) master
replicates f37ec54101536425ce8798e041ad75a582d7e153
M: b2bea8ede402e2112cced7d7cea52127f18edef2 192.168.1.103:7005
slots: (0 slots) master
replicates 7b0ca3978858454051ad572aa816eec450f31a53
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
可以得到如下信息
节点名称 |
7000 |
7001 |
7002 |
7003 |
7004 |