Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a cluster using redis-trib.rb

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report