The method of Building redis High availability Cluster based on redis-cluster
This article introduces the knowledge of "the method of building redis high availability cluster based on redis-cluster". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
This time, we build a cluster of 3 master and 3 slave with 6 redis instances.
The first step is to create a folder called cluster under the / usr/local/redis/ directory
Cd / usr/local/redismkdir cluster
Then create 6 folders with the name 7001-7006 under cluster
Mkdir 7001
The second step is to create a redis.conf file in each of the six folders
Vi redis.conf## port port 7001 # # enable cluster mode cluster-enabled yes## generation cluster configuration file cluster-config-file nodes.conf## instance communication timeout cluster-node-timeout 5000 times # enable AOF persistence, an appendonly.aof persistence file will be created appendonly yes##redis background launches daemonize yes#bind 0.0.0.0 contacts # turn off protected mode, allowing external access to protected-mode no
The ports of each redis.conf are 7001-7006.
The third step is to copy the redis-server and redis-cli scripts to the 7001-7006 file plus the following
Step 4: go to 6 folders and start the redis instance
. / redis-server. / redis.conf
Step 5, install the ruby and redis libraries (if your redis version is redis 3.x, otherwise ignore this step)
Yum install ruby-y
Step 6, create a cluster using these 6 redis instances (just execute it on one machine)
. / redis-cli-- cluster create ip1:7001 ip2:7002 ip3:7003 ip4:7004 ip5:7005 ip6:7006-- cluster-replicas 1
-- cluster-replicas 1 this configuration is a master to create a slave node. If you need to create 3 slave nodes, you only need to change it to-- cluster-replicas 3.
Note: if it is an older version of redis, such as redis 3.x, the script to create the cluster is as follows
. / redis-trib.rb create-- replicas 1 ip1:7001 ip2:7002 ip3:7003 ip4:7004 ip5:7005 ip6:7006
So far, the implementation of redis high availability cluster based on redis-cluster has been completed.
This is the end of the content of "how to build a high-availability cluster of redis based on redis-cluster". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!