Hi,
I am new to redis, I am using a redis in sentinel mode.
I am strugging with manipulate my redis db using redis-cli in sentinel mode.
I am using:
redis-cli -h my_host -p my_port -a my_password
where I randomly picked one node (host and port) from 3 sentinel nodes.
The connection has been successfully established, however I cannot using regular redis-cli command such as:
select 0
to switch between dbs.
nor
FLUSHDB
ALL the above commands turn out to be something like:
host:port> select 0
(error) ERR unknown command `select`, with args beginning with: `0`,
I am sure this is related to the usage of redis-cli, as I can notice information like master name is not provided.
However, I searched over internet and I cannot even find any pieces/intro about redis-cli usage under redis sentinel mode.
Can anyone help ?
Comment From: itamarhaber
Hello @suesunss
It appears that you're trying to use Sentinel for service discovery with redis-cli. AFAIK, the cli doesn't handle that so you'd have to connect to the Sentinel node, issue a SENTINEL get-master-addr-by-name <master name> command, and use the information returned to connect to the current master with the cli.
Comment From: suesunss
it works like a charm. @itamarhaber thanks.
Comment From: hwware
@suesunss hello ,sentinel mode for redis is a special mode and there is only centain command supported. these are ping, sentinel, subscribe, unsubscribe, psubscribe, punsubscribe, publish, info, role, client, shutdown, auth and hello. The reason of that is sentinel is used for monitoring redis master and replica works as expected, if the master is offline, it will do an automatic failover. It is not supposed for using as a caching service or a db. therefore the normal redis db command are not supported. please check these information if you need. https://redis.io/topics/sentinel thanks
Comment From: suesunss
@hwware thanks ! I was thinking the connected sentinel node could take over issuing the commands to the real data node. I'll go dive into the docs now.
Comment From: mustaphazorgati
.sc