环境: centos 7.9
ip: 192.168.138.21

Redis server v=4.0.8 

同步一台服务器上,指定不同的端口启动redis-server,redis.conf基础配置文件信息如下

# cat redis-7000.conf
port 7000
daemonize yes
logfile /applications/redis/redis-7000.log
dir /applications/redis/
dbfilename 7000-dump.rdb
cluster-enabled yes
# cluster-config-file nodes*.conf 名称要不一样
cluster-config-file nodes-7000.conf
cluster-node-timeout 5000
appendonly yes
appendfilename "appendonly-7000.aof"

 

# 拷贝redis-7000.conf 至redis-7005.conf
[root@ansb01 redis]# cp redis-7000.conf redis-7001.conf
[root@ansb01 redis]# cp redis-7000.conf redis-7002.conf
[root@ansb01 redis]# cp redis-7000.conf redis-7003.conf
[root@ansb01 redis]# cp redis-7000.conf redis-7004.conf
[root@ansb01 redis]# cp redis-7000.conf redis-7005.conf

# 修改对应端口配置文件
[root@ansb01 redis]# sed -i 's/7000/7001/g' redis-7001.conf
[root@ansb01 redis]# sed -i 's/7000/7002/g' redis-7002.conf
[root@ansb01 redis]# sed -i 's/7000/7003/g' redis-7003.conf
[root@ansb01 redis]# sed -i 's/7000/7004/g' redis-7004.conf
[root@ansb01 redis]# sed -i 's/7000/7005/g' redis-7005.conf

分别启动不同端口服务,查看服务信息

# 查看redis
[root@ansb01 redis]# ps -ef|grep redis
root      5245     1  0 21:55 ?        00:00:01 ./bin/redis-server *:7000 [cluster]
root      5348     1  0 22:05 ?        00:00:00 ./bin/redis-server *:7001 [cluster]
root      5357     1  0 22:05 ?        00:00:00 ./bin/redis-server *:7002 [cluster]
root      5365     1  0 22:06 ?        00:00:00 ./bin/redis-server *:7003 [cluster]
root      5374     1  0 22:06 ?        00:00:00 ./bin/redis-server *:7004 [cluster]
root      5380     1  0 22:06 ?        00:00:00 ./bin/redis-server *:7005 [cluster]

 准备redis-trib.rb运行环境

 

wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz

yum -y install zlib-devel
tar xvf ruby-2.5.1.tar.gz

cd ruby-2.5.1/

./configure -prefix=/usr/local/ruby

make

make install

cd /usr/local/ruby/

cp bin/ruby /usr/local/bin

cp bin/gem /usr/local/bin

 

安装rubygem redis依赖

wget http://rubygems.org/downloads/redis-3.3.0.gem

gem install -l redis-3.3.0.gem

 

 redis-trib.rb支持的操作

 

   

[root@ansb01 src]# ./redis-trib.rb help
Usage: redis-trib <command> <options> <arguments ...>

  create          host1:port1 ... hostN:portN
                  --replicas <arg>
  check           host:port
  info            host:port
  fix             host:port
                  --timeout <arg>
  reshard         host:port
                  --from <arg>
                  --to <arg>
                  --slots <arg>
                  --yes
                  --timeout <arg>
                  --pipeline <arg>
  rebalance       host:port
                  --weight <arg>
                  --auto-weights
                  --use-empty-masters
                  --timeout <arg>
                  --simulate
                  --pipeline <arg>
                  --threshold <arg>
  add-node        new_host:new_port existing_host:existing_port
                  --slave
                  --master-id <arg>
  del-node        host:port node_id
  set-timeout     host:port milliseconds
  call            host:port command arg arg .. arg
  import          host:port
                  --from <arg>
                  --copy
                  --replace
  help            (show this help)

For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.

  

支持的操作如下:

1. create:创建集群

2. check:检查集群

3. info:查看集群信息

4. fix:修复集群

5. reshard:在线迁移slot

6. rebalance:平衡集群节点slot数量

7. add-node:添加新节点

8. del-node:删除节点

9. set-timeout:设置节点的超时时间

10. call:在集群所有节点上执行命令

11. import:将外部redis数据导入集群

 

