How to do it...

To test the Redis Sentinel set up in the previous recipe, take the following steps:

  1. Triggering a master failover manually:
    1. Connect to one of the Sentinels using redis-cli; here we are connecting to Sentinel-2 (192.168.0.32):
192.168.0.32:26379> SENTINEL FAILOVER MYMASTEROK
    1. Verify the old master 192.168.0.31 has been failed over and is now a slave:
192.168.0.31:26379> INFO REPLICATION# Replicationrole:slavemaster_host:192.168.0.33master_port:6379master_link_status:up...
    1.  Examine the logs of Sentinel-2:
2283:X 12 Nov 15:35:14.782 # Executing user requested FAILOVER of 'mymaster'2283:X 12 Nov 15:35:14.782 # +new-epoch 12283:X 12 Nov 15:35:14.782 # +try-failover master mymaster 192.168.0.31 63792283:X 12 Nov 15:35:14.789 ...

Get Redis 4.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.