How can I set password for Redis cluster? - redis

I'm trying to set password for my Redis cluster (3 masters, 3 slaves).
I have changed the /etc/redis/redis.conf configuration file on "requirepass" field, but when I log into the cluster i didn't get an error message (telling me to use password).
so, How can I set password for my Redis cluster?
thank you

Setting a slave to authenticate to a master
If your master has a password via requirepass, it's trivial to configure the slave to use that password in all sync operations.
To do it on a running instance, use redis-cli and type:
config set masterauth <password>
To set it permanently, add this to your config file:
masterauth <password>
Full info in: https://redis.io/topics/replication

Related

How to set password for redis-server

I have a 3-instance high availability redis deployed. On each server I have redis and sentinel installed. I am trying to set a password
so that it requests it at the moment of entering with the command "redis-cli".
I am modifying the value of the "requirepass" parameter of the "redis.conf" file.
requirepass password123
Also inside the redis terminal, I am setting the password with the following commands
config set requirepass password123
auth password123
When I connect with the following command
redis-cli --tls --cert /<path>/redis.crt --key /<path>/redis.key --cacert /<path>/ca.crt -a password123
It works fine, my problem is when I restart the redis service, for some reason the password settings are not kept and I get the following message
Warning: AUTH failed
I do not know what configuration I need to do so that the change is maintained after restarting the redis service.
The version of redis that I have installed is "Redis server v=6.0.6"
Check your ACL configuration,Your requirepass configuration will be ignored with ACL operation. I get follow infomation from redis.conf example file.
IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
layer on top of the new ACL system. The option effect will be just setting
the password for the default user. Clients will still authenticate using
AUTH as usually, or more explicitly with AUTH default
if they follow the new protocol: both will work.
The requirepass is not compatable with aclfile option and the ACL LOAD
command, these will cause requirepass to be ignored.
config rewrite
This command will solve your issue of nopass after restart.
After setting the requirepass from redis cli.

Redis: redis-cli not asking for password

I have configured my redis.conf with requirepass and I started the server with
redis-server redis.conf
However, when I run redis-cli it does not ask me for password
and lets me connect to redis, but when I try to run a command, asks me for the password.
This behavior is causing problems with Sentinel because Sentinel tries to authenticate. Sentinel won't find that master because is not asking for password.
https://medium.com/garimoo/redis-sentinel-no-such-master-with-specified-name-fatal-config-file-error-1ca8b3d25d38
Wasn't something releated to redis-cli i associated two separate things
there is the solution.

Redis Sentinel Authentication

I have 3 Servers with Redis and Sentinel Running.
All instances have in the configuration
requirepass XXX
masterauth XXX
I can connect with redis-cli to the redis server but if I try to connect to the sentinel I can not authenticate.
root#ip-:/usr/lib/nagios/plugins# redis-cli -p 26379
127.0.0.1:26379> AUTH xxx
(error) ERR unknown command 'AUTH'
127.0.0.1:26379>
If I use the same command but with the redis port it works.
Thanks
best
You have to setup auth for sentinels, too. I mean requirepass=<password> in sentinel.conf. More info on this here and here. Be careful, as not every client supports this setup.
Also, you need to set sentinel auth-pass <master-name> <password> in that file, in order for the sentinels to be able to administrate secured redis servers. (But I'm guessing you already did that).

How to make redis comand SLAVEOF work for encrypted redis master?

I started two redis node separately with original redis.conf, which I don't want to edit it, however I want to use redis command, such as slaveof, to config redis nodes dynamically.
If redis nodes without 'auth', i.e. no "requirepass" in the redis.conf, the following command on the slave redis node will work:
redis-server --slaveof redis-master 6379
where redis-master is the hostname of the redis master node.
But this will not work if the master is encrypted. I've went through the redis official docs, nothing helps. Before I go for antirez, I want to hear from you here.
You can set the masterauth config to specify the master's password.
start redis-cli to connect to the slave instance.
set masterauth config: config set masterauth master-password
set master: slaveof redis-master master-port

redis config set fails for slaveof

I am working with a master slave redis replication setup with redis version 2.4.15-1. I am testing to manually update the setting of one of the slaves to upgrade it to a master once the original master goes down. But from the client, I keep getting the following:
redis server:6381> CONFIG SET SLAVEOF "NO ONE"
(error) ERR Unsupported CONFIG parameter: SLAVEOF
Would I necessarily need to restart redis-server to do this? I assumed otherwise based on http://redis.io/topics/admin.
SLAVEOF is a command itself, not a config variable. You can make your server a slave of another server by running this on your slave:
SLAVEOF my.host.com 1234
(Where my.host.com is the server host and 1234 is your server port.)
If your master instance has a password, you'll need to set the MASTERAUTH config variable:
CONFIG SET MASTERAUTH foobar