0

I'm gonna deploy a simple master-slave redis cluster with two servers: 192.168.0.101, 192.168.0.103, and 101 is the master.

here is the sentinel.conf on 103 server:

port 26379

bind 192.168.0.103 127.0.0.1

sentinel myid 49f552d5540fdcb8aa60be25208c56b689d3c0b0
sentinel monitor mymaster 192.168.0.101 6379 2
sentinel down-after-milliseconds mymaster 60000
sentinel failover-timeout mymaster 900000

sentinel auth-pass mymaster arsenal

sentinel config-epoch mymaster 0

# Generated by CONFIG REWRITE
dir "/etc/redis"
sentinel leader-epoch mymaster 3
sentinel known-slave mymaster 192.168.0.103 6379

sentinel current-epoch 3

and my redis.conf on 103 server:

bind 127.0.0.1 ::1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
daemonize yes
supervised no

dbfilename dump.rdb
dir /var/lib/redis
slaveof device1 6379
masterauth arsenal
slave-serve-stale-data yes
slave-read-only yes

slave-priority 100
requirepass arsenal

slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no

activerehashing yes

aof-rewrite-incremental-fsync yes

I started with the sentinel on 192.168.0.103 with redis-server sentinel.conf --sentinel

7951:X 14 Mar 14:19:48.479 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
7951:X 14 Mar 14:19:48.479 # Sentinel ID is 49f552d5540fdcb8aa60be25208c56b689d3c0b0
7951:X 14 Mar 14:19:48.479 # +monitor master mymaster 192.168.0.101 6379 quorum 2

7951:X 14 Mar 14:20:48.480 # +sdown slave 192.168.0.103:6379 192.168.0.103 6379 @ mymaster 192.168.0.101 6379
7951:X 14 Mar 14:21:11.577 # +sdown master mymaster 192.168.0.101 6379

My sentinel calling is like this:

sentinel = Sentinel([('device3', 26379)], password='arsenal')

sentinel.discover_master('mymaster')

MasterNotFoundError: No master found for 'mymaster'

The problem is after I tried to stop the redis-server service on 101, the sentinel can not switch the 103 server as the master.

Anyone who have idea? thanks.

DennisLi
  • 3,915
  • 6
  • 30
  • 66

1 Answers1

0
  1. In your config sentinel monitor mymaster 192.168.0.101 6379 2, quorum is 2, which means only two or more than two Sentinels think master down, can failover start.

  2. See Redis Sentinel doc, only three or more than three Sentinels can be deployed stably, if you only have one Sentinel, it can not elects a leader (which get votes of majority) to start a failover.

DQYuan
  • 167
  • 7