search

Home  >  Q&A  >  body text

Redis有什么好的自动故障转移方案

具体需求是这样的,

这里的Redis是做存储的,不只是做缓存,例如任务队列,用户动态等

一主多从的Redis实例集群,当主发生故障的时候,如何能:

1、自动选出一个新的主实例
2、不需要应用端修改配置,自动将写请求切换到这个新的主实例上

PHP中文网PHP中文网2861 days ago1099

reply all(6)I'll reply

  • PHPz

    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:

    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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-24 09:11:53

    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

    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

    SENTINEL get-master-addr-by-name master-name

    reply
    0
  • 伊谢尔伦

    伊谢尔伦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...

    reply
    0
  • 黄舟

    黄舟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

    reply
    0
  • 高洛峰

    高洛峰2017-04-24 09:11:53

    If you don’t modify the client, you can use keepalived to achieve it

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:11:53

    redis 3 cluster implements election

    reply
    0
  • Cancelreply