使用Redis Sentinel时,如何使用密码保护主节点和副本节点?

时间:2019-05-10 15:37:45

标签: redis redis-sentinel

我能够将requirepass "redis-dev-pass"添加到哨兵配置文件中,以设置这些服务器的密码。但是,当将相同字段添加到主副本和包括masteauth字段的副本时,sentinel认为所有这些服务器都已关闭。

67476:X 10 May 2019 11:31:43.109 # Sentinel ID is 
3ef0b36a3937477ace9e9d59134272e71c256c68
67476:X 10 May 2019 11:31:43.109 # +monitor master mymaster 127.0.0.1 7000 quorum 1
67476:X 10 May 2019 11:31:48.134 # +sdown master mymaster 127.0.0.17000
67476:X 10 May 2019 11:31:48.134 # +odown master mymaster 127.0.0.1 7000 #quorum 1/1
67476:X 10 May 2019 11:31:48.134 # +new-epoch 1
67476:X 10 May 2019 11:31:48.134 # +try-failover master mymaster 127.0.0.1 7000
67476:X 10 May 2019 11:31:48.135 # +vote-for-leader 3ef0b36a3937477ace9e9d59134272e71c256c68 1
67476:X 10 May 2019 11:31:48.135 # +elected-leader master mymaster 127.0.0.1 7000
67476:X 10 May 2019 11:31:48.135 # +failover-state-select-slave master mymaster 127.0.0.1 7000
67476:X 10 May 2019 11:31:48.190 # -failover-abort-no-good-slave master mymaster 127.0.0.1 7000
67476:X 10 May 2019 11:31:48.246 # Next failover delay: I will not start a failover before Fri May 10 11:37:48 2019

但是副本连接到主节点没有问题

67336:S 10 May 2019 11:29:12.060 # Server initialized
67336:S 10 May 2019 11:29:12.061 * DB loaded from disk: 0.000 seconds
67336:S 10 May 2019 11:29:12.061 * Before turning into a replica, using my master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
67336:S 10 May 2019 11:29:12.061 * Ready to accept connections
67336:S 10 May 2019 11:29:12.061 * Connecting to MASTER 127.0.0.1:7000
67336:S 10 May 2019 11:29:12.061 * MASTER <-> REPLICA sync started
67336:S 10 May 2019 11:29:12.061 * Non blocking connect for SYNC fired the event.
67336:S 10 May 2019 11:29:12.061 * Master replied to PING, replication can continue...
67336:S 10 May 2019 11:29:12.061 * Trying a partial resynchronization (request bb8f55d8e8336ec1b7bcc986b712b3f1c386d37b:3864).
67336:S 10 May 2019 11:29:12.062 * Full resync from master: 233bf4156083aa06321579c328fff42f5ec4e8a9:0
67336:S 10 May 2019 11:29:12.062 * Discarding previously cached master state.
67336:S 10 May 2019 11:29:12.125 * MASTER <-> REPLICA sync: receiving 175 bytes from master
 67336:S 10 May 2019 11:29:12.125 * MASTER <-> REPLICA sync: Flushing old data
67336:S 10 May 2019 11:29:12.125 * MASTER <-> REPLICA sync: Loading DB in memory
67336:S 10 May 2019 11:29:12.126 * MASTER <-> REPLICA sync: Finished with success

sentinel.conf(我在5000 5001 5002上有3个)

port 5000
sentinel deny-scripts-reconfig yes
sentinel monitor mymaster 127.0.0.1 7000 1
sentinel down-after-milliseconds mymaster 5000
requirepass "pass"
masterauth "pass"

和redis.conf为主控

port 7000
bind 127.0.0.1

requirepass pass

类似的东西

1 个答案:

答案 0 :(得分:0)

原来这只是一个不同的配置选项

sentinel auth-pass mymaster redis-dev-pass