redis-cli: How to manually redirect to a specific port when running a cluster

1,328 views
Skip to first unread message

Michael Angerman

unread,
Apr 3, 2015, 1:30:51 AM4/3/15
to redi...@googlegroups.com

This is a question about redis cluster when running redis-cli.

Assuming I have the setup noted here : http://redis.io/topics/cluster-tutorial

Everything is up and running and it works great ---- Fantastic job !!

Assuming I start off by bringing up a client on 7000

redis-cli -c -p 7000

So I go off and set a bunch of keys for testing...

It will automatically set the keys and the slot and the port

Those keys are now distributed across different slots and ports {7000, 7001, 7002}, this happens automatically

Then I want to get one of those keys I just set.

If the key I get does not exist on 7000 the client says:

Redirected to slot [6597] located at 127.0.0.1:7001

and it will merrily get the value of that key and now I am sitting on port 7001

I can then run the "keys *" command and see all of the keys on port 7001.

Then I go get another key and if it is on port 7001 it will get it,

and if it is on port 7002 --- it will switch to that port and get the key.

Now I am on port 7002 and when I run the "keys *" command I get only the keys on 7002.  etc....

My question is ---->  If I want to go back to port 7000 and run the "keys *" command how do I get back to port 7000.

I can make it happen automatically by going off and getting a key that I know is on port 7000,
and it will REDIRECT me over automatically....

But is there a way to REDIRECT to that port manually with a redis client command ???

I know I can bring up another client on that port

redis-cli -c -p 7001

But I want to be able to stay in the same session / and or do this from client side code...

I am assuming this can not be done --- even though the redirect happens automatically if you know a key in another slot on another port.

Thanks,
Michael Angerman
Corvallis, Oregon





Jan-Erik Rediger

unread,
Apr 3, 2015, 4:44:47 AM4/3/15
to redi...@googlegroups.com
You can manually connect to another node:

connect 127.0.0.1 7000

Of course host and port can be changed.

On Thu, Apr 02, 2015 at 02:53:06PM -0700, Michael Angerman wrote:
>
> This is a question about redis cluster when running redis-cli.
>
> Assuming I have the setup noted here :
> http://redis.io/topics/cluster-tutorial
>
> Everything is up and running and it works great ---- Fantastic job !!
>
> Assuming I start off by bringing up a client on 7000
>
> redis-cli -c -p 7000
>
> So I go off and set a bunch of keys for testing...
>
> It will automatically set the keys and the slot and the port
>
> Those keys are now distributed across different slots and ports {7000,
> 7001, 7002}, this happens automatically
>
> Then I want to get one of those keys I just set.
>
> If the key I get does not exist on 7000 the client says:
>
> *Redirected to slot [6597] located at 127.0.0.1:7001*
>
> and it will merrily get the value of that key and now I am sitting on port
> 7001
>
> I can then run the "keys *" command and see all of the keys on port 7001.
>
> Then I go get another key and if it is on port 7001 it will get it,
>
> and if it is on port 7002 --- it will switch to that port and get the key.
>
> Now I am on port 7002 and when I run the "keys *" command I get only the
> keys on 7002. etc....
>
> My question is ----> If I want to go back to port 7000 and run the "keys
> *" command how do I get back to port 7000.
>
> I can make it happen automatically by going off and getting a key that I
> know is on port 7000,
> and it will REDIRECT me over automatically....
>
> But is there a way to REDIRECT to that port manually with a redis client
> command ???
>
> I know I can bring up another client on that port
>
> redis-cli -c -p 7001
>
> But I want to be able to stay in the same session / and or do this from
> client side code...
>
> I am assuming this can not be done --- even though the redirect happens
> automatically if you know a key in another slot on another port.
>
> Thanks,
> Michael Angerman
> Corvallis, Oregon
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages