Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About command "keys * " in cluster--How can I get all keys in redis cluster? #1962

Closed
Long80A opened this issue Aug 25, 2014 · 6 comments
Closed

Comments

@Long80A
Copy link

@Long80A Long80A commented Aug 25, 2014

How can I get all keys in redis cluster?
When I use keys * ,I get a result of the redis-server I have connected:
[admin@localhost src]$ ./redis-cli -c -p 7000
127.0.0.1:7000> keys *
(empty list or set)
127.0.0.1:7000> get foo
-> Redirected to slot [12182] located at 127.0.0.1:7002
"bar"
127.0.0.1:7002>

@badboy
Copy link
Contributor

@badboy badboy commented Aug 25, 2014

You can't. You would have to ask each node seperately. But please avoid KEYS * whenever possible. If you really must iterate the whole keyspace of an instance use SCAN.

Btw, this issue tracker should be used for bugs or improvements to the Redis server. For questions like your's please ask on the mailing list or in the irc channel.

@mattsta mattsta closed this Aug 25, 2014
@Long80A
Copy link
Author

@Long80A Long80A commented Aug 26, 2014

Thank you for your answer.

@xtianus79
Copy link

@xtianus79 xtianus79 commented Dec 19, 2019

@badboy this should be put into the documentation but thank you for the answer @mattsta

@badboy
Copy link
Contributor

@badboy badboy commented Dec 20, 2019

Then do that ;)
I'm not working on Redis anymore.

@xtianus79
Copy link

@xtianus79 xtianus79 commented Dec 22, 2019

lol @badboy, did you ever? I don't know that. but also, is their page a wiki where anyone can edit it?

@itamarhaber
Copy link
Contributor

@itamarhaber itamarhaber commented Dec 23, 2019

The docs are open at https://github.com/antirez/redis-doc, and this could belong in 'topics/cluster-tutorial.md'.

Newer versions of Redis include more cluster support in the cli. To answer the OP's question, you can do the following to have a command, such as KEYS execute on each node:

$ redis-cli --cluster call 127.0.0.1:7000 KEYS "*"

The cli also supports a --scan mode, for SCANning keys instead if using KEYS. That said, I don't think that --scan and --cluster modes play nicely together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.