Redis的/ Jedis无单点故障和自动故障转移 [英] Redis/Jedis no single point of failure and automated failover

查看:515
本文介绍了Redis的/ Jedis无单点故障和自动故障转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在3服务器1主2奴隶没有分片的简单情况。是否有成熟的解决方案与Java和Jedis,有没有单点故障,并会自动处理一台服务器下降是因为主机或从机(自动故障切换)。例如推广硕士,之后CH375复位没有任何故障而丢失数据。

In a simple situation with 3 servers with 1 master and 2 slaves with no sharding. Is there a proven solution with java and Jedis that has no single point of failure and will automatically deal with a single server going down be that master or slave(automated failover). e.g. promoting masters and reseting after the failure without any lost data.

在我看来,像它应该是一个解决问题,但我找不到任何code就可以了方法可以做到这只是高层次的描述。

It seems to me like it should be a solved problem but I can't find any code on it just high level descriptions of possible ways to do it.

谁实际上这已经覆盖并在生产工作?

Who actually has this covered and working in production?

推荐答案

您可能想给一个尝试 Redis的哨兵以做到这一点:

You may want to give a try to Redis Sentinel to achieve that:

Redis的哨兵是一个旨在帮助管理Redis的实例系统。   它执行以下三个任务:

Redis Sentinel is a system designed to help managing Redis instances. It performs the following three tasks:

      
  • 监测。哨兵经常检查,如果你的主机和从机实例按预期工作。

  • Monitoring. Sentinel constantly check if your master and slave instances are working as expected.

的通知。哨兵可以通知系统管理员或其他计算机程序,通过API,什么是错的一个   被监视Redis的实例。

Notification. Sentinel can notify the system administrator, or another computer program, via an API, that something is wrong with one of the monitored Redis instances.

自动故障转移。如果主没有按预期工作,哨兵可以启动故障转移过程,其中一个奴隶被晋升为大师,   其他附加的奴隶被重新配置为使用新的主人,   使用Redis的服务器应用程序告知新地址   连接时使用。

Automatic failover. If a master is not working as expected, Sentinel can start a failover process where a slave is promoted to master, the other additional slaves are reconfigured to use the new master, and the applications using the Redis server informed about the new address to use when connecting.

...或者使用一个外部解决方案,如动物园管理员和的 Jedis_failover

... or to use an external solution like Zookeeper and Jedis_failover:

JedisPool pool = new JedisPoolBuilder()
    .withFailoverConfiguration(
        "localhost:2838", // ZooKeeper cluster URL
        Arrays.asList( // List of redis servers
            new HostConfiguration("localhost", 7000), 
            new HostConfiguration("localhost", 7001))) 
    .build();

pool.withJedis(new JedisFunction() {
    @Override
    public void execute(final JedisActions jedis) throws Exception {
        jedis.ping();
    }
});

见的动物园管理员+ R​​edis的这 presentation。

See this presentation of Zookeeper + Redis.

[更新] ...或Jedis +哨兵一个纯Java的解决方案是使用处理Redis的哨兵事件的包装,看到<一href="https://github.com/hamsterready/jedis-sentinel-pool/blob/master/src/main/java/pl/quaternion/SentinelBasedJedisPoolWrapper.java">SentinelBasedJedisPoolWrapper.

[Update] ... or a pure Java solution with Jedis + Sentinel is to use a wrapper that handles Redis Sentinel events, see SentinelBasedJedisPoolWrapper.

这篇关于Redis的/ Jedis无单点故障和自动故障转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