Administrating Sentinel
We learned how to set up and test Redis Sentinel in the previous two recipes. Besides monitoring the status of Redis masters and slaves, Redis Sentinel also provides convenient features such as executing scripts on Sentinel events, or on failover. In this recipe, we will first introduce a few Sentinel commands which are frequently used, then we will see how to utilize the scripts execution feature to automate some common operation.
Getting ready…
You must finish the setup in the Setting up Sentinel section of this chapter, and have Redis data servers and Sentinels up and running.
How to do it...
The operations for administrating Redis Sentinel are as follows:
- Exploring Sentinel commands:
- Â Connect to one of the Sentinels using
redis-cli
:
- Â Connect to one of the Sentinels using
user@192.168.0.33:~$bin/redis-cli -h 192.168.0.33 -p 26379 192.168.0.33:26379>
- To get current master data server information, use
SENTINEL GET-MASTER-ADDR-BY-NAME <master-name>
:
- To get current master data server information, use
192.168.0.33:26379> SENTINEL GET-MASTER-ADDR-BY-NAME...