说明:把192.168.81.101:9000这个master及对应slave节点从集群中移除
[root@mysql ~]# redis-cli -p 9000 cluster nodes # 查看集群中的节点信息 2ff22acb1e006b9881abc80238e15b4e3fcefbef 127.0.0.1:9003 slave 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 0 1539827599055 12 connected 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 master - 0 1539827597043 9 connected 6827-10922 fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 master - 0 1539827598049 2 connected 12288-16383 ac153a3c1fb10d9d502b153c32dec65c85b2f97c 192.168.81.100:9002 slave fceba6001b95e2169ddd6622436b213324fe8f77 0 1539827601066 6 connected cb8c114d44d289687798508232d31e0a065fdab5 192.168.81.100:9000 slave 6f369311b0ca4c503f337c4bb23424eed3eeb188 0 1539827596039 9 connected 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 master - 0 1539827600062 12 connected 0-1364 5461-6826 10923-12287 cf74b2d9570665b74525802462c74cf2e072ef99 192.168.81.101:9000 myself,master - 0 0 1 connected 1365-5460 # 要移除的节点的槽编号为:1365到5460 71f5695dc1f4322c8ea9066d1b3cd8bb0ab7a329 192.168.81.100:9001 slave cf74b2d9570665b74525802462c74cf2e072ef99 0 1539827595029 5 connected [root@mysql ~]# redis-trib.rb reshard --from cf74b2d9570665b74525802462c74cf2e072ef99 --to 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 --slots 1366 127.0.0.1:9001 # 迁移槽,从192.168.81.101:9000迁移到集群中别的节点上 >>> Performing Cluster Check (using node 127.0.0.1:9001) M: fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 slots:12288-16383 (4096 slots) master 1 additional replica(s) S: 71f5695dc1f4322c8ea9066d1b3cd8bb0ab7a329 192.168.81.100:9001 slots: (0 slots) slave replicates cf74b2d9570665b74525802462c74cf2e072ef99 M: 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 slots:6827-10922 (4096 slots) master 1 additional replica(s) M: 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 slots:0-1364,5461-6826,10923-12287 (4096 slots) master 1 additional replica(s) M: cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 slots:1365-5460 (4096 slots) master 1 additional replica(s) S: ac153a3c1fb10d9d502b153c32dec65c85b2f97c 192.168.81.100:9002 slots: (0 slots) slave replicates fceba6001b95e2169ddd6622436b213324fe8f77 S: 2ff22acb1e006b9881abc80238e15b4e3fcefbef 127.0.0.1:9003 slots: (0 slots) slave replicates 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 S: cb8c114d44d289687798508232d31e0a065fdab5 192.168.81.100:9000 slots: (0 slots) slave replicates 6f369311b0ca4c503f337c4bb23424eed3eeb188 [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. Ready to move 1366 slots. # 此次可以迁移1366个槽 Source nodes: M: cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 slots:1365-5460 (4096 slots) master 1 additional replica(s) Destination node: M: 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 slots:0-1364,5461-6826,10923-12287 (4096 slots) master 1 additional replica(s) Resharding plan: Moving slot 1365 from cf74b2d9570665b74525802462c74cf2e072ef99 Moving slot 1366 from cf74b2d9570665b74525802462c74cf2e072ef99 ... Moving slot 2729 from cf74b2d9570665b74525802462c74cf2e072ef99 Moving slot 2730 from cf74b2d9570665b74525802462c74cf2e072ef99 Do you want to proceed with the proposed reshard plan (yes/no)? yes Moving slot 1365 from 127.0.0.1:9000 to 192.168.81.100:9003: Moving slot 1366 from 127.0.0.1:9000 to 192.168.81.100:9003: ... Moving slot 2728 from 127.0.0.1:9000 to 192.168.81.100:9003: Moving slot 2729 from 127.0.0.1:9000 to 192.168.81.100:9003: Moving slot 2730 from 127.0.0.1:9000 to 192.168.81.100:9003: [root@mysql ~]# redis-cli -p 9001 cluster nodes # 查看集群节点信息 71f5695dc1f4322c8ea9066d1b3cd8bb0ab7a329 192.168.81.100:9001 slave cf74b2d9570665b74525802462c74cf2e072ef99 0 1539827870363 5 connected 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 master - 0 1539827868350 9 connected 6827-10922 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 master - 0 1539827872375 12 connected 0-2730 5461-6826 10923-12287 fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 myself,master - 0 0 2 connected 12288-16383 cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 master - 0 1539827873385 1 connected 2731-5460 # 还有2731到5460号槽还没有迁移完 ac153a3c1fb10d9d502b153c32dec65c85b2f97c 192.168.81.100:9002 slave fceba6001b95e2169ddd6622436b213324fe8f77 0 1539827867345 6 connected 2ff22acb1e006b9881abc80238e15b4e3fcefbef 127.0.0.1:9003 slave 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 0 1539827869356 12 connected cb8c114d44d289687798508232d31e0a065fdab5 192.168.81.100:9000 slave 6f369311b0ca4c503f337c4bb23424eed3eeb188 0 1539827871370 9 connected [root@mysql ~]# redis-trib.rb reshard --from cf74b2d9570665b74525802462c74cf2e072ef99 --to 6f369311b0ca4c503f337c4bb23424eed3eeb188 --slots 2730 127.0.0.1:9002 # 迁移槽,把192.168.81.101:9000剩余的槽迁移到别的节点 >>> Performing Cluster Check (using node 127.0.0.1:9002) M: 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 slots:6827-10922 (4096 slots) master 1 additional replica(s) S: cb8c114d44d289687798508232d31e0a065fdab5 192.168.81.100:9000 slots: (0 slots) slave replicates 6f369311b0ca4c503f337c4bb23424eed3eeb188 S: ac153a3c1fb10d9d502b153c32dec65c85b2f97c 192.168.81.100:9002 slots: (0 slots) slave replicates fceba6001b95e2169ddd6622436b213324fe8f77 S: 2ff22acb1e006b9881abc80238e15b4e3fcefbef 127.0.0.1:9003 slots: (0 slots) slave replicates 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 S: 71f5695dc1f4322c8ea9066d1b3cd8bb0ab7a329 192.168.81.100:9001 slots: (0 slots) slave replicates cf74b2d9570665b74525802462c74cf2e072ef99 M: cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 slots:2731-5460 (2730 slots) master 1 additional replica(s) M: fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 slots:12288-16383 (4096 slots) master 1 additional replica(s) M: 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 slots:0-2730,5461-6826,10923-12287 (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. Ready to move 2730 slots. Source nodes: M: cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 slots:2731-5460 (2730 slots) master 1 additional replica(s) Destination node: M: 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 slots:6827-10922 (4096 slots) master 1 additional replica(s) Resharding plan: Moving slot 2731 from cf74b2d9570665b74525802462c74cf2e072ef99 Moving slot 2732 from cf74b2d9570665b74525802462c74cf2e072ef99 ... Moving slot 5459 from cf74b2d9570665b74525802462c74cf2e072ef99 Moving slot 5460 from cf74b2d9570665b74525802462c74cf2e072ef99 Do you want to proceed with the proposed reshard plan (yes/no)? yes Moving slot 2731 from 127.0.0.1:9000 to 127.0.0.1:9002: Moving slot 2732 from 127.0.0.1:9000 to 127.0.0.1:9002: ... Moving slot 5459 from 127.0.0.1:9000 to 127.0.0.1:9002: Moving slot 5460 from 127.0.0.1:9000 to 127.0.0.1:9002: [root@mysql ~]# redis-cli -p 9001 cluster nodes # 查看集群中节点的信息 71f5695dc1f4322c8ea9066d1b3cd8bb0ab7a329 192.168.81.100:9001 slave 6f369311b0ca4c503f337c4bb23424eed3eeb188 0 1539828016103 13 connected 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 master - 0 1539828017610 13 connected 2731-5460 6827-10922 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 master - 0 1539828016605 12 connected 0-2730 5461-6826 10923-12287 fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 myself,master - 0 0 2 connected 12288-16383 cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 master - 0 1539828013588 1 connected # 192.168.81.101:9000上已经没有槽了 ac153a3c1fb10d9d502b153c32dec65c85b2f97c 192.168.81.100:9002 slave fceba6001b95e2169ddd6622436b213324fe8f77 0 1539828015601 6 connected 2ff22acb1e006b9881abc80238e15b4e3fcefbef 127.0.0.1:9003 slave 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 0 1539828014593 12 connected cb8c114d44d289687798508232d31e0a065fdab5 192.168.81.100:9000 slave 6f369311b0ca4c503f337c4bb23424eed3eeb188 0 1539828012582 13 connected [root@mysql ~]# redis-cli -p 9001 cluster nodes |grep master 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 master - 0 1539828068951 13 connected 2731-5460 6827-10922 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 master - 0 1539828071970 12 connected 0-2730 5461-6826 10923-12287 fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 myself,master - 0 0 2 connected 12288-16383 cf74b2d9570665b74525802462c74cf2e072ef99 127.0.0.1:9000 master - 0 1539828073980 1 connected [root@mysql ~]# redis-trib.rb del-node 127.0.0.1:9001 cb8c114d44d289687798508232d31e0a065fdab5 # 先移除192.168.81.101:9000的slave节点 >>> Removing node cb8c114d44d289687798508232d31e0a065fdab5 from cluster 127.0.0.1:9001 >>> Sending CLUSTER FORGET messages to the cluster... >>> SHUTDOWN the node. [root@mysql ~]# redis-trib.rb del-node 127.0.0.1:9001 cf74b2d9570665b74525802462c74cf2e072ef99 # 移除192.168.81.101:9000节点 >>> Removing node cf74b2d9570665b74525802462c74cf2e072ef99 from cluster 127.0.0.1:9001 >>> Sending CLUSTER FORGET messages to the cluster... >>> SHUTDOWN the node. [root@mysql ~]# redis-cli -p 9000 # 连接192.168.81.101:9000客户端,显示连接失败 Could not connect to Redis at 127.0.0.1:9000: Connection refused Could not connect to Redis at 127.0.0.1:9000: Connection refused not connected> exit [root@mysql ~]# redis-trib.rb del-node 127.0.0.1:9001 cf74b2d9570665b74525802462c74cf2e072ef99 # 移除192.168.81.101:9000节点,显示移除失败,因为集群中已经没有这个节点了 >>> Removing node cf74b2d9570665b74525802462c74cf2e072ef99 from cluster 127.0.0.1:9001 [ERR] No such node ID cf74b2d9570665b74525802462c74cf2e072ef99 [root@mysql ~]# redis-cli -p 9002 cluster nodes # 查看集群中的节点信息 6f369311b0ca4c503f337c4bb23424eed3eeb188 127.0.0.1:9002 myself,master - 0 0 13 connected 2731-5460 6827-10922 ac153a3c1fb10d9d502b153c32dec65c85b2f97c 192.168.81.100:9002 slave fceba6001b95e2169ddd6622436b213324fe8f77 0 1539828535088 6 connected 2ff22acb1e006b9881abc80238e15b4e3fcefbef 127.0.0.1:9003 slave 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 0 1539828539118 12 connected 71f5695dc1f4322c8ea9066d1b3cd8bb0ab7a329 192.168.81.100:9001 slave 6f369311b0ca4c503f337c4bb23424eed3eeb188 0 1539828536098 13 connected fceba6001b95e2169ddd6622436b213324fe8f77 127.0.0.1:9001 master - 0 1539828537106 2 connected 12288-16383 27266dcfd098dfe2a42361d6ab59edf8fb9f5413 192.168.81.100:9003 master - 0 1539828538114 12 connected 0-2730 5461-6826 10923-12287高可用Redis(十一):使用redis-trib.rb工具搭建集群 (4)
内容版权声明:除非注明,否则皆为本站原创文章。