Search code examples
redisredis-clusterredis-cli

[REDIS]: How to Delete All Keys on Master and Slave(s)?


I'm trying to delete all keys on both redis master and slave, but when I'm executing flushall or flushdb from redis-cli on master it deletes keys only on master, or vice versa if I'm deleting keys on slave it deletes keys only on slave.

What command should I use to delete all keys both on master and slave(s)?

Do I need to enable cluster support for this? Cause now it is desabled in my setup.

One more question, why there is no replication in case of using flushall or flushdb from redis-cli?


Solution

  • You only need to call FLUSHALL or FLUSHDB on every master to remove all keys, when master syncs with slaves, slaves will remove all keys. However, you must ensure that the connection between master and slave is alive.

    If you call these two commands on slaves (of course, the slave must be writable), keys on master won't be removed.