Redis Cluster 部署

1鳍咱、安裝 redis

# yum install gcc gcc-c++  make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel python-devel ncurses-devel glib2 glib2-devel openssl-devel glibc-devel glibc-devel.i686 vim screen git ntp* python-devel mysql-devel -y

# wget http://download.redis.io/releases/redis-3.2.12.tar.gz

# tar xvf redis-3.2.12.tar.gz -C /usr/local/

# make

2、配置 redis cluster措嵌,以 redis-6379 為例躲叼,其他的 redis-6380、redis-6381企巢、redis-6382枫慷、redis-6383、redis-6384 配置類似

# cd /usr/local/redis-3.2.12
# egrep -v "^$|^#" redis-6379.conf 
bind 10.3.20.102
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "redis-6379.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_6379-dump.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "redis_6379-appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
# 開(kāi)啟集群模式
cluster-enabled yes
# 集群內(nèi)部配置文件
cluster-config-file nodes-6379.conf
# 節(jié)點(diǎn)超時(shí)時(shí)間浪规,單位毫秒
cluster-node-timeout 15000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

3或听、redis cluster 節(jié)點(diǎn)握手

集群架構(gòu)

10.3.20.102:6379 --> 10.3.20.14:6382
10.3.20.105:6380 --> 10.3.20.51:6383
10.3.20.93:6381  --> 10.3.20.54:6384
# redis-cli -h 10.3.20.102 -p 6379 -c
10.3.20.102:6379> cluster meet 10.3.20.105 6380
OK
10.3.20.102:6379> cluster meet 10.3.20.93 6381
OK
10.3.20.102:6379> cluster meet 10.3.20.14 6382
OK
10.3.20.102:6379> cluster meet 10.3.20.51 6383
OK
10.3.20.102:6379> cluster meet 10.3.20.54 6384
OK

10.3.20.102:6379> cluster nodes
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 master - 0 1531207146394 4 connected
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 master - 0 1531207144377 0 connected
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 myself,master - 0 0 5 connected
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531207143369 1 connected
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531207147400 2 connected
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 master - 0 1531207145383 3 connected


10.3.20.102:6379> set hello world
(error) CLUSTERDOWN Hash slot not served


10.3.20.102:6379> cluster info
cluster_state:fail
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:0
cluster_current_epoch:5
cluster_my_epoch:5
cluster_stats_messages_sent:469
cluster_stats_messages_received:469


被分配的槽(cluster_slots_assigned)是0,由于目前所有的槽沒(méi)有分配到節(jié)點(diǎn)笋婿,因此集群無(wú)法完成槽到節(jié)點(diǎn)的映射誉裆。只有當(dāng)16384個(gè)槽全部分配給節(jié)點(diǎn)后,集群才進(jìn)入在線狀態(tài)缸濒。

4足丢、redis cluster 分配槽

# redis-cli -h 10.3.20.102 -p 6379 cluster addslots {0..5461}
OK
# redis-cli -h 10.3.20.105 -p 6380 cluster addslots {5462..10922}
OK
# redis-cli -h 10.3.20.93 -p 6381 cluster addslots {10923..16383}
OK

# redis-cli -h 10.3.20.102 -p 6379 -c
10.3.20.102:6379> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:5
cluster_my_epoch:5
cluster_stats_messages_sent:3978
cluster_stats_messages_received:3978

10.3.20.102:6379> cluster nodes
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 myself,master - 0 0 5 connected 0-5461
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 master - 0 1531209712249 3 connected
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531209711748 2 connected 10923-16383
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531209710223 1 connected 5462-10922
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 master - 0 1531209709215 0 connected
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 master - 0 1531209713256 4 connected

5、配置 3 個(gè) 節(jié)點(diǎn)為從節(jié)點(diǎn)庇配,負(fù)責(zé)故障轉(zhuǎn)移(6379(Master)--> 6382(Slave)斩跌,6380(Master)--> 6383(Slave),6381(Master)--> 6384(Slave))

# redis-cli -h 10.3.20.14 -p 6382 -c
10.3.20.14:6382> cluster replicate 6f3639bc0ce4c99d487c9e89c57b290496666483
OK

# redis-cli -h 10.3.20.51 -p 6383 -c
10.3.20.51:6383> cluster replicate 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
OK

