Using redis 2.8 sentinel can achieve your requirements.
Its main purpose is to monitor your master and slave. If the master fails due to some kind of failure,
The cluster's sentinel will select a new master in the slave for you through configuration and algorithm ,
And notify other slaves and sentinels that the relevant configurations in sentinel.conf will be modified automatically, and the redis.conf file does not need to be modified manually.
The original master became a slave. You don’t need to configure whether sentinel is in cluster status. You only need to configure the same monitor in sentinel.conf, as follows:
sentinel monitor mymaster 127.0.0.1 6379 2
Among them, ip and port are the same. Sentinel can unify itself and other sentinels into a cluster through gossip protocols.
Similar to how you don't need to tell the sentinel master which slaves it has.
If you have any questions above, please feel free to discuss them again.
Can automatically remove the master Redis, select a new master from the slave Redis, and modify other slave Redis slaves of the new master
Disadvantages
No Proxy forwarding function, the application needs to modify the configuration and link to the new master
Redis Sentinel can send a notification when it discovers a main fault. In this case, the client needs to be able to monitor the notification through Redis Sentinel
The provided API obtains the new main Redis address
Using redis 2.8 sentinel can achieve your requirements.
Its main purpose is to monitor your master and slave. If the master fails due to some kind of failure,
sentinel monitor mymaster 127.0.0.1 6379 2The cluster's sentinel will select a new master in the slave for you through configuration and algorithm ,
And notify other slaves and sentinels that the relevant configurations in sentinel.conf will be modified automatically, and the redis.conf file does not need to be modified manually.
The original master became a slave.
You don’t need to configure whether sentinel is in cluster status. You only need to configure the same monitor in sentinel.conf, as follows:
Among them, ip and port are the same. Sentinel can unify itself and other sentinels into a cluster through gossip protocols.
Similar to how you don't need to tell the sentinel master which slaves it has.
If you have any questions above, please feel free to discuss them again.
Just to add:
Redis Sentinel Solution
Advantages
Can automatically remove the master Redis, select a new master from the slave Redis, and modify other slave Redis slaves of the new master
Disadvantages
No Proxy forwarding function, the application needs to modify the configuration and link to the new master
twemproxy is Twitter’s open source Redis Proxy. Twitter used it to scale Redis to 105TB of memory, 39MM QPS and over 10,000 Redis instances.
http://highscalability.com/blog/2014/9/8/how-twitter-uses-redis-to-sca...
I recommend this interactive e-book to you, you can try it while reading: http://book.hubwiz.com/55518c22032c78127cce2481
If you don’t modify the client, you can use keepalived to achieve it
redis 3 cluster implements election