I have the following configuration:
1 redis master setup with 3 redis slaves in replication and with auth enabled
3 redis sentinel instances configured with the master/slave setup for failover
My configuration works well and I am able to access either my master or any of the slaves. I have also tested failover, and it works well.
Now, I would like to connect to my sentinel using ioredis and I am experiencing some issue.
As mentioned in the documentation, I used the following snippets (with or without password) to connect to my redis sentinel:
var Redis = require('ioredis');
var redis = new Redis({
sentinels: [{ host: 'redis-sentinel', port: 26379, password: "My-highly-secured-password" }],
name: 'mymaster'
});
redis.set('foo', 'toto');
redis.get('foo', function (err, result) {
console.log(result);
});
var Redis = require('ioredis');
var redis = new Redis({
sentinels: [{ host: 'redis-sentinel', port: 26379 }],
name: 'mymaster'
});
redis.set('foo', 'toto');
redis.get('foo', function (err, result) {
console.log(result);
});
But in both the two cases, I end up with the same error:
[ioredis] Unhandled error event: ReplyError: NOAUTH Authentication required.
Does that mean that it is impossible to connect to a sentinel setup with auth enabled redis master/slaves instances using ioredis library?
You can still passes password option as how you connect to a single redis instance:
var redis = new Redis({
sentinels: [{ host: 'redis-sentinel', port: 26379 }],
password: "My-highly-secured-password",
name: 'mymaster'
});
However, it's required that all your redis instances' password are same.
Thank you guy for your response, @luin
Tested and it works fine.
If you've set password for both sentinel and redis nodes, like in bitnami helm chart
var redis = new Redis({
sentinels: [{ host: 'redis-sentinel', port: 26379 }],
password: "My-highly-secured-password",
sentinelPassword: "My-highly-secured-password",
name: 'mymaster'
});
Most helpful comment
You can still passes
passwordoption as how you connect to a single redis instance:However, it's required that all your redis instances' password are same.