Sentinel sentry

Redis does not automatically restore a master node after a master node fails. Manual intervention is required to switch a slave to a master. The service is temporarily unavailable, a bunch of configurations can go wrong manually, and availability is low. Sentinel's high availability solution monitors master and slave servers, and automatically switches from master to master based on feedback from the slave nodes when the master library is down, so you don't have to worry about dealing with problems online at night.Copy the code

The following environment setup is carried out in WSL of Win

The test configuration is as follows

Modify the redis.conf configuration file

The master node

Don't need to configureCopy the code

From the node

Masterauth 123654 masterauth 123654 slaveof 127.0.0.1 6379Copy the code

Sentinel Sentinel (note separate installation required)

The installation

Sudo apt install redis-sentinelCopy the code

configuration

Sentinel Monitor MyMaster 127.0.0.1 6379 1 # Start daemonize yes [milliseconds] sentinel down-after-milliseconds mymaster 10000 >1 Parallel sentinel parallel syncs myMaster 1 # Failover started, not completed within 3 minutes, Sentinel fail-timeout myMaster 180000 Sentinel auth-pass myMaster 123654Copy the code

The effect

Another Redis Desktop Manager is a Redis visualization tool

Normal nodes

Both master and slave nodes are visible by executing commands on sentry's serverCopy the code

Kill the master node

Info Replication 6381 has become the primary nodeCopy the code

Configuration files have also changed