Redis Cluster Common commands

Source: Internet
Author: User
Tags redis cluster

#1, redis-cli command into the cluster environment

Redis-cli-c-P 7000


#2, view the status of the entire Redis cluster, see who is the master, who is from, and often in two ways.

#2.1, through redis-trib.rb check method,

./REDIS-TRIB.RB Check 127.0.0.1:7000

#2.2, through the REDIS-CLI way to view,

REDIS-CLI-C-P 7000 cluster nodes


#3, add master node to cluster

#3.1. According to Redis cluster one, create a new instance of Port 7006 and start the instance (as with other nodes, be aware of modifying the port.) )

#3.2, add 7006 to the cluster

cd/data/soft/redis/src/

./redis-trib.rb Add-node 127.0.0.1:7006 127.0.0.1:7000

#3.3. See all cluster nodes to see if the 7006 node is added successfully

REDIS-CLI-C-P 7000 cluster nodes

7adf4b58e321bdc0f5962dfdc1ab0eb3e6835b30 127.0.0.1:7004 Slave 757c2dcebb7b8effca5e89d5c44229f9a33f6e54 0 1451322932189 5 Connected

f3951a3c666b429a095375799c1ab49e694a291c 127.0.0.1:7005 Slave fd92a2277ad03bf7ad51f5865edb613f498cf409 0 1451322933202 6 Connected

757c2dcebb7b8effca5e89d5c44229f9a33f6e54 127.0.0.1:7001 master-0 1451322931685 2 connected 5795-10922

84c29ba2d6aa9e6179d0faeabc54bb8cd443c4ae 127.0.0.1:7003 Slave 721d0479cbd308eac871b2abe3b5805db80d2fe3 0 1451322931181 8 Connected

fd92a2277ad03bf7ad51f5865edb613f498cf409 127.0.0.1:7002 master-0 1451322932692 3 connected 11256-16383

Cee383ab949eeb33d58aacde89c9cfb8eaa65eab 127.0.0.1:7006 master-0 1451322933202 0 connected

721d0479cbd308eac871b2abe3b5805db80d2fe3 127.0.0.1:7000 myself,master-0 0 8 connected 0-5794 10923-11255

#3.4. Assign a hash slot to the newly added 7006 node

cd/data/soft/redis/src/

./redis-trib.rb Reshard 127.0.0.1:7000

#3.4.1. Select the number of slots to migrate according to the prompts (PS: Select 1000 here)

How many slots does want to move (from 1 to 16384)? 1000

#3.4.2. Select the Node-id (PS: 7006-node Node-id) to accept these slots

What is the receiving node ID? Cee383ab949eeb33d58aacde89c9cfb8eaa65eab

#3.4.3, select slot Source:

#all表示从所有的master重新分配,

#或者数据要提取slot的master节点id, End With done (PS: only 7000-node slots are selected here)

Please enter the source node IDs.

The Type ' All ' is the nodes as source nodes for the hash slots.

Type ' Done ' once your entered all the source nodes IDs.

Source node #1:721d0479cbd308eac871b2abe3b5805db80d2fe3

Source node #2:d One

#3.4.4. After printing the slot that was moved, enter Yes to begin moving the slot and the corresponding data.

Do you want to proceed with the proposed Reshard plan (yes/no)? Yes

#3.5. See if 7006 node becomes master node (connected in 0-999 range)

REDIS-CLI-P 7000 Cluster Nodes | grep Master | grep 7006

Cee383ab949eeb33d58aacde89c9cfb8eaa65eab 127.0.0.1:7006 master-0 1451325140212 9 Connected 0-999

#4, adding slave nodes to the cluster

#4.1. According to Redis cluster one, create a new instance of Port 7007 and start the instance (as with other nodes, be aware of modifying the port.) )

#4.2, add 7006 to the cluster

cd/data/soft/redis/src/

./redis-trib.rb Add-node 127.0.0.1:7007 127.0.0.1:7000