创建集群

 

如果您使用 Redis 5 或更高版本,这很容易实现,因为我们在 Redis Cluster 命令行实用程序的帮助下嵌入到 中redis-cli,可用于创建新集群、检查或重新分片现有集群等。

 

对于 Redis 版本 3 或 4,有一个redis-trib.rb非常相似的旧工具。您可以src在Redis源代码分发目录中找到它。您需要安装redisgem 才能运行redis-trib.

# 使用redis-trib.rb用于Redis的4或3型:
[root@ansb01 src]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 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
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7004 to 127.0.0.1:7000
Adding replica 127.0.0.1:7005 to 127.0.0.1:7001
Adding replica 127.0.0.1:7003 to 127.0.0.1:7002
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
M: 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
S: 0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003
   replicates 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa
S: 5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004
   replicates c56b3b07bec108fe51aa68214b93b4b0a6999798
S: 8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
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:7000)
M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004
   slots: (0 slots) slave
   replicates c56b3b07bec108fe51aa68214b93b4b0a6999798
M: 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: 0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003
   slots: (0 slots) slave
   replicates 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

  

# 查看集群信息
[root@ansb01 redis]# ./bin/redis-cli -p 7000 cluster info
cluster_state:ok                        # 状态为ok
cluster_slots_assigned:16384            # 标记slot共有16384    
cluster_slots_ok:16384                  # 已分配slot有16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6                   # 当前集群有6个节点        
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:576
cluster_stats_messages_pong_sent:603
cluster_stats_messages_sent:1179
cluster_stats_messages_ping_received:598
cluster_stats_messages_pong_received:576
cluster_stats_messages_meet_received:5
cluster_stats_messages_received:1179


# 查看当前集群节点信息
[root@ansb01 redis]# ./bin/redis-cli -p 7000 cluster nodes
5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004@17004 slave c56b3b07bec108fe51aa68214b93b4b0a6999798 0 1631718314377 5 connected
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1631718314000 2 connected 5461-10922
8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005@17005 slave 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 0 1631718314000 6 connected
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1631718314000 3 connected 10923-16383
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 myself,master - 0 1631718315000 1 connected 0-5460
0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003@17003 slave 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 0 1631718315399 4 connected

  

 添加主节点

 

#创建一个redis-7006.conf 配置文件
[root@ansb01 redis]# cat redis-7006.conf 
port 7006
daemonize yes
logfile /applications/redis/redis-7006.log
dir /applications/redis/
dbfilename 7006-dump.rdb
cluster-enabled yes
cluster-config-file nodes-7006.conf
cluster-node-timeout 5000
appendonly yes
appendfilename "appendonly-7006.aof"

# 启动7006端口redis服务
[root@ansb01 redis]# ./bin/redis-server redis-7006.conf
[root@ansb01 redis]# ps -ef|grep redis
root      5440     1  0 06:46 ?        00:00:21 ./bin/redis-server *:7000 [cluster]
root      5445     1  0 06:46 ?        00:00:21 ./bin/redis-server *:7001 [cluster]
root      5450     1  0 06:46 ?        00:00:21 ./bin/redis-server *:7002 [cluster]
root      5455     1  0 06:46 ?        00:00:22 ./bin/redis-server *:7003 [cluster]
root      5460     1  0 06:46 ?        00:00:22 ./bin/redis-server *:7004 [cluster]
root      5465     1  0 06:46 ?        00:00:21 ./bin/redis-server *:7005 [cluster]
root     23178 22956  0 08:38 pts/4    00:00:00 ./bin/redis-cli -c -p 7000
root     23405     1  1 08:44 ?        00:00:00 ./bin/redis-server *:7006 [cluster]

[root@ansb01 src]# ./redis-trib.rb add-node 127.0.0.1:7006 127.0.0.1:7000
>>> Adding node 127.0.0.1:7006 to cluster 127.0.0.1:7000
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004
   slots: (0 slots) slave
   replicates c56b3b07bec108fe51aa68214b93b4b0a6999798
M: 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: 0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003
   slots: (0 slots) slave
   replicates 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 127.0.0.1:7006 to make it join the cluster.
[OK] New node added correctly.