# redis-cli -h 10.3.20.54 -p 6384 -c
10.3.20.54:6384> cluster replicate 5fb133912a7caaac22bd5bbd75af346aa129a766
OK

# redis-cli -h 10.3.20.102 -p 6379 -c
10.3.20.102:6379> cluster nodes
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 myself,master - 0 0 5 connected 0-5461
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 slave 6f3639bc0ce4c99d487c9e89c57b290496666483 0 1531209918639 5 connected
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531209917228 2 connected 10923-16383
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531209919245 1 connected 5462-10922
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 slave 5fb133912a7caaac22bd5bbd75af346aa129a766 0 1531209914202 2 connected
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 slave 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 0 1531209918235 4 connected

6捞慌、測(cè)試 redis cluster

# redis-cli -c -h 10.3.20.102 -p 6379
10.3.20.102:6379> set name foo
-> Redirected to slot [5798] located at 10.3.20.105:6380
OK
# redis-cli -h 10.3.20.105 -p 6380 -c
10.3.20.105:6380> set age 21
-> Redirected to slot [741] located at 10.3.20.102:6379
OK
# redis-cli -h 10.3.20.93 -p 6381 -c
10.3.20.93:6381> get name
-> Redirected to slot [5798] located at 10.3.20.105:6380
"foo"
10.3.20.105:6380> get age
-> Redirected to slot [741] located at 10.3.20.102:6379
"21"

7耀鸦、錯(cuò)誤處理

# redis-cli -h 10.3.20.102 -p 6379 -c
10.3.20.102:6379> set name kine
(error) CLUSTERDOWN The cluster is down
10.3.20.102:6379> 

// Also do cluster reset soft on each server after the flushall
10.3.20.102:6379> flushall
OK
10.3.20.102:6379> cluster reset soft
OK

8、利用 redis-trib.rb 快速部署 redis cluster

# yum install ruby -y
# wget http://rubygems.org/downloads/redis-3.3.0.gem
# gem install -l redis-3.3.0.gem 
Successfully installed redis-3.3.0
Parsing documentation for redis-3.3.0
Installing ri documentation for redis-3.3.0
1 gem installed
# gem list 

*** LOCAL GEMS ***

bigdecimal (1.2.0)
io-console (0.4.2)
json (1.7.7)
psych (2.0.0)
rdoc (4.0.0)
redis (3.3.0)

# redis-trib.rb create --replicas 1 10.3.20.102:6379 10.3.20.105:6380 10.3.20.93:6381 10.3.20.14:6382 10.3.20.51:6383 10.3.20.54:6384
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
10.3.20.102:6379
10.3.20.105:6380
10.3.20.93:6381
Adding replica 10.3.20.14:6382 to 10.3.20.102:6379
Adding replica 10.3.20.51:6383 to 10.3.20.105:6380
Adding replica 10.3.20.54:6384 to 10.3.20.93:6381
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
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 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

# redis-trib.rb info 10.3.20.102:6379
10.3.20.102:6379 (6f3639bc...) -> 0 keys | 5461 slots | 1 slaves.
10.3.20.93:6381 (5fb13391...) -> 0 keys | 5461 slots | 1 slaves.
10.3.20.105:6380 (4dacd43c...) -> 0 keys | 5462 slots | 1 slaves.
[OK] 0 keys in 3 masters.
0.00 keys per slot on average.

# redis-cli -h 10.3.20.102 -p 6379 -c
10.3.20.102:6379> set name kine
-> Redirected to slot [5798] located at 10.3.20.105:6380
OK
10.3.20.105:6380> set age 10
-> Redirected to slot [741] located at 10.3.20.102:6379
OK
10.3.20.102:6379> set weight 100
-> Redirected to slot [16280] located at 10.3.20.93:6381
OK
10.3.20.93:6381> 
[root@docker-01 redis-3.2.12]# redis-trib.rb info 10.3.20.102:6379
10.3.20.102:6379 (6f3639bc...) -> 1 keys | 5461 slots | 1 slaves.
10.3.20.93:6381 (5fb13391...) -> 1 keys | 5461 slots | 1 slaves.
10.3.20.105:6380 (4dacd43c...) -> 1 keys | 5462 slots | 1 slaves.
[OK] 3 keys in 3 masters.
0.00 keys per slot on average.

