The following column Redis Tutorial will introduce to you about the implementation of ranking list in java based on redis ordered collection. I hope it will be helpful to friends in need!
Sentinel is an independent process.
Principle: The sentinel monitors multiple running Redis instances by sending commands and waiting for the Redis server to respond.
However, problems may arise when a sentinel process monitors the Redis server. For this reason, we can use multiple sentinels for monitoring. Each sentinel will also be monitored, thus forming a multi-sentinel mode.
Assuming that the main server is down and Sentinel 1 detects this result first, the system will not immediately perform the failover process, only Sentinel 1 Subjectively believing that the main server is unavailable, this phenomenon becomes Subjective offline. When the subsequent sentinels also detect that the main server is unavailable and the number reaches a certain value, a vote will be held between the sentinels. The result of the vote will be initiated by one sentinel to perform a failover operation. After the switch is successful, each sentry will use the publish and subscribe mode to switch the slave server it monitors to the host. This process is called Objective offline. This way everything is transparent to the client.
Configure 3 sentinels and a Redis server with 1 master and 2 slaves to demonstrate this process.
Service type | Is it the main server | IP address | Port |
---|---|---|---|
Redis | is | 192.168.11.128 | 6379 |
Redis | No | 192.168.11.129 | 6379 |
Redis | No | 192.168.11.130 | 6379 |
Sentinel | - | 192.168.11.128 | 26379 |
Sentinel | - | 192.168.11.129 | 26379 |
Sentinel | - | 192.168.11.130 | 26379 |
# 使得Redis服务器可以跨网络访问 bind 0.0.0.0# 设置密码 requirepass "123456"# 指定主服务器,注意:有关slaveof的配置只是配置从服务器,主服务器不需要配置 slaveof 192.168.11.128 6379# 主服务器密码,注意:有关slaveof的配置只是配置从服务器,主服务器不需要配置 masterauth 123456
There is a sentinel.conf file in the Redis installation directory (copy 3 copies)
# 禁止保护模式protected-mode no# 配置监听的主服务器,这里sentinel monitor代表监控,mymaster代表服务器的名称,可以自定义,192.168.11.128代表监控的主服务器,6379代表端口,2代表只有两个或两个以上的哨兵认为主服务器不可用的时候,才会进行failover操作。sentinel monitor mymaster 192.168.11.128 6379 2# sentinel author-pass定义服务的密码,mymaster是服务名称,123456是Redis服务器密码# sentinel auth-pass <master-name> <password>sentinel auth-pass mymaster 123456</password></master-name>
With the above modifications, we can enter the src directory of the Redis installation directory and start the server and sentinel through the following commands
# 启动Redis服务器进程./redis-server ../redis.conf # 启动哨兵进程./redis-sentinel ../sentinel.conf
First is the Redis service process of the host (192.168.11.128), then start the service process of the slave, and finally start the three sentinel service processes.
The above is the detailed content of Detailed explanation of Redis sentry mode. For more information, please follow other related articles on the PHP Chinese website!