简体   繁体   中英

How to find which Redis instance was master on a specific day (Redis promotion history)

I am running Redis + Sentinel as containers on 4 RHEL machines. Is there a way of finding out which Redis server was the master on a specific day?

I know running INFO (INFO REPLICATION) will give me the current role for each server, but I'd like to find out which one was the master on a specific day in order to review metrics in an APM.

I quickly run a setup and triggered sentinel failover to generate below logs.

If you check your sentinel log file you will find logs like this

55451:X 03 Sep 2022 20:27:02.699 # Executing user requested FAILOVER of 'mymaster'
55451:X 03 Sep 2022 20:27:02.699 # +new-epoch 1
55451:X 03 Sep 2022 20:27:02.699 # +try-failover master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.749 * Sentinel new configuration saved on disk
55451:X 03 Sep 2022 20:27:02.749 # +vote-for-leader dcfdb6ee5b4341866ac2933b8cf15f08631ac366 1
55451:X 03 Sep 2022 20:27:02.749 # +elected-leader master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.749 # +failover-state-select-slave master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.833 # +selected-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.833 * +failover-state-send-slaveof-noone slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:02.913 * +failover-state-wait-promotion slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.055 * Sentinel new configuration saved on disk
55451:X 03 Sep 2022 20:27:03.055 # +promoted-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.055 # +failover-state-reconf-slaves master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.144 # +failover-end master mymaster 127.0.0.1 6379
55451:X 03 Sep 2022 20:27:03.144 # +switch-master mymaster 127.0.0.1 6379 127.0.0.1 6380
55451:X 03 Sep 2022 20:27:03.144 * +slave slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6380
55451:X 03 Sep 2022 20:27:03.146 * Sentinel new configuration saved on disk
55451:X 03 Sep 2022 20:27:13.256 * +convert-to-slave slave 127.0.0.1:6379 127.0.0.1 6379 @ mymaster 127.0.0.1 6380

You can easily find when which server was promoted as master in your setup

55451:X 03 Sep 2022 20:27:03.055 # +promoted-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ mymaster 127.0.0.1 6379

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM