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 set the redis cluster password

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

In this issue, the editor will bring you about how to set the redis cluster password. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Note:

1. If you are building a cluster using the redis-trib.rb tool, do not configure the password before the cluster is built. After the cluster is built, set the password machine by machine through the config set + config rewrite command

two。 If you set a password for the cluster, then both requirepass and masterauth need to be set. Otherwise, when master-slave switching occurs, you will encounter authorization problems. You can simulate and observe the log.

3. The passwords of each node must be the same, otherwise Redirected will fail

Config set masterauth abc config set requirepass abc config rewrite

Test version:

Redis3.0.7

Test environment:

Centos7

Cluster size:

3 Master 3 Slave

Redis configuration before the cluster is successfully built:

Port 8000 cluster-enabled yes cluster-config-file "nodes-8000.conf" cluster-node-timeout 15000 dir "/ opt/redisdata" appendonly yes appendfilename "appendonly-8000.aof" logfile "opt/redisdata/8000.log" daemonize yes pidfile "/ var/run/redis-8000.pid" dbfilename "dump-8000.rdb" cluster-require-full-coverage no

Redis configuration after successful cluster construction:

Port 8004 cluster-enabled yes cluster-config-file "nodes-8004.conf" cluster-node-timeout 15000 dir "/ opt/redisdata" appendonly yes appendfilename "appendonly-8004.aof" logfile "opt/redisdata/8004.log" daemonize yes pidfile "/ var/run/redis-8004.pid" dbfilename "dump-8004.rdb" cluster-require-full-coverage no # Generated by CONFIG REWRITE requirepass "abc" masterauth "abc"

Test:

1.8002 is the master and 8005 is the slave of 8002. Now you need to kill 8002 to simulate the master-slave switch.

two。 Looking at the log of 8005, 8005 was finally elected as the new master

21227S14 Jun 07VOV28 Jun 49.343 # Connection with master lost.21227:S 14 Jun 07VOV 28VOL49.343 * Caching the disconnected master state.21227:S 14 Jun 07VOV 28VOL49.433 * Connecting to MASTER 127.0.1VOL800221227VOL14 Jun 07VOV 28 VOL49.433 * MASTER SLAVE sync started21227:S 14 Jun 07VOV 2849.434 # Error condition on socket for SYNC: Connection refused21227:S 14 Jun 07 VLAR 2850.437 * Connecting to MASTER 127.0.0 1Jun 221227 milliseconds 14 milliseconds 06.205 # Start of election delayed for 564 (rank # 0) Offset 337) .21227 Jun S 14 Jun 07 Paradigm 29V 06.507 * Connecting to MASTER 127.0.0.1V 800221227 V 14 Jun 07V 29V 06.507 * MASTER SLAVE sync started21227:S 14 Jun 07 V 29V 06.507 # Error condition on socket for SYNC: Connection refused21227:S 14 Jun 07 V 29V 06.808 # Starting a failover election for epoch 10.21227S 14 Jun 07V V 29 06.810 # Failover election won: I'm the new master.21227:S 14 Jun 07:29:06 .810 # configEpoch set to 10 after successful failover21227:M 14 Jun 07VOV 29VO 6.810 * Discarding previously cached master state.

3. Start 8002 again and check the log of 8005. 8002 has become 8005 slave.

21227 Jun M 14 Jun 07 32 Jun 53.511 * Slave 127.0.0.1 asks for synchronization21227:M 14 Jun 07 32 asks for synchronization21227:M 53.511 * Full resync requested by slave 127.0.1 14 Jun 07 32 DB saved on disk21613:C 53.511 * Starting BGSAVE for SYNC with target: disk21227:M 14 Jun 07 32 32 * Background saving started by pid 2161321613 C 14 Jun 07 32 32 * DB saved on disk21613:C 14 Jun 07 32 32 * RDB: 0 MB of memory used by copy-on-write21227:M 14 Jun 07 Jun 32 Jun 53.612 * Synchronization with slave 127.0.1 succeeded above is how to set the redis cluster password shared by Xiaobian If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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