具体需求是这样的,
这里的Redis是做存储的,不只是做缓存,例如任务队列,用户动态等
一主多从的Redis实例集群,当主发生故障的时候,如何能:
1、自动选出一个新的主实例
2、不需要应用端修改配置,自动将写请求切换到这个新的主实例上
PHPz2017-04-24 09:11:53
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:
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.
伊谢尔伦2017-04-24 09:11:53
Just to add:
Can automatically remove the master Redis, select a new master from the slave Redis, and modify other slave Redis slaves of the new master
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 addressSENTINEL get-master-addr-by-name master-name
伊谢尔伦2017-04-24 09:11:53
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...
黄舟2017-04-24 09:11:53
I recommend this interactive e-book to you, you can try it while reading: http://book.hubwiz.com/55518c22032c78127cce2481