备注:add-node命令将新节点的地址指定为第一个参数,并将集群中随机现有节点的地址指定为第二个参数

# 查看添加的节点信息
[root@ansb01 redis]# ./bin/redis-cli -c -p 7006 cluster nodes
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 master - 0 1632099162269 1 connected 0-5460
8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005@17005 slave 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 0 1632099160940 1 connected
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1632099161962 3 connected 10923-16383
5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004@17004 slave c56b3b07bec108fe51aa68214b93b4b0a6999798 0 1632099161000 3 connected
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1632099161000 2 connected 5461-10922
0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003@17003 slave 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 0 1632099160526 2 connected
23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006@17006 myself,master - 0 1632099160000 0 connected

请注意,由于此节点已连接到集群,因此它已经能够正确重定向客户端查询,并且通常是集群的一部分。然而,与其他大师相比,它有两个特点:
   1)它没有数据,因为它没有分配的哈希槽。
   2)因为是没有分配slots的master,所以当slave想成为master时不参与选举过程。

 

  

添加从节点

 

添加新节点为副本
添加新副本可以通过两种方式执行
命令格式如下:
redis-trib add-node --slave [--master-id <arg>] new_host:new_port existing_host:existing_port 

1)使用--slave参数 指定127.0.0.1:7007副本
[root@ansb01 src]# ./redis-trib.rb add-node --slave 127.0.0.1:7007 127.0.0.1:7000
>>> Adding node 127.0.0.1:7007 to cluster 127.0.0.1:7000
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004
   slots: (0 slots) slave
   replicates c56b3b07bec108fe51aa68214b93b4b0a6999798
M: 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
M: 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006
   slots: (0 slots) master
   0 additional replica(s)
M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: 0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003
   slots: (0 slots) slave
   replicates 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
Automatically selected master 127.0.0.1:7006
>>> Send CLUSTER MEET to node 127.0.0.1:7007 to make it join the cluster.
Waiting for the cluster to join.
>>> Configure node as replica of 127.0.0.1:7006.
[OK] New node added correctly.


27.0.0.1:7006> cluster nodes
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 master - 0 1632100833596 1 connected 0-5460
8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005@17005 slave 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 0 1632100832785 1 connected
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1632100832680 3 connected 10923-16383
5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004@17004 slave c56b3b07bec108fe51aa68214b93b4b0a6999798 0 1632100833000 3 connected
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1632100833802 2 connected 5461-10922
0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003@17003 slave 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 0 1632100833000 2 connected
85c4206fda2307e57b6a55f855c6e6156f54f5e0 127.0.0.1:7007@17007 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632100833596 0 connected
23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006@17006 myself,master - 0 1632100832000 0 connected
127.0.0.1:7006> 


请注意,这里的命令行与我们用来添加新主服务器的命令行完全相同,因此我们没有指定要将副本添加到哪个主服务器。在这种情况下,redis-trib.rb 会在副本较少的主节点中添加新节点作为随机主节点的副本

2)您可以使用以下命令行准确指定要使用新副本定位的主服务器

[root@ansb01 redis]# ./bin/redis-cli -c -p 7006 cluster nodes|grep master
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 master - 0 1632101087534 1 connected 0-5460
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1632101088555 3 connected 10923-16383
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1632101087000 2 connected 5461-10922
23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006@17006 myself,master - 0 1632101086000 0 connected

# 将新增加的7008端口redis服务添加到7000端口主节点

[root@ansb01 src]# ./redis-trib.rb add-node --slave --master-id 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7008 127.0.0.1:7000
>>> Adding node 127.0.0.1:7008 to cluster 127.0.0.1:7000
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: 5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004
   slots: (0 slots) slave
   replicates c56b3b07bec108fe51aa68214b93b4b0a6999798
M: 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 85c4206fda2307e57b6a55f855c6e6156f54f5e0 127.0.0.1:7007
   slots: (0 slots) slave
   replicates 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4
S: 8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
M: 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006
   slots: (0 slots) master
   1 additional replica(s)
M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: 0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003
   slots: (0 slots) slave
   replicates 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 127.0.0.1:7008 to make it join the cluster.
