Redis 3 cluster (ii)

Source: Internet
Author: User
Tags node redis redis cluster


The basic building of a Redis cluster is described in Redis 3 cluster (i). This section focuses on the operation of the Redis cluster.

Add master node to cluster
    • Create a new instance of port 7006 as per Redis cluster one, and start the instance

    • Add 7006 to the cluster:

REDIS-TRIB.RB Add-node 127.0.0.1:7006 127.0.0.1:7000

Node: The new node does not contain any data because it does not contain any slots. The newly added add-on is a master node that will not be selected when the cluster needs to upgrade a slave node to a new master node.

    • To assign a hash slot to a new node:

redis-trib.rb reshard 127.0.0.1:7000# follow the prompts to select the number of slots to migrate (PS: select here) how many slots do  you want to move  (from 1 to 16384)  500# Select the Node-idwhat to accept these slots  is the receiving node id? f51e26b5d5ff74f85341f06f28f125b7254e61bf# Select slot Source: # All means re-allocating from all master, #或者数据要提取slot的master节点id, and end with done 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:3375be2ccc321932e8853234ffa87ee9fde973ffsource node  #2:d one# Print the moved slot, enter Yes to begin moving the slot and the corresponding data. #Do  you want to proceed with the proposed reshard plan  (yes/no) ?  yes# End
    • To view operation results:

REDIS-CLI-C-P 7000cluster nodes

You can see that 7006 of the returned cluster information has 0-999 hash slots.

Adding slave nodes to the cluster
    • Create a new instance of port 7007 as per Redis cluster one, and start the instance

    • Add 7007 to the cluster:

REDIS-TRIB.RB Add-node 127.0.0.1:7007 127.0.0.1:7000
    • Slave set to 7006:

REDIS-CLI-C-P 7007# parameter is idcluster replicate 2b9ebcbd627ff0fd7a7bbcc5332fb09e72788835 of master node
Delete a Slave node
#redis-trib del-node ip:port ' <node-id> ' redis-trib.rb del-node 127.0.0.1:7007 ' c7ee2fca17cb79fe3c9822ced1d4f6c5e169e378 '
Delete a master node

Before deleting the master node, first use Reshard to remove all of the master slots and then delete the current node (currently only the slots of the deleted master are migrated to one node)

redis-trib.rb reshard 127.0.0.1:7006# follow the prompts to select the number of slots to migrate (PS: select here) how many slots do  you want to move  (from 1 to 16384)  500# Select the Node-idwhat to accept these slots  is the receiving node id? f51e26b5d5ff74f85341f06f28f125b7254e61bf# Select slot Source: # All means re-allocating from all master, #或者数据要提取slot的master节点id, and end with done 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:3375be2ccc321932e8853234ffa87ee9fde973ffsource node  #2:d one# Print the moved slot, enter Yes to begin moving the slot and the corresponding data. #Do  you want to proceed with the proposed reshard plan  (yes/no) ?  yes# End # Delete empty master node redis-trib.rb del-node 127.0.0.1:7006  ' c7ee2fca17cb79fe3c9822ced1d4f6c5e169e378 ' 


Redis 3 cluster (ii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.