Skip to content

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

Closed

Description

@Long80A

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>

Activity

  1. badboy commented on Aug 25, 2014

    @badboy
    Contributor

    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.

  2. Long80A commented on Aug 26, 2014

    @Long80A
    Author

    Thank you for your answer.

  3. xtianus79 commented on Dec 19, 2019

    @xtianus79

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

  4. badboy commented on Dec 20, 2019

    @badboy
    Contributor

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

  5. xtianus79 commented on Dec 22, 2019

    @xtianus79

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

  6. itamarhaber commented on Dec 23, 2019

    @itamarhaber
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions