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

At least how many redis nodes are required for a Redis cluster cluster

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how many redis nodes does a Redis cluster cluster need at least". In daily operation, I believe many people have doubts about at least how many redis nodes a Redis cluster cluster needs. The editor consulted all kinds of materials and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the question of "at least how many redis nodes does a Redis cluster cluster need?" Next, please follow the editor to study!

# # at least 6 redis nodes are required to configure redis cluster

The cluster can only be built with at least 3 masters and 3 slaves to prevent confusion. We set up a folder under redis, cluster, in which 6 configuration files are copied and renamed to redis1-redis6.conf.

Modify each configuration file on the following common ground:

Bind 10.233.19.36 (configured according to actual situation)

Port 7001 (7001-7006)

Daemonize yes (runs as a daemon)

Pidfile / var/run/redis.pid (files generated by the daemon, configured in reality)

Appendonly yes (enables persistence of AOF logging Redis operations)

Appendfilename "appendonly-7001.aof" (AOF file name, configured port as file name for easy viewing)

Cluster-enabled yes (start cluster)

Cluster-config-file nodes-7001.conf (node information, which has been named for easy viewing)

Cluster-node-timeout 15000 (Node response timeout)

The above are common points. Each node needs to be configured regardless of master-slave.

It should also be noted that the master-slave relationship is no longer actively configured for each node, otherwise an error will be reported at startup.

Because the master-slave relationship has to be adjusted by the redis cluster itself.

# # starting redis Cluster

After the above configuration is complete, start 6 redis instances respectively. If the configuration is correct, it can be started successfully. Then run the following command to create the cluster:

Note that ip:port is used here

Replicas 1 means that we want to create a slave node for each master node in the cluster

Because the password is set in the configuration file, the password parameter-an is also needed to create the cluster.

[ERR] Node 10.233.19.36:6380 NOAUTH Authentication required.

[redis@weblogic-test bin] $. / redis-cli-- cluster create 10.233.19.36 cluster create 6380 10.233.19.36 beijing 6381 10.233.19.36 cluster-replicas 1-a beijing

Warning: Using a password with'- a'or'- u 'option on the command line interface may not be safe.

> Performing hash slots allocation on 6 nodes...

Master [0]-> Slots 0-5460

Master [1]-> Slots 5461-10922

Master [2]-> Slots 10923-16383

Adding replica 10.233.19.36:6383 to 10.233.19.36:6380

Adding replica 10.233.19.36:6384 to 10.233.19.36:6381

Adding replica 10.233.19.36:6385 to 10.233.19.36:6382

> Trying to optimize slaves allocation for anti-affinity

[WARNING] Some slaves are in the same host as their master

M: 369151e4f1bed1e3fcaf474025853bc72056542e 10.233.19.36:6380

Slots: [0-5460] (5461 slots) master

M: 1f9314f13a22c2c68c609e98247bfe6d0714c75b 10.233.19.36:6381

Slots: [5461-10922] (5462 slots) master

M: 41840a493fceef875b1a521d951090f9c99c7040 10.233.19.36:6382

Slots: [10923-16383] (5461 slots) master

S: 438c5ecaf7501da25bfc0d2055445c036907ba61 10.233.19.36:6383

Replicates 1f9314f13a22c2c68c609e98247bfe6d0714c75b

S: 9598769e90155aeb130a33980ac1a1c27b1609cc 10.233.19.36:6384

Replicates 41840a493fceef875b1a521d951090f9c99c7040

S: b0d325e936ee5055648561302560d055d0bdb365 10.233.19.36:6385

Replicates 369151e4f1bed1e3fcaf474025853bc72056542e

Can I set the above configuration? (type 'yes' to accept): yes

> Nodes configuration updated

> Assign a different config epoch to each node

> Sending CLUSTER MEET messages to join the cluster

Waiting for the cluster to join

..

> Performing Cluster Check (using node 10.233.19.36)

M: 369151e4f1bed1e3fcaf474025853bc72056542e 10.233.19.36:6380

Slots: [0-5460] (5461 slots) master

1 additional replica (s)

M: 1f9314f13a22c2c68c609e98247bfe6d0714c75b 10.233.19.36:6381

Slots: [5461-10922] (5462 slots) master

1 additional replica (s)

S: 9598769e90155aeb130a33980ac1a1c27b1609cc 10.233.19.36:6384

Slots: (0 slots) slave

Replicates 41840a493fceef875b1a521d951090f9c99c7040

M: 41840a493fceef875b1a521d951090f9c99c7040 10.233.19.36:6382

Slots: [10923-16383] (5461 slots) master

1 additional replica (s)

S: b0d325e936ee5055648561302560d055d0bdb365 10.233.19.36:6385

Slots: (0 slots) slave

Replicates 369151e4f1bed1e3fcaf474025853bc72056542e

S: 438c5ecaf7501da25bfc0d2055445c036907ba61 10.233.19.36:6383

Slots: (0 slots) slave

Replicates 1f9314f13a22c2c68c609e98247bfe6d0714c75b

[OK] All nodes agree about slots configuration.

> Check for open slots...

> Check slots coverage...

[OK] All 16384 slots covered.

After the execution is successful, connect a redis, and execute cluster info to see a message similar to the following:

127.0.0.1 6380 > cluster info

Cluster_state:ok

Cluster_slots_assigned:16384

Cluster_slots_ok:16384

Cluster_slots_pfail:0

Cluster_slots_fail:0

Cluster_known_nodes:6

Cluster_size:3

Cluster_current_epoch:6

Cluster_my_epoch:1

Cluster_stats_messages_ping_sent:190

Cluster_stats_messages_pong_sent:181

Cluster_stats_messages_sent:371

Cluster_stats_messages_ping_received:176

Cluster_stats_messages_pong_received:190

Cluster_stats_messages_meet_received:5

Cluster_stats_messages_received:371

We can see cluster_state:ok,cluster_slots_ok:16384,cluster_size:3.

At this point, the study on "at least how many redis nodes a Redis cluster cluster needs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Database

Wechat

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

12
Report