Build a redis cluster with redis-trib.rb

First make sure ruby ​​and ruby's redis client are installed

Enter the src directory of the redis installation directory, you can find the redis-trib.rb file, execute it, you can see:

This means that we can use the ruby ​​script officially provided by redis to install our cluster cluster.

Then prepare 6 nodes 8000-8005 ports, configure the cluster (there is a demo in the previous native chapter) and start it (the demo is in the form of single-machine multi-deployment)

Then use the create command of redis-trib.rb to create a cluster

Here, --replicas specifies the master-slave configuration, the latter 1 means that each node has several slave nodes (one is set here) and then followed by the ip and ports of 6 nodes. Since each node has 1 slave, it is 6/2. The first three nodes will automatically become masters, and the last three correspond to slaves. Then execute the command, you can see that one of its execution plans is as follows:

Enter yes:

In this way, we have completed the construction of the cluster, including node handshake, allocation of slots, and allocation of master-slave.

Connect to 8000 nodes and enter cluster info to verify, everything is ok!

So far, the use of redis-trib.rb to build a cluster demonstration is complete!

By the way, why not install with native commands? Because the native steps are very cumbersome, not standardized, and prone to errors, we choose to use the official ruby ​​tool. However, if there are too many cluster nodes, this is not a good way to manage the cluster. It is better to develop a cloud platform for visual deployment.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324418835&siteId=291194637