Waiting for the cluster to join.
>>> Configure node as replica of 127.0.0.1:7000.
[OK] New node added correctly.

注意:--slave和--master-id必须写在前面,同样的参数,如果是下面这样写法,会提示错误,

# 查看添加的从节点
[root@ansb01 redis]# ./bin/redis-cli -c -p 7006 cluster nodes|grep 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
99c3bf3255711f9ca1ad5b662c8c55d086c858da 127.0.0.1:7008@17008 slave 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 0 1632101400826 1 connected
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 master - 0 1632101401545 1 connected 0-5460
8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005@17005 slave 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 0 1632101401546 1 connected

 

 重新分片 reshard

 

[root@ansb01 src]# ./redis-trib.rb reshard 127.0.0.1:7000
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   2 additional replica(s)
S: 5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004
   slots: (0 slots) slave
   replicates c56b3b07bec108fe51aa68214b93b4b0a6999798
M: 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
S: 85c4206fda2307e57b6a55f855c6e6156f54f5e0 127.0.0.1:7007
   slots: (0 slots) slave
   replicates 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4
S: 99c3bf3255711f9ca1ad5b662c8c55d086c858da 127.0.0.1:7008
   slots: (0 slots) slave
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
S: 8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005
   slots: (0 slots) slave
   replicates 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
M: 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006
   slots: (0 slots) master
   1 additional replica(s)
M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: 0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003
   slots: (0 slots) slave
   replicates 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa
[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)? 200 
# 提示需要迁移多个槽 填写 200
What is the receiving node ID? 
# 紧跟着它会提示槽从哪些节点中迁出。
# 如果指定为all,则待迁移的槽在剩余节点中平均分配,在这里,127.0.0.1:7000和127.0.0.1:7002各迁移100个槽出来。
# 也可从指定节点中迁出,这个时候,必须指定源节点的节点ID,最后以done结束,如下所示,
Source node #1:5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
Source node #2:c56b3b07bec108fe51aa68214b93b4b0a6999798
Source node #3:done


