How to know connected slaves to a master in redis?

by raven_corwin , in category: Third Party Scripts , 8 months ago

How to know connected slaves to a master in redis?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , 8 months ago

@raven_corwin 

You can use the CLIENT LIST command in Redis to get a list of all the connections to the server, including both master and slave instances. To filter out only the slave connections, you can look at the flags field in the output of the CLIENT LIST command.


Here is an example of how you can do this in the Redis command line interface:

  1. Open a Redis CLI by running the command redis-cli.
  2. Run the CLIENT LIST command to get a list of all connections to the server.
  3. Look at the output of the command and find the connections with the flags field containing "slave".


For example, the output of the CLIENT LIST command may look something like this:

1
2
id=1 addr=127.0.0.1:58580 fd=5 name=slave, flags=slave
id=2 addr=127.0.0.1:58581 fd=6 name=client-1, flags=


In this example, the connection with flags=slave indicates that it is a slave instance connected to the master. This way, you can identify the connected slaves to a master in Redis.