Redis Sentinel Failover

What is Redis Sentinel?

Sentinel is the high availability solution offered by Redis, in case of failure in your Redis cluster, Sentinel will automatically detect the point of failure and bring the cluster back to stable mode without human intervention.

Sometimes when updating the cluster we need to failover the master, this is how:

How to failover on Redis Sentinel

Check server state, to see the number of replicas on the master:

sudo systemctl status redis

Example outout:

Jan 12 17:01:31 cca-redis-1-a.qa-aws-va-1.example.net cca-redis-1-a.qa-aws-va-1.example.net[494]: 58 clients connected (2 replicas), 3398512 bytes in use

Login to Redis Sentinel:

redis-cli -p 26379

Authenticate using your password:

auth <PASSWORD>

Show all the clusters this sentinel knows about:

SENTINEL MASTERS

Show the current master for <cluster>:

SENTINEL MASTER <cluster>

Show how many replicas this sentinel knows about:

SENTINEL REPLICAS <cluster>

Show the other sentinels:

SENTINEL SENTINELS <cluster>

Failover the redis master to another node

SENTINEL FAILOVER <cluster>

When viewing the master node you should now see  a different IP:

SENTINEL MASTER <cluster>

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.