Redis Cluster Deployment Configuration

Source: Internet
Author: User
Tags redis version redis cluster install redis

Redis Cluster Deployment Configuration


Test environment: The server system is Centos6.5,redis version 3.2.2, using a machine, simulates 6 Redis instances to create a Redis cluster, where 3 master 3 from


    1. Set up the Redis installation directory separately and copy the redis.conf to the installation directory.

      650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/83/CB/wKioL1d8pBOiq69_AAAnOH8gA7s281.png-wh_500x0-wm_3 -wmp_4-s_4123021491.png "title=" image 1.png "alt=" Wkiol1d8pboiq69_aaanoh8ga7s281.png-wh_50 "/>


2. Modify the redis.conf configuration file in each directory


Port 7000 #端口

Daemonize Yes

cluster-enabled Yes #开启集群模式

Cluster-config-file nodes-7000.conf #集群配置文件

Cluster-node-timeout #超时时间

AppendOnly Yes

dir/rs-base/servers/redis-2.x/cluster/7000

3. Launch instances separately

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/83/CC/wKiom1d8pF-zYIaGAAAXqNXyrFw809.png-wh_500x0-wm_3 -wmp_4-s_1900598344.png "style=" Float:none; "title=" Picture 2.png "alt=" Wkiom1d8pf-zyiagaaaxqnxyrfw809.png-wh_50 "/>

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/83/CC/wKiom1d8pGLRGf-BAAAbMD7qzY4505.png-wh_500x0-wm_3 -wmp_4-s_1399138936.png "style=" Float:none; "title=" Picture 3.png "alt=" Wkiom1d8pglrgf-baaabmd7qzy4505.png-wh_50 "/>

See if all has started successfully


4. Now that we have six running Redis instances, we need to use these instances to create the cluster and write a configuration file for each node.

By using the Redis Cluster command-line tool Redis-trib, writing the node configuration file can be done very easily redis-trib is located in the Redis Source src folder, which is a Ruby program that creates a new cluster by sending special commands to the instance. Check the cluster, or re-shard (reshared) the cluster.

Execute the following command to create the cluster:

/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

(Note: This command--replicas the number of slave allocated per master node in the SRC directory after Redis decompression)

Prompt after execution:/usr/bin/env:ruby:no such file or directory

Ruby is not installed in the system, so the above error is reported.

Install Ruby First:

[[email protected] yum.repos.d]# Yum install Ruby

[email protected] yum.repos.d]# Yum install RubyGems

[[Email protected] yum.repos.d]# gem install Redis

Create the cluster again:

[Email protected] src]#/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

Redis automatically selects Master-slave

5. Test the cluster

In any one of the nodes using Redis-cli-c-P 7000, set AAA BBB

Again to other nodes using get AAA can get value,

Simulates one of the primary node failures, kills a redis process, and then uses get and set for other nodes without exception, and its slave node becomes the master node.

6. Check the cluster: Through a check cluster node, you know the whole cluster status, you can see who is the Lord, who is from.

./REDIS-TRIB.RB Check 127.0.0.1:7000

Add node: redis-trib.rb Add-node want to increase the ip:port in the cluster that already exists Ip:port

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

If you report this mistake,

Need to delete the file where you redis.conf inside Cluster-config-file

If you intend to make the new node the slave node of the 127.0.0.1:7005, simply connect the new node with the client, and then execute the following command:

Redis 127.0.0.1:7006> Cluster Replicate 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e

(ID for ID 7005)

Use the following command to see if the slave node is not 7005 (ID of the primary node)

REDIS-CLI-P 7000 Cluster Nodes | grep slave | grep 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e





This article is from the "technology Change the World" blog, reproduced please contact the author!

Redis Cluster Deployment Configuration

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.