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 deploy redis Sentinel Sentinel

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "how to deploy redis's Sentinel Sentinel". In daily operation, I believe many people have doubts about how to deploy redis's Sentinel Sentinel. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to deploy redis's Sentinel Sentinel". Next, please follow the editor to study!

1. Introduction:

Redis's sentinel system is used to manage multiple redis servers and can implement a cluster that functionally implements HA. The system mainly performs three tasks:

① monitoring (Monitoring): Redis Sentinel monitors the running status of master and slave servers in real time.

② reminder (notification): when there is a problem with a monitored Redis server, Redis Sentinel can send a notification to the system administrator or send a notification to other programs through API

③ automatic failover (Automatic failover): when a master server does not work properly, Redis Sentinel can upgrade one slave server to the master server and configure the other slave servers to use the new master server. When the application connects to the Redis server, Redis Sentinel tells you the new primary server address and port.

The architecture diagram of a simple master-slave structure plus sentinel cluster is as follows:

The picture above shows one master and one slave node, plus two clusters with sentinel deployed. Sentinel clusters will communicate with each other, communicate the status of redis nodes, make corresponding judgments and deal with them. Here, subjective offline state and objective offline state are more important states, which determine whether to fail over.

You can subscribe to the specified channel information and notify the administrator when the server fails

The client can think of Sentinel as a Redis server that only provides subscription. You cannot use the PUBLISH command to send information to this server, but you can use the SUBSCRIBE command or the PSUBSCRIBE command to get the corresponding event reminder by subscribing to a given channel.

A channel can receive events with the same name as that channel. For example, a channel called + sdown can receive events when all instances enter the subjective offline (SDOWN) state.

II. Deployment

Redis's sentinel system can monitor master-slave nodes and realize automatic switching.

Note: when using sentinel to monitor master and slave nodes, slave nodes need to be configured dynamically. If you modify the configuration file directly, there will be problems in the later implementation of sentinel failover.

The nodes are as follows:

Redis master node: 192.168.1.170

Redis slave node: 192.168.1.171 (there can be more than one)

Sentinel node: 192.168.1.172 192.168.1.173

Deployment steps:

1 192.168.1.170, 192.168.1.171, 192.168.1.172, 192.168.1.173, decompress the redis-3.0 package on these four nodes

2: compile and install redis on these four nodes.

3: modify the following attributes in the redis.conf file on 192.168.1.170, 192.168.1.171

Daemonize yes

Logfile "/ usr/local/redis-3.0.0/log"

4: modify the following properties in the sentinel.conf file on 192.168.1.172 and 192.168.1.173

Sentinel monitor mymaster 192.168.1.170 6379 2

5: start redis and sentinel

Start reids on 192.168.1.170 and 192.168.1.171, respectively

Redis-server / / etc/redis.conf

Set the primary node information dynamically on 192.168.1.171

Redis-cli

Slaveof 192.168.1.170 6379

Start sentinel on 192.168.1.172 and 192.168.1.173 respectively

Redis-sentinel / etc/sentinel

So our cluster can be used.

III. Some orders of sentinel

① INFO

Basic status information of sentinel

② SENTINEL masters

Lists all primary servers being monitored and the current status of these primary servers

③ SENTINEL slaves

Lists all slave servers for a given master server and the current status of these slave servers

④ SENTINEL get-master-addr-by-name

Returns the IP address and port number of the primary server with the given name

⑤ SENTINEL reset

Resets all primary servers whose names match the given pattern pattern. The reset operation clears all the current state of the master server, including the failover in progress, and removes all slaves and Sentinel of the master server that have been discovered and associated.

⑥ SENTINEL failover

When the primary server fails, force an automatic failover without asking other Sentinel comments, but it will send the other sentinel an up-to-date configuration, and the other sentinel will update according to this configuration

At this point, the study on "how to deploy redis Sentinel Sentinel" 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

Servers

Wechat

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

12
Report