Der*_*gan 9 java redis sentinel
好吧,我觉得我错过了一些重要的信息.
本地我有1个主服务器和1个从服务器redis服务器在不同的端口上运行 http://redis.io/topics/sentinel
我也有3个哨兵,他们似乎都相互了解并按预期工作.
现在我有一个很大的java代码指向我的主redis服务器127.0.0.1:6379.
如果我取下主人,哨兵会像预期的那样推动奴隶掌握,所以现在新的主人开启了
127.0.0.1:6380
我的问题是我的代码如何知道这一点和自动切换?
您必须在其pubsub频道之一订阅哨兵消息.你可以在你发布的链接上看到,哨兵会发布消息
+odown <instance details> -- The specified instance is now in Objectively Down state.
-odown <instance details> -- The specified instance is no longer in Objectively Down state.
+failover-takedown <instance details> -- 25% of the configured failover timeout has elapsed, but this sentinel can't see any progress, and is the new leader. It starts to act as the new leader reconfiguring the remaining slaves to replicate with the new master.
+failover-triggered <instance details> -- We are starting a new failover as a the leader sentinel.
Run Code Online (Sandbox Code Playgroud)
因此,当您在其中一个频道上看到哨兵发布时,您需要解析该消息并让您的客户做出相应的响应.Redis并不聪明 - 您必须使用客户端库来处理这些事情.
具体来说,最有用的渠道是
+odown
+failover-detected
+switch-master
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6353 次 |
| 最近记录: |