9卿闹、擴(kuò)容集群(10.3.20.132:6385(Master)-->(10.3.20.132 6386(Slave)

集群架構(gòu)

10.3.20.102:6379 --> 10.3.20.14:6382
10.3.20.105:6380 --> 10.3.20.51:6383
10.3.20.93:6381  --> 10.3.20.54:6384
10.3.20.132:6385 --> 10.3.20.132:6386
// 準(zhǔn)備新節(jié)點(diǎn) 10.3.20.132:6385(Master)
# redis-server redis-6385.conf

// 原生命令 cluster meet 實(shí)現(xiàn) 10.3.20.132:6385(Master) 加入集群
# redis-cli -h 10.3.20.102 -p 6379 -c
10.3.20.102:6379> cluster meet 10.3.20.132 6385
OK
10.3.20.102:6379> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:7
cluster_size:3
cluster_current_epoch:8
cluster_my_epoch:5
cluster_stats_messages_sent:210273
cluster_stats_messages_received:179187
10.3.20.102:6379> cluster nodes
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 slave 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 0 1531360499646 8 connected
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531360500653 2 connected 10923-16383
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 myself,master - 0 0 5 connected 0-5460
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531360497636 8 connected 5461-10922
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 slave 6f3639bc0ce4c99d487c9e89c57b290496666483 0 1531360498639 5 connected
8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385 master - 0 1531360501661 0 connected
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 slave 5fb133912a7caaac22bd5bbd75af346aa129a766 0 1531360495615 6 connected

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots: (0 slots) master
   0 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

// redis-trib.rb add-node 實(shí)現(xiàn) 10.3.20.132:6385(Master) 加入集群
# redis-trib.rb add-node 10.3.20.132:6385 10.3.20.102:6379
>>> Adding node 10.3.20.132:6385 to cluster 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots: (0 slots) master
   0 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[ERR] Node 10.3.20.132:6385 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.

// 遷移槽和數(shù)據(jù)(16384/4=4096)
# redis-trib.rb reshard 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots: (0 slots) master
   0 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 4096
What is the receiving node ID? 8e197d1add3838be26744dde6422b6ccfd205ede
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1:6f3639bc0ce4c99d487c9e89c57b290496666483
Source node #2:4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
Source node #3:5fb133912a7caaac22bd5bbd75af346aa129a766
Source node #4:done

Ready to move 4096 slots.
  Source nodes:
    M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
    M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
    M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
  Destination node:
    M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots: (0 slots) master
   0 additional replica(s)
  Resharding plan:
    Moving slot 5461 from 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
    ……
    Moving slot 12287 from 5fb133912a7caaac22bd5bbd75af346aa129a766
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 5461 from 10.3.20.105:6380 to 10.3.20.132:6385: 
……
Moving slot 12287 from 10.3.20.93:6381 to 10.3.20.132:6385: 

10.3.20.102:6379> cluster nodes
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 slave 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 0 1531362985537 8 connected
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531362984026 2 connected 12288-16383
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 myself,master - 0 0 5 connected 1365-5460
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531362979488 8 connected 6827-10922
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 slave 6f3639bc0ce4c99d487c9e89c57b290496666483 0 1531362982512 5 connected
8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385 master - 0 1531362986545 9 connected 0-1364 5461-6826 10923-12287
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 slave 5fb133912a7caaac22bd5bbd75af346aa129a766 0 1531362984532 6 connected

# redis-trib.rb rebalance 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
*** No rebalancing needed! All nodes are within the 2.0% threshold.

# redis-trib.rb info 10.3.20.102:6379
10.3.20.102:6379 (6f3639bc...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.93:6381 (5fb13391...) -> 1 keys | 4096 slots | 1 slaves.
10.3.20.105:6380 (4dacd43c...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.132:6385 (8e197d1a...) -> 3 keys | 4096 slots | 0 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   0 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

// 準(zhǔn)備 10.3.20.132 6386(Slave) 節(jié)點(diǎn)
# redis-server redis-6386.conf

// 10.3.20.132:6386(Slave) 加入集群
# redis-trib.rb add-node 10.3.20.132:6386 10.3.20.102:6379
>>> Adding node 10.3.20.132:6386 to cluster 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   1 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   0 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 10.3.20.132:6386 to make it join the cluster.
[OK] New node added correctly.

# redis-trib.rb info 10.3.20.102:6379
10.3.20.102:6379 (6f3639bc...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.93:6381 (5fb13391...) -> 1 keys | 4096 slots | 1 slaves.
10.3.20.132:6386 (34585de8...) -> 0 keys | 0 slots | 0 slaves.
10.3.20.105:6380 (4dacd43c...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.132:6385 (8e197d1a...) -> 3 keys | 4096 slots | 0 slaves.
[OK] 4 keys in 5 masters.
0.00 keys per slot on average.

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   1 additional replica(s)
M: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) master
   0 additional replica(s)
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   0 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

# redis-cli -h 10.3.20.132 -p 6386 -c
10.3.20.132:6386> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:8
cluster_size:4
cluster_current_epoch:9
cluster_my_epoch:0
cluster_stats_messages_sent:481
cluster_stats_messages_received:481
10.3.20.132:6386> cluster nodes
8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385 master - 0 1531392646476 9 connected 0-1364 5461-6826 10923-12287
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531392642446 2 connected 12288-16383
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531392643957 8 connected 6827-10922
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 slave 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 0 1531392645470 8 connected
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 master - 0 1531392646981 5 connected 1365-5460
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 slave 6f3639bc0ce4c99d487c9e89c57b290496666483 0 1531392648491 5 connected
34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386 myself,master - 0 0 0 connected
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 slave 5fb133912a7caaac22bd5bbd75af346aa129a766 0 1531392647483 2 connected

// 10.3.20.132:6386(Slave) 配置為 10.3.20.132:6385(Master) 從節(jié)點(diǎn)
10.3.20.132:6386> cluster replicate 8e197d1add3838be26744dde6422b6ccfd205ede
OK
10.3.20.132:6386> cluster nodes
8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385 master - 0 1531392707947 9 connected 0-1364 5461-6826 10923-12287
5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381 master - 0 1531392706941 2 connected 12288-16383
4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380 master - 0 1531392703902 8 connected 6827-10922
2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383 slave 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 0 1531392708959 8 connected
6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379 master - 0 1531392704917 5 connected 1365-5460
1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382 slave 6f3639bc0ce4c99d487c9e89c57b290496666483 0 1531392708971 5 connected
34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386 myself,slave 8e197d1add3838be26744dde6422b6ccfd205ede 0 0 0 connected
6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384 slave 5fb133912a7caaac22bd5bbd75af346aa129a766 0 1531392705923 2 connected

10揭糕、收縮集群

集群架構(gòu)

10.3.20.102:6379 --> 10.3.20.14:6382
10.3.20.105:6380 --> 10.3.20.51:6383
10.3.20.132:6385 --> 10.3.20.132:6386
// 先下線 10.3.20.93:6381(Master) 的從節(jié)點(diǎn) 10.3.20.54:6384(Slave)
# redis-trib.rb info 10.3.20.102:6379
10.3.20.102:6379 (6f3639bc...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.93:6381 (5fb13391...) -> 1 keys | 4096 slots | 1 slaves.
10.3.20.105:6380 (4dacd43c...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.132:6385 (8e197d1a...) -> 3 keys | 4096 slots | 1 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   1 additional replica(s)
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
S: 6ffe8ec154ade4c27532383af3ddad51c3d43373 10.3.20.54:6384
   slots: (0 slots) slave
   replicates 5fb133912a7caaac22bd5bbd75af346aa129a766
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

先下線從節(jié)點(diǎn) 10.3.20.54:6384(Slave)
# redis-trib.rb del-node 10.3.20.102:6379 6ffe8ec154ade4c27532383af3ddad51c3d43373
>>> Removing node 6ffe8ec154ade4c27532383af3ddad51c3d43373 from cluster 10.3.20.102:6379
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

# redis-trib.rb info 10.3.20.102:6379
10.3.20.102:6379 (6f3639bc...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.93:6381 (5fb13391...) -> 1 keys | 4096 slots | 0 slaves.
10.3.20.105:6380 (4dacd43c...) -> 0 keys | 4096 slots | 1 slaves.
10.3.20.132:6385 (8e197d1a...) -> 3 keys | 4096 slots | 1 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   0 additional replica(s)
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

// 再下線 10.3.20.93:6381(Master)(4096/3=1365,10.3.20.93:6381 的槽分 3 部分锻霎,分別遷移到 10.3.20.102:6379著角、10.3.20.105:6380 和 10.3.20.132:6385)
// 遷移 10.3.20.93:6381 的 1365 個(gè)槽到 10.3.20.102:6379
# redis-trib.rb reshard 10.3.20.93:6381
>>> Performing Cluster Check (using node 10.3.20.93:6381)
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   0 additional replica(s)
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 1365
What is the receiving node ID? 6f3639bc0ce4c99d487c9e89c57b290496666483
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1:5fb133912a7caaac22bd5bbd75af346aa129a766
Source node #2:done

Ready to move 1365 slots.
  Source nodes:
    M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:12288-16383 (4096 slots) master
   0 additional replica(s)
  Destination node:
    M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460 (4096 slots) master
   1 additional replica(s)
  Resharding plan:
    Moving slot 12288 from 5fb133912a7caaac22bd5bbd75af346aa129a766
    ……
    Moving slot 13652 from 5fb133912a7caaac22bd5bbd75af346aa129a766
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 12288 from 10.3.20.93:6381 to 10.3.20.102:6379: 
……
Moving slot 13652 from 10.3.20.93:6381 to 10.3.20.102:6379:

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460,12288-13652 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:13653-16383 (2731 slots) master
   0 additional replica(s)
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

// 遷移 10.3.20.93:6381 的 1365 個(gè)槽到 10.3.20.105:6380
# redis-trib.rb reshard 10.3.20.93:6381
>>> Performing Cluster Check (using node 10.3.20.93:6381)
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:13653-16383 (2731 slots) master
   0 additional replica(s)
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460,12288-13652 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 1365
What is the receiving node ID? 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1:5fb133912a7caaac22bd5bbd75af346aa129a766
Source node #2:done

Ready to move 1365 slots.
  Source nodes:
    M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:13653-16383 (2731 slots) master
   0 additional replica(s)
  Destination node:
    M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922 (4096 slots) master
   1 additional replica(s)
  Resharding plan:
    Moving slot 13653 from 5fb133912a7caaac22bd5bbd75af346aa129a766
    ……
    Moving slot 15017 from 5fb133912a7caaac22bd5bbd75af346aa129a766
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 13653 from 10.3.20.93:6381 to 10.3.20.105:6380: 
……
Moving slot 15017 from 10.3.20.93:6381 to 10.3.20.105:6380: 

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460,12288-13652 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:15018-16383 (1366 slots) master
   0 additional replica(s)
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922,13653-15017 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

// 遷移 10.3.20.93:6381 剩下的 1366 個(gè)槽到 10.3.20.132:6385
# redis-trib.rb reshard 10.3.20.93:6381
>>> Performing Cluster Check (using node 10.3.20.93:6381)
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:15018-16383 (1366 slots) master
   0 additional replica(s)
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460,12288-13652 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922,13653-15017 (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 1366
What is the receiving node ID? 8e197d1add3838be26744dde6422b6ccfd205ede
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1:5fb133912a7caaac22bd5bbd75af346aa129a766
Source node #2:done

Ready to move 1366 slots.
  Source nodes:
    M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots:15018-16383 (1366 slots) master
   0 additional replica(s)
  Destination node:
    M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287 (4096 slots) master
   1 additional replica(s)
  Resharding plan:
    Moving slot 15018 from 5fb133912a7caaac22bd5bbd75af346aa129a766
    ……
    Moving slot 16383 from 5fb133912a7caaac22bd5bbd75af346aa129a766
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 15018 from 10.3.20.93:6381 to 10.3.20.132:6385: 
……
Moving slot 16383 from 10.3.20.93:6381 to 10.3.20.132:6385: 

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460,12288-13652 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
M: 5fb133912a7caaac22bd5bbd75af346aa129a766 10.3.20.93:6381
   slots: (0 slots) master
   0 additional replica(s)
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922,13653-15017 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287,15018-16383 (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

// 刪除 10.3.20.93:6381 節(jié)點(diǎn)信息
# redis-trib.rb del-node 10.3.20.102:6379 5fb133912a7caaac22bd5bbd75af346aa129a766
>>> Removing node 5fb133912a7caaac22bd5bbd75af346aa129a766 from cluster 10.3.20.102:6379
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

# redis-trib.rb check 10.3.20.102:6379
>>> Performing Cluster Check (using node 10.3.20.102:6379)
M: 6f3639bc0ce4c99d487c9e89c57b290496666483 10.3.20.102:6379
   slots:1365-5460,12288-13652 (5461 slots) master
   1 additional replica(s)
S: 2e3c0b2c184640fcfae8af3aed622942b25d16dd 10.3.20.51:6383
   slots: (0 slots) slave
   replicates 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b
S: 34585de8b5731f8690a418cc7d84851fedb52f6b 10.3.20.132:6386
   slots: (0 slots) slave
   replicates 8e197d1add3838be26744dde6422b6ccfd205ede
M: 4dacd43c0a5a20d0e2676342107f3e4b125a2b2b 10.3.20.105:6380
   slots:6827-10922,13653-15017 (5461 slots) master
   1 additional replica(s)
S: 1cb93aa1c9e6e5097d321077de16f4d053ee3e05 10.3.20.14:6382
   slots: (0 slots) slave
   replicates 6f3639bc0ce4c99d487c9e89c57b290496666483
M: 8e197d1add3838be26744dde6422b6ccfd205ede 10.3.20.132:6385
   slots:0-1364,5461-6826,10923-12287,15018-16383 (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市旋恼,隨后出現(xiàn)的幾起案子吏口,更是在濱河造成了極大的恐慌,老刑警劉巖冰更,帶你破解...
    沈念sama閱讀 212,718評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件产徊,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡蜀细,警方通過(guò)查閱死者的電腦和手機(jī)舟铜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,683評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)奠衔,“玉大人谆刨,你說(shuō)我怎么就攤上這事塘娶。” “怎么了痊夭?”我有些...
    開(kāi)封第一講書人閱讀 158,207評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)她我。 經(jīng)常有香客問(wèn)我虹曙,道長(zhǎng),這世上最難降的妖魔是什么番舆? 我笑而不...
    開(kāi)封第一講書人閱讀 56,755評(píng)論 1 284
  • 正文 為了忘掉前任酝碳,我火速辦了婚禮,結(jié)果婚禮上合蔽,老公的妹妹穿的比我還像新娘击敌。我一直安慰自己,他們只是感情好拴事,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,862評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布沃斤。 她就那樣靜靜地躺著,像睡著了一般刃宵。 火紅的嫁衣襯著肌膚如雪衡瓶。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 50,050評(píng)論 1 291
  • 那天牲证,我揣著相機(jī)與錄音哮针,去河邊找鬼。 笑死坦袍,一個(gè)胖子當(dāng)著我的面吹牛十厢,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播捂齐,決...
    沈念sama閱讀 39,136評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼蛮放,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了奠宜?” 一聲冷哼從身側(cè)響起包颁,我...
    開(kāi)封第一講書人閱讀 37,882評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎压真,沒(méi)想到半個(gè)月后娩嚼,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,330評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡滴肿,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,651評(píng)論 2 327
  • 正文 我和宋清朗相戀三年岳悟,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片泼差。...
    茶點(diǎn)故事閱讀 38,789評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡竿音,死狀恐怖和屎,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情春瞬,我是刑警寧澤,帶...
    沈念sama閱讀 34,477評(píng)論 4 333
  • 正文 年R本政府宣布套啤,位于F島的核電站宽气,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏潜沦。R本人自食惡果不足惜萄涯,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,135評(píng)論 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望唆鸡。 院中可真熱鬧涝影,春花似錦、人聲如沸争占。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 30,864評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)臂痕。三九已至伯襟,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間握童,已是汗流浹背姆怪。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,099評(píng)論 1 267
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留澡绩,地道東北人稽揭。 一個(gè)月前我還...
    沈念sama閱讀 46,598評(píng)論 2 362
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像肥卡,于是被迫代替她去往敵國(guó)和親溪掀。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,697評(píng)論 2 351

推薦閱讀更多精彩內(nèi)容