sql >> Base de Datos >  >> NoSQL >> Redis

Cómo decirle a un cliente dónde está el nuevo maestro de Redis usando Sentinel

Tienes que suscribirte a los mensajes centinela en uno de sus canales pubsub. Puede ver en el enlace que publicó que el centinela publicará mensajes como

+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.

Entonces, cuando vea una publicación centinela en uno de esos canales, debe analizar el mensaje y hacer que su cliente responda en consecuencia. Redis no es inteligente:debe manejar estas cosas usando una biblioteca de cliente.

En concreto, los canales más útiles son

+odown
+failover-detected
+switch-master