In Redis, you can retrieve replication information using the
INFO command with the
replication section. This command returns details about the Redis instance, including various types of statistics and status data.
Here's how you can use it:
The output will provide detailed information about the state of replication. It includes the role of the instance (master or slave), the number of connected slaves if it's a master, or the master's IP and port if it's a slave. Here is a sample output for a master:
This output contains important details about the state of replication:
role: The role of this Redis instance (
connected_slaves: The number of connected slaves to this master.
slave<n>: One line per connected slave showing their IP, port, state, data offset, and lag in data received.
master_replid: The replication ID of the master. It changes when the data that is not in the backlog of any slave is modified.
Remember to replace "127.0.0.1:6379" with your Redis instance's IP address and port if it's different.