Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build a cluster using redis-trib.rb

Shulou Source: shulou.com Published: 2022-06-02 06:55:22 10月02日 Update

This article introduces the knowledge of "how to use redis-trib.rb to build a cluster". In the operation of practical 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!

1.Ruby environment building

Install Ruby

. / configure-prefix=/usr/local/ruby

Make

Make install

Cd / usr/local/ruby

Sudo cp bin/ruby / usr/local/bin

Sudo cp bin/gem / usr/local/bin

Install rubygem redis dependencies

Gem install-l rubygems-update-2.7.7.gem

Install redis-trib.rb

Sudo cp redis-4.0.9/src/redis-trib.rb / usr/local/bin

We can execute the redis-trib.rb command to see if the environment is installed successfully.

two。 Prepare the node

It is still the same as the startup node in the previous article:

. / src/redis-server redis-6379.conf

. / src/redis-server redis-6380.conf

. / src/redis-server redis-6381.conf

. / src/redis-server redis-6382.conf

. / src/redis-server redis-6383.conf

. / src/redis-server redis-6384.conf

3. Create a cluster

Instead of manually configuring the cluster as in the previous article, we will use the redis-trib.rb create command directly this time. This command can automatically complete the node handshake and slot allocation process.

Redis-trib.rb create-- replicas 1 127.0.0.1 6379 127.0.0.1 Fraser 6380 127.0.1 Discovery 6381 127.0.0.1 Flux 6382 127.0.1 1V 6383 127.0.1

The-- replicas parameter above refers to how many slaves are configured for each master node in the cluster. Since we have started a total of six nodes, our replicas parameter is set to 1.

As we can see in the figure above, when we execute the above command, the command line displays the confirmation command, because it is only when we type yes that redis-trib.rb begins to perform node handshake and slot allocation operations.

As shown in the figure above, all 16384 slots have been allocated and the cluster has been created successfully.

4. Cluster integrity check

The cluster integrity check means that you must ensure that all slots are allocated to the master node, that is, as in the previous article, while the slave node copies the slots of the master node. As long as 16384 of the slots are not allocated to the primary node, the cluster is incomplete. We can use the redis-trib.rb check command to check whether the created cluster is successful, and a convenience of the check command is that it can check the entire cluster as long as it gives the address of any node in the cluster.

This is the end of "how to use redis-trib.rb to build a 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!

Tags: Clusters nodes commands allocation success previous check content parameters integrity more environment knowledge process configuration practical successful learning and then no that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple Xiaomi MySQL Linux