Question: How can I retrieve replication information in Redis?


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:> INFO replication

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:

# Replication

This output contains important details about the state of replication:

  • role: The role of this Redis instance (master or slave).
  • 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 "" with your Redis instance's IP address and port if it's different.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.