Testing Sentinel
We have demonstrated in the previous recipe how to set up an environment of one Redis master and two slaves, which is monitored by three Sentinels. In this recipe, we will do a couple of experiments in this environment and verify the Sentinels are doing their jobs correctly. We will also explain the master failover process in detail.
Getting ready…
You must finish the setup in the Setting up Sentinel section of this chapter. Additionally, you can refer to the table shown in the Getting ready section of the previous recipe, Setting up Sentinel.
How to do it...
To test the Redis Sentinel set up in the previous recipe, take the following steps:
- Triggering a master failover manually:
- Connect to one of the Sentinels using
redis-cli
; here we are connecting to Sentinel-2 (192.168.0.32
):
- Connect to one of the Sentinels using
192.168.0.32:26379> SENTINEL FAILOVER MYMASTER OK
- Verify the old master
192.168.0.31
has been failed over and is now a slave:
- Verify the old master
192.168.0.31:26379> INFO REPLICATION # Replication role:slave master_host...