redis sentinel mode

redis sentinel mode

Redis-4.0.8 One master two slaves, 3 sentinel construction method:

The build is on a virtual host, using different ports:

 

 Masternode: 192.168.1.235:6379

 slave node 1: 192.168.1.235: 6380

slave node 2: 192.168.1.235: 6381

Sentinel 1: 192.168.1.235: 2 6379

Sentinel 2: 192.168.1.235: 2 6380

Sentinel 3: 192.168.1.235: 2 6381

 

1. Master node: 192.168.1.235:6379 Configuration file:

 



#Main redis configuration
bind 0.0.0.0
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile "/usr/local/redis-4.0.8/conf/ms/pid/redis_6379.pid"
loglevel notice
logfile "/usr/local/redis-4.0.8/conf/log/redis_6379.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
dir "/usr/local/redis-4.0.8/conf/ms"
masterauth "123456"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass "123456"
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
# Generated by CONFIG REWRITE


 2. The configuration of the two slaves: except for the port, log and other configurations are different, the others are the same,

 

    The signs that distinguish master from slave are:

slaveof 192.168.1.235 6379

 


#Configure from redis
bind 0.0.0.0
protected-mode no
port 6381
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile "/usr/local/redis-4.0.8/conf/ms/pid/redis_6381.pid"
loglevel notice
logfile "/usr/local/redis-4.0.8/conf/log/redis_6381.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
dir "/usr/local/redis-4.0.8/conf/ms"
masterauth "123456"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass "123456"
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
slaveof 192.168.1.235 6379

 

 

 3. The configuration of the three sentinels is roughly the same, except for the port, the log is different:

 



# Sentinel configuration
protected-mode no
port 26380
daemonize yes
dir "/tmp"
logfile "/usr/local/redis-4.0.8/conf/log/sentinel_26380.log"
sentinel monitor mymaster 192.168.1.235 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 10000
sentinel auth-pass mymaster 123456

 

 

4. Question:

 1. Since the redis is built for external access, do not use 127.0.0.1 when binding the ip, but use the external ip

    a. Whether it is the bind configuration from the master or slave: bind 0.0.0.0

       Or the configuration behind the slaveof: slaveof 192.168.1.235 6379 , to configure the external ip 

    b. Sentinel monitor mymaster 192.168.1.235 6379 2 in the sentinel configuration  should configure the external ip

2. The master, slave and sentinel of the redis4 version must set protected-mode to no , otherwise the sentinel cannot failover:


protected-mode no

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325340441&siteId=291194637