Redis cluster deployment and common operation commands

Source: Internet
Author: User
Tags redis cluster
Briefly describe the general steps for self-testing and building a simple Redis cluster: 1. first, you have 6 apsaradb for redis instances (at least 6, 3 master, and 3 slave ).

Briefly describe the general steps for self-testing and building a simple Redis cluster: 1. first, you have 6 apsaradb for redis instances (at least 6, 3 master, and 3 slave ).

Briefly describe the general steps for self-testing and building a simple Redis cluster:

1. first, you have 6 apsaradb for redis instances (at least 6, 3 master, and 3 slave). You can build them on one server first, you only need to change the startup command to build a multi-stage server (You may need ssh without a key or something, just to guess)

You can configure multiple redis instances on the Internet. (There are two methods in general. One is virtual, and the other is redis, one is to copy the configured redis into six copies and configure the corresponding port. The latter I selected seems more real)

Then open them all. You can write a script or open them one by one. As a young man in the new century, I certainly choose to open them one by one ......

[Root @ localhost ~] # Ps-ef | grep redis
Root 3427 1 0 July 17? 00:02:59 src/redis-server *: 6379
Root 3454 1 0 July 17? 00:06:09 src/redis-server *: 7001 [cluster]
Root 3460 1 0 July 17? 00:06:19 src/redis-server *: 7002 [cluster]
Root 3467 1 0 July 17? 00:05:59 src/redis-server *: 7003 [cluster]
Root 3473 1 0 July 17? 00:05:59 src/redis-server *: 7004 [cluster]
Root 3477 1 0 July 17? 00:05:57 src/redis-server *: 7005 [cluster]
Root 5867 1 0 :02? 00:00:06 src/redis-server *: 7000 [cluster]
Root 5938 5913 0 00:00:00 pts/1 grep -- color = auto redis

2. Set six independent redis instances as clusters, so easy to do in one sentence. Among them, the -- replicas parameter is to assign the master-slave relationship to the six redis instances respectively (the slave node can be replaced by the slave node when the master node fails, but there is no further research)

./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

Many problems may occur during the startup process. For various strange errors, you need to install some ruby and gem stuff. If you don't understand what it is, you just need to rely on it ~ It can only be said that this will bypass many pitfalls.

# Yum install ruby-devel.x86_64

# Wget
# Gem install-l./redis-3.2.1.gem

Run the code and then run the cluster creation command above. If the code is successful, you will see the following:

>>> Creating cluster
Connecting to node 127.0.0.1: 7000: OK
Connecting to node 127.0.0.1: 7001: OK
Connecting to node 127.0.0.1: 7002: OK
Connecting to node 127.0.0.1: 7003: OK
Connecting to node 127.0.0.1: 7004: OK
Connecting to node 127.0.0.1: 7005: OK
>>> Specify Ming 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: 7003 to 127.0.0.1: 7000
Adding replica 127.0.0.1: 7004 to 127.0.0.1: 7001
Adding replica 127.0.0.1: 7005 to 127.0.0.1: 7002
M: ad52e4f7c14da4b8b1e8e48603c9e5515a4cec7a 127.0.0.1: 7000
Slots: 0-5460 (5461 slots) master
M: d3058a19483d7be5c30c042779e56130f6ebf074 FIG: 7001
Slots: 5461-10922 (5462 slots) master
M: 5814305e71552ab45c44b9b823da-1a63c3a57b1 127.0.0.1: 7002
Slots: 10923-16383 (5461 slots) master
S: e50676757acbe7c6a21e8abf4eda26ababb08285 127.0.0.1: 7003
Replicates ad52e4f7c14da4b8b1e8e48603c9e5515a4cec7a
S: ab307ba26d6dabe8edb2f2a7287be6f01aa46d88 127.0.0.1: 7004
Replicates d3058a19483d7be5c30c042779e56130f6ebf074
S: 11174332eb6ad40c0327750536fa776d706caf85 FIG: 7005
Replicates 5814305e71552ab45c44b9b8232131a63c3a57b1
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...
>>> Specify Ming Cluster Check (using node 127.0.0.1: 7000)
M: ad52e4f7c14da4b8b1e8e48603c9e5515a4cec7a 127.0.0.1: 7000
Slots: 0-5460 (5461 slots) master
M: d3058a19483d7be5c30c042779e56130f6ebf074 FIG: 7001
Slots: 5461-10922 (5462 slots) master
M: 5814305e71552ab45c44b9b823da-1a63c3a57b1 127.0.0.1: 7002
Slots: 10923-16383 (5461 slots) master
M: e50676757acbe7c6a21e8abf4eda26ababb08285 127.0.0.1: 7003
Slots: (0 slots) master
Replicates ad52e4f7c14da4b8b1e8e48603c9e5515a4cec7a
M: ab307ba26d6dabe8edb2f2a7287be6f01aa46d88 127.0.0.1: 7004
Slots: (0 slots) master
Replicates d3058a19483d7be5c30c042779e56130f6ebf074
M: 11174332eb6ad40c0327750536fa776d706caf85 FIG: 7005
Slots: (0 slots) master
Replicates 5814305e71552ab45c44b9b8232131a63c3a57b1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

3. Test the cluster.

You can use the following command to view the cluster status. The following shows that there are four masters and two slave ~~~, This is because I was too young to kill redis 7000 and joined it again. His slave 7003 was replaced by the master.

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.