Closed CQBinh closed 7 years ago
Please try to add a statement (debug('resolved: %s:%s', resolved.host, resolved.port);
) to log the resolved address:
in lib/connectors/sentinel_connector.js to see whether the sentinels return the correct master address.
It returns the same result with when I query via cli: x.y.z.1:6379
.
Still returns the master IP.
Update 2: one more thing, I run the app in my local machine with the production environment and everything work like charm!!!
I'm not sure but the issue may due to the configuration since it seems the correct address has been resolved to the client.
Yeah, finally found.
It's my mistake when an old code use the redis
module and try to connect directly to localhost
.
Replace it to ioredis
instance and it work like charm :)
Anw, thank for your quickly help.
I have this
redis replication
withsentinel
architect:5 servers:
.1
,.2
,.3
,.4
and.5
.1
: nodejs app, redis master, redis sentinel.2
: nodejs app, redis slave.3
: nodejs app, redis slave.4
: redis sentinel.5
: redis sentinelSentinel handle failover as expected.
redis-cli -h x.y.z.5 -p 26379 sentinel get-master-addr-by-name mymaster
is always return.1
server.My code to connect to this replication:
Then,
.1
nodejs app run ok, but in.2
and.3
, the error occurs with this log:P/s: my redis servers are binding in both server IP and
127.0.0.1
. Because, without127.0.0.1
, I meet this error:So, I guess that, my app isn't connect to
redis server
viasentinel
, but it connect directly withlocalhost
.Any help are appriciate!
Update: log when I turn on the
DEBUG=ioredis:*
:Update 2: one more thing, I run the app in my local machine with the production environment and everything work like charm!!!