Is there a way to flushall on a cluster so all keys from master and slaves are deleted from the db

左心房为你撑大大i 提交于 2020-06-29 06:44:12

问题


From the documentation this seems how flushall would work but in practice it is not working that way. When I use the command flushall it only flushes the keys from the db instance the cli is assigned to.

Redis flushall documentation

Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.

The time-complexity for this operation is O(N), N being the number of keys in all existing databases.

For example if my cluster redis-cli has started and I search for a key and the node cli changes from 7000 to 7002 corresponding with the key that the hash is located i.e. server 7002 and then do a flush all it will delete the key per that server.

However, the other keys remain.

Is there a way to flushall meaning delete all keys across all masters and slaves?


回答1:


Yes. You can use the cli's --cluster switch with the call command - it will execute the provided command on each of the cluster's master nodes (and will replicate, as FLUSHALL is a write command, to their respective slaves).

This should do it:

$ redis-cli --cluster call <one-of-the-nodes-address>:<its-port> FLUSHALL


来源:https://stackoverflow.com/questions/59492382/is-there-a-way-to-flushall-on-a-cluster-so-all-keys-from-master-and-slaves-are-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!