#4.3. See all cluster nodes to see if the 7007 node is added successfully

REDIS-CLI-C-P 7000 cluster nodes

7adf4b58e321bdc0f5962dfdc1ab0eb3e6835b30 127.0.0.1:7004 Slave 757c2dcebb7b8effca5e89d5c44229f9a33f6e54 0 1451324338685 5 Connected

f3951a3c666b429a095375799c1ab49e694a291c 127.0.0.1:7005 Slave fd92a2277ad03bf7ad51f5865edb613f498cf409 0 1451324340703 6 Connected

757c2dcebb7b8effca5e89d5c44229f9a33f6e54 127.0.0.1:7001 master-0 1451324340197 2 connected 5795-10922

84c29ba2d6aa9e6179d0faeabc54bb8cd443c4ae 127.0.0.1:7003 Slave 721d0479cbd308eac871b2abe3b5805db80d2fe3 0 1451324339190 8 Connected

fd92a2277ad03bf7ad51f5865edb613f498cf409 127.0.0.1:7002 master-0 1451324338685 3 connected 11256-16383

Cee383ab949eeb33d58aacde89c9cfb8eaa65eab 127.0.0.1:7006 master-0 1451324340197 9 Connected 0-999

721d0479cbd308eac871b2abe3b5805db80d2fe3 127.0.0.1:7000 myself,master-0 0 8 connected 1000-5794 10923-11255

9FC511D059EB7FCCAE41663D495E73275E942AEC 127.0.0.1:7007 master-0 1451324339693 0 connected

#4.4, setting the slave 7,007 to 7006

REDIS-CLI-C-P 7007 cluster replicate CEE383AB949EEB33D58AACDE89C9CFB8EAA65EAB

#4.5. See if the 7007 node becomes a 7006 slave node

REDIS-CLI-P 7000 Cluster Nodes | grep slave | grep 7007

9FC511D059EB7FCCAE41663D495E73275E942AEC 127.0.0.1:7007 Slave Cee383ab949eeb33d58aacde89c9cfb8eaa65eab 0 1451324745834 9 Connected


#5, delete a Slave node (format:./redis-trib.rb del-node Ip:port Node-id, with 7007 nodes as an example)

cd/data/soft/redis/src/

./redis-trib.rb del-node 127.0.0.1:7007 ' 9FC511D059EB7FCCAE41663D495E73275E942AEC '

#6, delete a master node (this is the case with 7006 nodes)

#6.1. Remove the master node first by using Reshard to remove all of the master slots

cd/data/soft/redis/src/

./redis-trib.rb Reshard 127.0.0.1:7006

#6.1.1. Select the number of slots to migrate according to the prompts (PS: Select 1000 here)

How many slots does want to move (from 1 to 16384)? 1000

#6.1.2. Select the Node-id (PS: 7000-node Node-id) to accept these slots

What is the receiving node ID? 721d0479cbd308eac871b2abe3b5805db80d2fe3

#6.1.3, select slot Source:

#all表示从所有的master重新分配,

#或者数据要提取slot的master节点id, End With Done (PS: Select the 7006-node slot you want to delete)

Please enter the source node IDs.

The Type ' All ' is the nodes as source nodes for the hash slots.

Type ' Done ' once your entered all the source nodes IDs.

Source node #1: Cee383ab949eeb33d58aacde89c9cfb8eaa65eab

Source node #2:d One

#6.1.4. After printing the slot that was moved, enter Yes to begin moving the slot and the corresponding data.

Do you want to proceed with the proposed Reshard plan (yes/no)? Yes

#6.2, delete empty 7006 nodes

cd/data/soft/redis/src/

./redis-trib.rb del-node 127.0.0.1:7006 ' Cee383ab949eeb33d58aacde89c9cfb8eaa65eab '


This article is from the "Kundylee" blog, make sure to keep this source http://kundylee.blog.51cto.com/6605245/1729305

Redis Cluster Common commands

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.