Ready to move 200 slots.
  Source nodes:
    M: 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000
   slots:0-5460 (5461 slots) master
   2 additional replica(s)
    M: c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
  Destination node:
    M: 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006
   slots: (0 slots) master
   1 additional replica(s)
  Resharding plan:
    Moving slot 0 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 1 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 2 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 3 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 4 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 5 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 6 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 7 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 8 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 9 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 10 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 11 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 12 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 13 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 14 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 15 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 16 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 17 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 18 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 19 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 20 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 21 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 22 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 23 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 24 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 25 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 26 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 27 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 28 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 29 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 30 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 31 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 32 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 33 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 34 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 35 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 36 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 37 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 38 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 39 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 40 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 41 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 42 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 43 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 44 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 45 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 46 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 47 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 48 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 49 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 50 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 51 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 52 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 53 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 54 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 55 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 56 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 57 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 58 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 59 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 60 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 61 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 62 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 63 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 64 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 65 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 66 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 67 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 68 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 69 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 70 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 71 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 72 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 73 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 74 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 75 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 76 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 77 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 78 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 79 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 80 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 81 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 82 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 83 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 84 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 85 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 86 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 87 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 88 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 89 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 90 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 91 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 92 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 93 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 94 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 95 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 96 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 97 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 98 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 99 from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
    Moving slot 10923 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10924 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10925 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10926 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10927 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10928 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10929 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10930 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10931 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10932 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10933 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10934 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10935 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10936 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10937 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10938 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10939 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10940 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10941 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10942 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10943 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10944 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10945 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10946 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10947 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10948 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10949 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10950 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10951 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10952 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10953 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10954 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10955 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10956 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10957 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10958 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10959 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10960 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10961 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10962 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10963 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10964 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10965 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10966 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10967 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10968 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10969 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10970 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10971 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10972 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10973 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10974 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10975 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10976 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10977 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10978 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10979 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10980 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10981 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10982 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10983 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10984 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10985 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10986 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10987 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10988 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10989 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10990 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10991 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10992 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10993 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10994 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10995 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10996 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10997 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10998 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 10999 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11000 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11001 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11002 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11003 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11004 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11005 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11006 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11007 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11008 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11009 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11010 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11011 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11012 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11013 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11014 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11015 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11016 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11017 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11018 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11019 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11020 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11021 from c56b3b07bec108fe51aa68214b93b4b0a6999798
    Moving slot 11022 from c56b3b07bec108fe51aa68214b93b4b0a6999798
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 0 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 1 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 2 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 3 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 4 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 5 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 6 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 7 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 8 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 9 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 10 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 11 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 12 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 13 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 14 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 15 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 16 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 17 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 18 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 19 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 20 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 21 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 22 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 23 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 24 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 25 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 26 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 27 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 28 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 29 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 30 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 31 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 32 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 33 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 34 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 35 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 36 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 37 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 38 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 39 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 40 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 41 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 42 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 43 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 44 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 45 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 46 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 47 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 48 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 49 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 50 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 51 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 52 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 53 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 54 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 55 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 56 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 57 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 58 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 59 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 60 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 61 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 62 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 63 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 64 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 65 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 66 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 67 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 68 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 69 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 70 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 71 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 72 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 73 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 74 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 75 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 76 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 77 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 78 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 79 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 80 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 81 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 82 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 83 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 84 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 85 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 86 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 87 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 88 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 89 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 90 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 91 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 92 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 93 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 94 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 95 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 96 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 97 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 98 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 99 from 127.0.0.1:7000 to 127.0.0.1:7006: 
Moving slot 10923 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10924 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10925 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10926 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10927 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10928 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10929 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10930 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10931 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10932 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10933 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10934 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10935 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10936 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10937 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10938 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10939 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10940 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10941 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10942 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10943 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10944 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10945 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10946 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10947 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10948 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10949 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10950 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10951 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10952 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10953 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10954 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10955 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10956 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10957 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10958 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10959 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10960 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10961 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10962 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10963 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10964 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10965 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10966 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10967 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10968 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10969 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10970 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10971 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10972 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10973 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10974 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10975 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10976 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10977 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10978 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10979 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10980 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10981 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10982 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10983 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10984 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10985 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10986 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10987 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10988 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10989 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10990 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10991 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10992 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10993 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10994 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10995 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10996 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10997 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10998 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 10999 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11000 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11001 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11002 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11003 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11004 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11005 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11006 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11007 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11008 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11009 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11010 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11011 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11012 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11013 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11014 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11015 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11016 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11017 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11018 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11019 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11020 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11021 from 127.0.0.1:7002 to 127.0.0.1:7006: 
Moving slot 11022 from 127.0.0.1:7002 to 127.0.0.1:7006: 


# 查看迁移后的槽分配
[root@ansb01 redis]# ./bin/redis-cli -c -p 7006 cluster nodes|grep master
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1632103476000 2 connected 5461-10922
23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006@17006 myself,master - 0 1632103476000 7 connected 0-99 10923-11022
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 master - 0 1632103477542 1 connected 100-5460
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1632103477000 3 connected 11023-16383

命令行中使用,命令格式如下:
redis-trib.rb reshard host:port --from <arg> --to <arg> --slots <arg> --yes --timeout <arg> --pipeline <arg>
其中,

host:port:必传参数,集群内任意节点地址,用来获取整个集群信息。

--from:源节点id,如果有多个源节点,使用逗号分隔,如果是all,则源节点为集群内出目标节点外的其它所有主节点。

--to:目标节点id,只能填写一个。

--slots:需要迁移槽的总数量。

--yes:迁移无需用户手动确认。

--timeout:控制每次migrate操作的超时时间,默认为60000毫秒。

--pipeline:控制每次批量迁移键的数量,默认为10。

[root@ansb01 src]# ./redis-trib.rb reshard --from 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e --to 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4  --slots 5360 --yes --pipeline 100 127.0.0.1:7002

 

 删除节点

 

 

 

