Introducing Dragonfly Cloud! Learn More

Question: How can you check the Redis replication status?

Answer

You can check the status of Redis replication using the INFO command, particularly the INFO REPLICATION section. This command provides information about Redis's master or slave state along with other details such as connected slaves, master link status etc.

Here is an example of how to do this:

$ redis-cli 127.0.0.1:6379> INFO REPLICATION

The output will provide a lot of useful information. If your instance is set as a master, it will show something similar to:

# Replication role:master connected_slaves:3 slave0:ip=127.0.0.1,port=6380,state=online,offset=1456,lag=1 slave1:ip=127.0.0.1,port=6381,state=online,offset=1456,lag=1 slave2:ip=127.0.0.1,port=6382,state=online,offset=1456,lag=1 master_replid:<some id> master_replid2:0000000000000000000000000000000000000000 master_repl_offset:1456 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:1 repl_backlog_histlen:1456

If your instance is set as a slave, it will show:

# Replication role:slave master_host:127.0.0.1 master_port:6379 master_link_status:up master_last_io_seconds_ago:6 master_sync_in_progress:0 slave_repl_offset:184823 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:<some id> master_replid2:0000000000000000000000000000000000000000 master_repl_offset:184823 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:69868 repl_backlog_histlen:114956

In this way, you can easily check the replication status of your Redis instances.

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.