After the cluster is set up, it is necessary to add a node for capacity expansion. Then copy a 7006, instead of the corresponding redis.conf (copy the change port is good, if the copy of Redis belongs to the cluster before, you need to put the associated node.conf, such as remove)
[[Email protected]7006]# vim redis.conf [[email protected]7006]# src/redis-server redis.conf [[email protected]7006]#PS-ef |grepRedisroot2993 2959 0 the: -pts/0 xx:xx:xxSrc/redis-server *:6379Root2999 1 0 the: the?xx:xx:xxSrc/redis-server *:7000[Cluster]root3006 1 0 the: the?xx:xx:xxSrc/redis-server *:7001[Cluster]root3013 1 0 the: the?xx:xx:xxSrc/redis-server *:7002[Cluster]root3017 1 0 the: -?xx:xx:xxSrc/redis-server *:7003[Cluster]root3021 1 0 the: -?xx:xx:xxSrc/redis-server *:7004[Cluster]root3028 1 0 the: -?xx:xx:xxSrc/redis-server *:7005[Cluster]root3061 1 0 the: -?xx:xx:xxSrc/redis-server *:7006[Cluster]
(1) Adding nodes
A simple command: The previous address is a newly added Redis, followed by any one of the previous clusters.
7006 127.0. 0.1:7006127.0. 0.1:7001
>>> Adding Node127.0.0.1:7006To cluster127.0.0.1:7001Connecting to Node127.0.0.1:7001: okconnecting to Node127.0.0.1:7004: okconnecting to Node127.0.0.1:7002: okconnecting to Node127.0.0.1:7005: okconnecting to Node127.0.0.1:7000: okconnecting to Node127.0.0.1:7003: OK>>> performing Cluster Check (using node127.0.0.1:7001) M:0bbc46d087d7256fb7b71ca35871446e29926afa127.0.0.1:7001Slots:5461-10922(5462slots) Master1additional replica (s) s:ec376f305428afde24aa363919a863f01908c140127.0.0.1:7004Slots: (0slots) Slave replicates 0bbc46d087d7256fb7b71ca35871446e29926afam:0b521aa8664b2e51475470230f3a975bdd4d1909 127.0.0.1:7002Slots:10923-16383(5461slots) Master1additional replica (s) s:d1a7c6485909a119a1c276f3972b8ae3f93e52d7127.0.0.1:7005Slots: (0slots) Slave replicates 0b521aa8664b2e51475470230f3a975bdd4d1909m:9b7b98c4bf2517e4f172a895b5728d13bef62952 127.0.0.1:7000Slots:0-5460(5461slots) Master1additional replica (s) s:ee95130f0aed20c62881df8070d7690c4608a7cc127.0.0.1:7003Slots: (0slots) Slave replicates 9b7b98c4bf2517e4f172a895b5728d13bef62952[OK] All nodes agree about slots configuration. >>> Check forOpen Slots ...>>>Check Slots Coverage ... [OK] All16384 slots covered. Connecting to Node127.0.0.1:7006: OK>>> Send CLUSTER MEET to Node127.0.0.1:7006To MakeItJoinThe cluster. [OK] New node added correctly.
You can enter any machine to see if a new node has been added, and you will find that the node you just added does not have any hash slots hosted, because there is data in the wood. Adding the slave node only needs to add the--slave parameter
[[Email protected]7006]# Src/redis-cli-c-P7001127.0.0.1:7001>Cluster Nodes0bbc46d087d7256fb7b71ca35871446e29926afa127.0.0.1:7001Myself,master-0 0 2Connected5461-1092232cc36d5deead5d8eb3208120d6f38358c9b6a55127.0.0.1:7006Master-0 1437992923735 0connectedec376f305428afde24aa363919a863f01908c140127.0.0.1:7004Slave 0bbc46d087d7256fb7b71ca35871446e29926afa0 1437992924736 5connected0b521aa8664b2e51475470230f3a975bdd4d1909127.0.0.1:7002Master-0 1437992924736 3Connected10923-16383D1a7c6485909a119a1c276f3972b8ae3f93e52d7127.0.0.1:7005Slave 0b521aa8664b2e51475470230f3a975bdd4d19090 1437992922732 6connected9b7b98c4bf2517e4f172a895b5728d13bef62952127.0.0.1:7000Master-0 1437992923234 1Connected0-5460ee95130f0aed20c62881df8070d7690c4608a7cc127.0.0.1:7003Slave 9b7b98c4bf2517e4f172a895b5728d13bef629520 1437992924236 4Connected
(2) Deleting a node
Before deleting a node, the first thing is to ensure that there is no data in the node, and if there is data to be fragmented, transfer the data. followed by the ID with cluster nodes will be able to find the corresponding ~
Delete the data I also need to study ... Because of some very humble reason ~ ~, ./redis-trib.rb reshard 127.0. 0.1:9003 This is the command that is transferred when the data is assigned to those hash slots.
[[Email protected]7006]# src/redis-trib.rb Del-node127.0.0.1:7001 'c8ed852a52863e941a6e63037e018eb2952b776a'>>> removing node c8ed852a52863e941a6e63037e018eb2952b776a from cluster127.0.0.1:7001Connecting to Node127.0.0.1:7001: okconnecting to Node127.0.0.1:7004: okconnecting to Node127.0.0.1:7002: okconnecting to Node127.0.0.1:7005: okconnecting to Node127.0.0.1:7006: okconnecting to Node127.0.0.1:7000: okconnecting to Node127.0.0.1:7003: OK>>>sending CLUSTER forget messages to the CLUSTER ...>>> SHUTDOWN the node.
Okay, just pretend he's doing a good job of deleting it.
There is also a need to add, and then continue to add ...
Redis cluster deployment and common operations commands (bottom)