从Python调用Sentinel故障转移

时间:2015-09-16 21:09:27

标签: python-2.7 redis redis-sentinel

我有一个简单的Redis配置,运行3个服务器和3个Sentinels(不同的实例)。这个配置运行得几乎完美,最终,我的Master失败了(常见的Redis问题,它无法完成后台保存)。

我的问题是,每当我尝试保存(或删除)某些内容时,我都会收到错误:

ResponseError: MISCONF Redis is configured to save RDB snapshots, but
is currently not able to persist on disk. Commands that may modify the
data set are disabled. Please check Redis logs for details about the error.

我有没有办法让Sentinel呼叫“故障转移”部队选举新的主人?通过redis-cli非常容易,但我无法通过Python(2.7)程序(使用redis.py)找到一种方法。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

首先,您可能没有磁盘空间,这会导致该错误。因此,解决这个问题,它将不再需要进行故障转移。

那就是说,要用Python做,我认为你需要使用" execute_command"并传递sentinel命令和args。如下所示:

myclient.execute_command("SENTINEL failover", podname)

其中myclient是您的连接对象,poundage是您在Sentinel中用于pod的名称,应该这样做。

相关问题