Redis sentinel cluster configuration-master-slave switchover, redissentinel
1. Configure redis master and redis slave (see the http://www.cnblogs.com/wangchaozhi/p/5140469.html above for specific configuration operations ).
Redis master ip: 127.0.0.1: port 6379 (default configuration file)
Redis slave1 ip: 127.0.0.1: port 6380 (modify the port number to 6380 and configure it as the master slave, # slaveof <masterip> <masterport>, remove # and change it to slaveof 127.0.0.1 6379)
Redis slave1 ip: 127.0.0.1: port 6381 (modify the port number to 6381 and configure it as the master slave, # slaveof <masterip> <masterport>, remove # and change it to slaveof 127.0.0.1 6379)
2. Configure sentinel (you can also configure it as a cluster. Here, configure a demo ).
Sentinel monitor mymaster 127.0.0.1 6379 1
Sentinel down-after-milliseconds MySQL master 5000
Sentinel failover-timeout MySQL master 180000
Sentinel parallel-syncs mymaster 1
3. Run master, slave1, slave2, and sentinel.
Command for starting redisservice redis-server.exe redis. windows. conf
Start sentinelcommand redis-server.exe sentinel. conf -- sentinel
4. Simulate host downtime
Enter the following command
Redis-cli-h 127.0.0.1-p 6379 shutdown
Observe the sentinel service.
We can know that the slave of port 6381 is upgraded to the master. Test whether data can be written
Restart the master's service port 6379.
Observe master and sentinel service prompts
The red line indicates that the original master (6379) becomes the slave of 6381.
At this point, the master-slave automatic switch configuration test is complete.