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

Redis Sentinel-- operation and maintenance management

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

Share

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

In the last blog, we introduced the installation and configuration of Redis Sentinel. For more information, please refer to the link: Redis Sentinel-- installation and configuration. Today we mainly do a few simple tests of Case.

Redis Sentinel API

Ping normally returns pongsentinel masters to return all monitored master and status sentinel master to return specified master and status setntinel slaves to return slave and status sentinel sentinels to return sentinel and status sentinel get-master-addr-by-name mymaster to return current master IP and Portsentinel reset * Clean removed master-slave or sentinel messages sentinel failover to manually perform failover sentinel ckquorum return (OK 3 usable Sentinels. Quorum and failover authorization can be reached) sentinel flushconfig if sentinel.conf is missing, you can use this command to generate a new configuration file

Add Sentinel

It's easy to add a sentinel. Just configure the sentinel.conf file and open a sentinel.

When adding, it is best to add one after adding, and then add another, not at the same time, you can add a sentinel every 30 seconds

Check the num-other-sentinels in SENTINEL MASTER mastername to see if the sentinel was added successfully.

[root@sht-sgmhadoopdn-04 redis] # cat sentinel.confdaemonize yesport 26379logfile "sentinel.log" dir "/ usr/local/redis" protected-mode nosentinel myid 79393e76e002cb64db92fb8bcb88d79f2d85a82bsentinel monitor mymaster 172.16.101.59 6379 2 [root@sht-sgmhadoopdn-04 redis] # src/redis-sentinel sentinel.conf172.16.101.54:26379 > sentinel master mymaster33) "num-other-sentinels" 34) "3"

Remove Sentinel

Deleting a sentinel is a little more complicated. Sentinel will never delete a sentinel that already exists, even if it has lost contact with the organization

Step:

(1) Stop the Sentinel process of the Sentinel you want to remove.

(2) Send a SENTINEL RESET * command to all the other Sentinel instances (instead of * you can use the exact master name if you want to reset just a single master) One after the other, waiting at least 30 seconds between instances.

(3) Check that all the Sentinels agree about the number of Sentinels currently active, by inspecting the output of SENTINEL MASTER mastername of every Sentinel.

[root@sht-sgmhadoopdn-04 redis] # ps-ef | grep redisroot 17510 10 18:34? 00:00:03 src/redis-sentinel *: 26379 [sentinel] [root@sht-sgmhadoopdn-04 redis] # kill-9 17510

On each other sentinel node, each execution is performed at 30s intervals

172.16.101.54 sentinel reset 26379 > sentinel reset * 172.16.101.56 sentinel reset 26379 > sentinel master mymaster33) "num-other-sentinels" 34) "2"

Remove an old master or unavailable slave

[root@sht-sgmhadoopdn-01 redis] # ps-ef | grep redisroot 152611 0 Aug05? 00:05:55 src/redis-server 172.16.101.58:6379root 19768 19394 0 21:09 pts/2 00:00:00 grep-- color=auto redis [root@sht-sgmhadoopdn-01 redis] # kill-9 15261172.16.101.54 kill > sentinel masters 31) "num-slaves" 32) "2"

On each sentinel node, each execution is performed at 30s intervals

172.16.101.54 sentinel masters 26379 > sentinel reset mymaster172.16.101.55:26379 > sentinel reset mymaster172.16.101.56:26379 > sentinel reset mymaster172.16.101.54:26379 > sentinel masters 31) "num-slaves" 32) "1"

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