Search code examples
redisredis-sentinelredis-cli

How to connect to redis sentinel and manipulate different dbs


I am struggling to connect redis in sentinel mode using redis-cli.

I've tried:

redis-cli -h my_host -p my_port -a my_password

I randomly picked up one from 3 sentinel nodes to connect.

However, when logged in, it seems different with single mode redis, where I can manipulate dbs with set or hset commmand.

For instance, when I am typing:

select 0 (trying to select db 0)

It returns:

redis_sentinel_node_1_ip:port> select 0
(error) ERR unknown command `select`, with args beginning with: `0`

Could anyone help ?


Solution

  • While Sentinel and Redis use the same communication protocol (and live in the same executable as well), they support a very different set of commands. Afaik, Sentinel does not have the notion of multiple databases, so SELECT wouldn't have any sense there. If you just want to test a random command, you can use PING which is supported by both Redis and Sentinel.

    You may want to review the set of commands Sentinel supports on the official docs.