[root@ansb01 redis]# ./bin/redis-cli -c -p 7006 cluster nodes
99c3bf3255711f9ca1ad5b662c8c55d086c858da 127.0.0.1:7008@17008 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632104700528 7 connected
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1632104700000 2 connected 5461-10922
5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004@17004 slave c56b3b07bec108fe51aa68214b93b4b0a6999798 0 1632104699099 3 connected
23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006@17006 myself,master - 0 1632104700000 7 connected 0-5460 10923-11022
5cf0519f5067742f75bc84d3d9f6c6d9521fe95e 127.0.0.1:7000@17000 master - 0 1632104700528 1 connected
8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005@17005 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632104700530 7 connected
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1632104699000 3 connected 11023-16383
0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003@17003 slave 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 0 1632104700000 2 connected
85c4206fda2307e57b6a55f855c6e6156f54f5e0 127.0.0.1:7007@17007 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632104700726 7 connected



[root@ansb01 src]# ./redis-trib.rb del-node 127.0.0.1:7002 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e
>>> Removing node 5cf0519f5067742f75bc84d3d9f6c6d9521fe95e from cluster 127.0.0.1:7002
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

# 在删除节点之前,其对应的槽必须为空,所以,在进行节点删除动作之前,必须使用redis-trib.rb reshard将其迁移出去。


[root@ansb01 redis]# ./bin/redis-cli -c -p 7006 cluster nodes
99c3bf3255711f9ca1ad5b662c8c55d086c858da 127.0.0.1:7008@17008 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632104913649 7 connected
2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 127.0.0.1:7001@17001 master - 0 1632104914568 2 connected 5461-10922
5891169f86b44ac812fab99594d81bd9f8a3081c 127.0.0.1:7004@17004 slave c56b3b07bec108fe51aa68214b93b4b0a6999798 0 1632104914164 3 connected
23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 127.0.0.1:7006@17006 myself,master - 0 1632104913000 7 connected 0-5460 10923-11022
8fd12dd488bcd226202ffb0814f8c5d57b62ffb3 127.0.0.1:7005@17005 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632104913549 7 connected
c56b3b07bec108fe51aa68214b93b4b0a6999798 127.0.0.1:7002@17002 master - 0 1632104913000 3 connected 11023-16383
0ee1eac88e12ba1f0305f8adcb3f8212731a68cf 127.0.0.1:7003@17003 slave 2f6aa651087e63d5e97a03b7cdd1917fe0010ffa 0 1632104912128 2 connected
85c4206fda2307e57b6a55f855c6e6156f54f5e0 127.0.0.1:7007@17007 slave 23b3adf877cb8ba29f83f57ab95ccfe4131b9ea4 0 1632104913000 7 connected

 

集群相关命令

CLUSTER INFO 打印集群的信息
CLUSTER NODES 列出集群当前已知的所有节点(node),以及这些节点的相关信息。 
CLUSTER MEET <ip> <port> 将 ip 和 port 所指定的节点添加到集群当中,让它成为集群的一份子。
CLUSTER FORGET <node_id> 从集群中移除 node_id 指定的节点。
CLUSTER REPLICATE <node_id> 将当前节点设置为 node_id 指定的节点的从节点。
CLUSTER SAVECONFIG 将节点的配置文件保存到硬盘里面。
CLUSTER ADDSLOTS <slot> [slot ...] 将一个或多个槽(slot)指派(assign)给当前节点。
CLUSTER DELSLOTS <slot> [slot ...] 移除一个或多个槽对当前节点的指派。
CLUSTER FLUSHSLOTS 移除指派给当前节点的所有槽,让当前节点变成一个没有指派任何槽的节点。
CLUSTER SETSLOT <slot> NODE <node_id> 将槽 slot 指派给 node_id 指定的节点。
CLUSTER SETSLOT <slot> MIGRATING <node_id> 将本节点的槽 slot 迁移到 node_id 指定的节点中。
CLUSTER SETSLOT <slot> IMPORTING <node_id> 从 node_id 指定的节点中导入槽 slot 到本节点。
CLUSTER SETSLOT <slot> STABLE 取消对槽 slot 的导入(import)或者迁移(migrate)。 
CLUSTER KEYSLOT <key> 计算键 key 应该被放置在哪个槽上。
CLUSTER COUNTKEYSINSLOT <slot> 返回槽 slot 目前包含的键值对数量。
CLUSTER GETKEYSINSLOT <slot> <count> 返回 count 个 slot 槽中的键。 
CLUSTER SLAVES node-id 返回一个master节点的slaves 列表