在上篇文章中介绍了Redis主从模式的优点和缺点,哨兵模式是建立在主从模式基础之上的,主从模式中一点主节点发生故障,必须引入手工切换,而哨兵模式则可以解决这个问题。

docker-compose.yml

本文示例在一主两从的Redis服务基础之上添加三个哨兵(Sentinel),示例的yml文件如下所示:

liumiaocn:redis liumiao$ cat docker-compose.yml
version: '2'
services:# redis mastermaster:image: redis:6.0.4container_name: redis-masterrestart: alwayscommand: redis-server --port 6379 --requirepass liumiaocn@server  --appendonly yesports:- 6379:6379volumes:- ./data:/data# redis slave 1 slave1:image: redis:6.0.4container_name: redis-slave-1restart: alwayscommand: redis-server --slaveof 192.168.31.242 6379 --port 6380 --requirepass liumiaocn@server --masterauth liumiaocn@server  --appendonly yesports:- 6380:6380volumes:- ./data:/data# redis slave 2 slave2:image: redis:6.0.4container_name: redis-slave-2restart: alwayscommand: redis-server --slaveof 192.168.31.242 6379 --port 6381 --requirepass liumiaocn@server --masterauth liumiaocn@server  --appendonly yesports:- 6381:6381volumes:- ./data:/data# reids sentinel 1sentinel1:image: redis:6.0.4container_name: redis-sentinel-1command: redis-sentinel /usr/local/etc/redis/sentinel.confrestart: alwaysports:- 26379:26379volumes:- ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf# reids sentinel 2 sentinel2:image: redis:6.0.4container_name: redis-sentinel-2command: redis-sentinel /usr/local/etc/redis/sentinel.confrestart: alwaysports:- 26380:26379volumes:- ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf# reids sentinel 3sentinel3:image: redis:6.0.4container_name: redis-sentinel-3command: redis-sentinel /usr/local/etc/redis/sentinel.confrestart: alwaysports:- 26381:26379volumes:- ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf
liumiaocn:redis liumiao$

配置文件信息

liumiaocn:redis liumiao$ cat sentinel1.conf
port 26379
dir "/tmp"
sentinel monitor redismaster 192.168.31.242 6379 2
sentinel down-after-milliseconds redismaster 30000
sentinel parallel-syncs redismaster 1
sentinel deny-scripts-reconfig yes
sentinel auth-pass redismaster liumiaocn@server
sentinel failover-timeout redismaster 180000
liumiaocn:redis liumiao$ diff sentinel1.conf sentinel2.conf
liumiaocn:redis liumiao$ diff sentinel1.conf sentinel3.conf
liumiaocn:redis liumiao$

启动服务

启动确认

liumiaocn:redis liumiao$ docker-compose up -d
Creating network "redis_default" with the default driver
Creating redis-sentinel-1 ... done
Creating redis-master     ... done
Creating redis-slave-1    ... done
Creating redis-sentinel-2 ... done
Creating redis-sentinel-3 ... done
Creating redis-slave-2    ... done
liumiaocn:redis liumiao$

服务确认

liumiaocn:redis liumiao$ docker-compose psName                    Command               State                 Ports
----------------------------------------------------------------------------------------------
redis-master       docker-entrypoint.sh redis ...   Up      0.0.0.0:6379->6379/tcp
redis-sentinel-1   docker-entrypoint.sh redis ...   Up      0.0.0.0:26379->26379/tcp, 6379/tcp
redis-sentinel-2   docker-entrypoint.sh redis ...   Up      0.0.0.0:26380->26379/tcp, 6379/tcp
redis-sentinel-3   docker-entrypoint.sh redis ...   Up      0.0.0.0:26381->26379/tcp, 6379/tcp
redis-slave-1      docker-entrypoint.sh redis ...   Up      6379/tcp, 0.0.0.0:6380->6380/tcp
redis-slave-2      docker-entrypoint.sh redis ...   Up      6379/tcp, 0.0.0.0:6381->6381/tcp
liumiaocn:redis liumiao$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                NAMES
d6084a0e9d2e        redis:6.0.4         "docker-entrypoint.s…"   48 seconds ago      Up 46 seconds       6379/tcp, 0.0.0.0:6381->6381/tcp     redis-slave-2
c0370c9f685a        redis:6.0.4         "docker-entrypoint.s…"   48 seconds ago      Up 46 seconds       0.0.0.0:6379->6379/tcp               redis-master
e751670b0059        redis:6.0.4         "docker-entrypoint.s…"   48 seconds ago      Up 46 seconds       6379/tcp, 0.0.0.0:26381->26379/tcp   redis-sentinel-3
ad5a080315d3        redis:6.0.4         "docker-entrypoint.s…"   48 seconds ago      Up 46 seconds       6379/tcp, 0.0.0.0:26380->26379/tcp   redis-sentinel-2
c55e3c715994        redis:6.0.4         "docker-entrypoint.s…"   48 seconds ago      Up 45 seconds       6379/tcp, 0.0.0.0:26379->26379/tcp   redis-sentinel-1
34a10aac06fe        redis:6.0.4         "docker-entrypoint.s…"   48 seconds ago      Up 46 seconds       6379/tcp, 0.0.0.0:6380->6380/tcp     redis-slave-1
liumiaocn:redis liumiao$

确认master信息

liumiaocn:redis liumiao$ redis-cli -p 26379
127.0.0.1:26379> sentinel master redismaster1) "name"2) "redismaster"3) "ip"4) "192.168.31.242"5) "port"6) "6379"7) "runid"8) "a2b5ed263dd7532ad2dca170bf6606592305890a"9) "flags"
10) "master"
11) "link-pending-commands"
12) "0"
13) "link-refcount"
14) "1"
15) "last-ping-sent"
16) "0"
17) "last-ok-ping-reply"
18) "841"
19) "last-ping-reply"
20) "841"
21) "down-after-milliseconds"
22) "30000"
23) "info-refresh"
24) "4943"
25) "role-reported"
26) "master"
27) "role-reported-time"
28) "115686"
29) "config-epoch"
30) "0"
31) "num-slaves"
32) "2"
33) "num-other-sentinels"
34) "2"
35) "quorum"
36) "2"
37) "failover-timeout"
38) "180000"
39) "parallel-syncs"
40) "1"
127.0.0.1:26379>

确认slave信息

可以看到如下两个从节点信息

127.0.0.1:26379> sentinel slaves redismaster
1)  1) "name"2) "192.168.240.1:6381"3) "ip"4) "192.168.240.1"5) "port"6) "6381"7) "runid"8) "9f9a35cdaa78c958eb85208f4cafbebf1d5f9ecb"9) "flags"10) "slave"11) "link-pending-commands"12) "0"13) "link-refcount"14) "1"15) "last-ping-sent"16) "0"17) "last-ok-ping-reply"18) "347"19) "last-ping-reply"20) "347"21) "down-after-milliseconds"22) "30000"23) "info-refresh"24) "1908"25) "role-reported"26) "slave"27) "role-reported-time"28) "162585"29) "master-link-down-time"30) "0"31) "master-link-status"32) "ok"33) "master-host"34) "192.168.31.242"35) "master-port"36) "6379"37) "slave-priority"38) "100"39) "slave-repl-offset"40) "36642"
2)  1) "name"2) "192.168.240.1:6380"3) "ip"4) "192.168.240.1"5) "port"6) "6380"7) "runid"8) "059a12b5d15417adfcd02cbd635779071cb624cc"9) "flags"10) "slave"11) "link-pending-commands"12) "0"13) "link-refcount"14) "1"15) "last-ping-sent"16) "0"17) "last-ok-ping-reply"18) "348"19) "last-ping-reply"20) "348"21) "down-after-milliseconds"22) "30000"23) "info-refresh"24) "1907"25) "role-reported"26) "slave"27) "role-reported-time"28) "162591"29) "master-link-down-time"30) "0"31) "master-link-status"32) "ok"33) "master-host"34) "192.168.31.242"35) "master-port"36) "6379"37) "slave-priority"38) "100"39) "slave-repl-offset"40) "36642"
127.0.0.1:26379>

整体日志信息

liumiaocn:redis liumiao$ docker-compose logs
Attaching to redis-slave-2, redis-master, redis-sentinel-3, redis-sentinel-2, redis-sentinel-1, redis-slave-1
redis-slave-2 | 1:C 07 Jun 2020 01:42:29.377 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-slave-2 | 1:C 07 Jun 2020 01:42:29.377 # Redis version=6.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-slave-2 | 1:C 07 Jun 2020 01:42:29.377 # Configuration loaded
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.380 * Running mode=standalone, port=6381.
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.380 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.380 # Server initialized
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.380 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.383 * Ready to accept connections
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.383 * Connecting to MASTER 192.168.31.242:6379
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.383 * MASTER <-> REPLICA sync started
redis-slave-2 | 1:S 07 Jun 2020 01:42:29.384 * Non blocking connect for SYNC fired the event.
redis-slave-2 | 1:S 07 Jun 2020 01:42:30.214 * Master replied to PING, replication can continue...
redis-slave-2 | 1:S 07 Jun 2020 01:42:30.218 * Partial resynchronization not possible (no cached master)
redis-slave-2 | 1:S 07 Jun 2020 01:42:30.221 * Full resync from master: f242fca3ad938609e70c192a0c492b4bfa97fc31:0
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.250 * MASTER <-> REPLICA sync: receiving 175 bytes from master to disk
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.251 * MASTER <-> REPLICA sync: Flushing old data
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.252 * MASTER <-> REPLICA sync: Loading DB in memory
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.255 * Loading RDB produced by version 6.0.4
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.256 * RDB age 1 seconds
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.256 * RDB memory usage when created 2.24 Mb
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.256 * MASTER <-> REPLICA sync: Finished with success
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.258 * Background append only file rewriting started by pid 22
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.290 * AOF rewrite child asks to stop sending diffs.
redis-slave-2 | 22:C 07 Jun 2020 01:42:31.290 * Parent agreed to stop sending diffs. Finalizing AOF...
redis-slave-2 | 22:C 07 Jun 2020 01:42:31.290 * Concatenating 0.00 MB of AOF diff received from parent.
redis-slave-2 | 22:C 07 Jun 2020 01:42:31.293 * SYNC append only file rewrite performed
redis-slave-2 | 22:C 07 Jun 2020 01:42:31.294 * AOF rewrite: 0 MB of memory used by copy-on-write
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.350 * Background AOF rewrite terminated with success
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.352 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
redis-slave-2 | 1:S 07 Jun 2020 01:42:31.355 * Background AOF rewrite finished successfully
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.974 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.974 # Redis version=6.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.974 # Configuration loaded
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.976 * Running mode=sentinel, port=26379.
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.976 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.983 # Sentinel ID is 96f68c8a1b158d081d3c1268d220e82c5c480abb
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:29.983 # +monitor master redismaster 192.168.31.242 6379 quorum 2
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:31.177 * +sentinel sentinel 1b9edaa4b9ef749ee8c12a10c10b65a2a34542a1 192.168.240.2 26379 @ redismaster 192.168.31.242 6379
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:31.617 * +sentinel sentinel 3258fb06b016bbdeecd506e08b343284c918a276 192.168.240.5 26379 @ redismaster 192.168.31.242 6379
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:40.274 * +slave slave 192.168.240.1:6380 192.168.240.1 6380 @ redismaster 192.168.31.242 6379
redis-sentinel-1 | 1:X 07 Jun 2020 01:42:40.280 * +slave slave 192.168.240.1:6381 192.168.240.1 6381 @ redismaster 192.168.31.242 6379
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.587 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.587 # Redis version=6.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.587 # Configuration loaded
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.589 * Running mode=sentinel, port=26379.
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.589 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.597 # Sentinel ID is 3258fb06b016bbdeecd506e08b343284c918a276
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:29.597 # +monitor master redismaster 192.168.31.242 6379 quorum 2
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:31.178 * +sentinel sentinel 1b9edaa4b9ef749ee8c12a10c10b65a2a34542a1 192.168.240.2 26379 @ redismaster 192.168.31.242 6379
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:31.990 * +sentinel sentinel 96f68c8a1b158d081d3c1268d220e82c5c480abb 192.168.240.7 26379 @ redismaster 192.168.31.242 6379
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:40.269 * +slave slave 192.168.240.1:6380 192.168.240.1 6380 @ redismaster 192.168.31.242 6379
redis-sentinel-3 | 1:X 07 Jun 2020 01:42:40.275 * +slave slave 192.168.240.1:6381 192.168.240.1 6381 @ redismaster 192.168.31.242 6379
redis-master | 1:C 07 Jun 2020 01:42:29.638 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-master | 1:C 07 Jun 2020 01:42:29.638 # Redis version=6.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-master | 1:C 07 Jun 2020 01:42:29.638 # Configuration loaded
redis-master | 1:M 07 Jun 2020 01:42:29.643 * Running mode=standalone, port=6379.
redis-master | 1:M 07 Jun 2020 01:42:29.643 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-master | 1:M 07 Jun 2020 01:42:29.643 # Server initialized
redis-master | 1:M 07 Jun 2020 01:42:29.643 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis-master | 1:M 07 Jun 2020 01:42:29.645 * Ready to accept connections
redis-master | 1:M 07 Jun 2020 01:42:30.219 * Replica 192.168.240.1:6380 asks for synchronization
redis-master | 1:M 07 Jun 2020 01:42:30.219 * Full resync requested by replica 192.168.240.1:6380
redis-master | 1:M 07 Jun 2020 01:42:30.219 * Replication backlog created, my new replication IDs are 'f242fca3ad938609e70c192a0c492b4bfa97fc31' and '0000000000000000000000000000000000000000'
redis-master | 1:M 07 Jun 2020 01:42:30.219 * Starting BGSAVE for SYNC with target: disk
redis-master | 1:M 07 Jun 2020 01:42:30.220 * Background saving started by pid 19
redis-master | 1:M 07 Jun 2020 01:42:30.220 * Replica 192.168.240.1:6381 asks for synchronization
redis-master | 1:M 07 Jun 2020 01:42:30.220 * Full resync requested by replica 192.168.240.1:6381
redis-master | 1:M 07 Jun 2020 01:42:30.221 * Waiting for end of BGSAVE for SYNC
redis-master | 19:C 07 Jun 2020 01:42:30.224 * DB saved on disk
redis-master | 19:C 07 Jun 2020 01:42:30.224 * RDB: 0 MB of memory used by copy-on-write
redis-master | 1:M 07 Jun 2020 01:42:30.250 * Background saving terminated with success
redis-master | 1:M 07 Jun 2020 01:42:30.256 * Synchronization with replica 192.168.240.1:6380 succeeded
redis-master | 1:M 07 Jun 2020 01:42:30.258 * Synchronization with replica 192.168.240.1:6381 succeeded
redis-slave-1 | 1:C 07 Jun 2020 01:42:29.633 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-slave-1 | 1:C 07 Jun 2020 01:42:29.633 # Redis version=6.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-slave-1 | 1:C 07 Jun 2020 01:42:29.633 # Configuration loaded
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.641 * Running mode=standalone, port=6380.
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.641 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.641 # Server initialized
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.641 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.644 * Ready to accept connections
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.645 * Connecting to MASTER 192.168.31.242:6379
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.645 * MASTER <-> REPLICA sync started
redis-slave-1 | 1:S 07 Jun 2020 01:42:29.647 * Non blocking connect for SYNC fired the event.
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.214 * Master replied to PING, replication can continue...
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.218 * Partial resynchronization not possible (no cached master)
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.221 * Full resync from master: f242fca3ad938609e70c192a0c492b4bfa97fc31:0
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.255 * MASTER <-> REPLICA sync: receiving 175 bytes from master to disk
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.470 * MASTER <-> REPLICA sync: Flushing old data
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.471 * MASTER <-> REPLICA sync: Loading DB in memory
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.476 * Loading RDB produced by version 6.0.4
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.476 * RDB age 0 seconds
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.476 * RDB memory usage when created 2.24 Mb
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.477 * MASTER <-> REPLICA sync: Finished with success
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.478 * Background append only file rewriting started by pid 21
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.510 * AOF rewrite child asks to stop sending diffs.
redis-slave-1 | 21:C 07 Jun 2020 01:42:30.510 * Parent agreed to stop sending diffs. Finalizing AOF...
redis-slave-1 | 21:C 07 Jun 2020 01:42:30.510 * Concatenating 0.00 MB of AOF diff received from parent.
redis-slave-1 | 21:C 07 Jun 2020 01:42:30.512 * SYNC append only file rewrite performed
redis-slave-1 | 21:C 07 Jun 2020 01:42:30.513 * AOF rewrite: 0 MB of memory used by copy-on-write
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.555 * Background AOF rewrite terminated with success
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.557 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
redis-slave-1 | 1:S 07 Jun 2020 01:42:30.559 * Background AOF rewrite finished successfully
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.122 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.122 # Redis version=6.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.122 # Configuration loaded
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.123 * Running mode=sentinel, port=26379.
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.123 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.130 # Sentinel ID is 1b9edaa4b9ef749ee8c12a10c10b65a2a34542a1
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:29.130 # +monitor master redismaster 192.168.31.242 6379 quorum 2
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:31.617 * +sentinel sentinel 3258fb06b016bbdeecd506e08b343284c918a276 192.168.240.5 26379 @ redismaster 192.168.31.242 6379
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:31.991 * +sentinel sentinel 96f68c8a1b158d081d3c1268d220e82c5c480abb 192.168.240.7 26379 @ redismaster 192.168.31.242 6379
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:40.318 * +slave slave 192.168.240.1:6380 192.168.240.1 6380 @ redismaster 192.168.31.242 6379
redis-sentinel-2 | 1:X 07 Jun 2020 01:42:40.325 * +slave slave 192.168.240.1:6381 192.168.240.1 6381 @ redismaster 192.168.31.242 6379
liumiaocn:redis liumiao$

Redis基础:哨兵模式相关推荐

  1. Redis(3)--哨兵模式,集群

    Redis的哨兵模式 什么是哨兵模式 Redis提供了哨兵的命令,哨兵是一个独立的进程,作为进程,它会独立运行.其原理是哨兵通过发送命令,等待Redis服务器响应,从而监控运行的多个Redis实例. ...

  2. Redis:哨兵模式(针对某一模块,数据量有限)

    Redis:哨兵模式(针对某一模块,数据量有限) 关键词 主从(读写分离,高新能),没有实现高可用 主从+哨兵:可以实现主从切换,实现高可用 哨兵检测(1s1ping),哨兵确认(接受回复,主观下线: ...

  3. ip地址转换数字函数 iton_redis深度剖析: 03 redis读写哨兵模式

    什么叫系统不可用: 什么是99.99高可用性: 高可用计算规则,全年 系统可用的时间 / 全年 redis不可用是什么? redis主从基于哨兵模式的高可用: 哨兵的主要功能: (1)集群监控,负责监 ...

  4. Redis的哨兵模式搭建

    Redis的哨兵模式搭建 1.Redis的哨兵模式 Redis的哨兵是反客为主的自动版,能够后台监控主机是否故障,如果故障了根据投票数自动将从库转换为主库.哨兵(sentinel) 是一个分布式系统, ...

  5. Redis之哨兵模式

    文章目录 Redis之哨兵模式 1.哨兵介绍 2.哨兵作用 3.哨兵相关配置 4.配置哨兵 5.演示(配置哨兵) 6.主从切换过程 7.阶段一监控阶段 8.阶段二通知阶段 9.阶段三故障转移阶段 Re ...

  6. redis的哨兵模式测试

    上篇文章我们说到,一主二从的模式,如果主机挂掉,从机等待主机连上之后,继续成为主机的slave. 但是这样会影响我们业务的正常运转呀,我们怎么来做呢? 目前的我的服务器: 192.128.116.12 ...

  7. docker+网桥+redis主从+哨兵模式

    docker+网桥+redis主从+哨兵模式 我是在两台服务器上实验的,一台服务器的ip是192.168.213.144,另一台服务器的ip是192.168.213.145 1. 搭建网桥 关于第一部 ...

  8. Redis主从复制哨兵模式自动切换

    Redis主从复制 1.概念 主从复制,是指将一台Redis服务器的数据复制到其他的redis服务器上.前者为主节点master,后者为从节点slave,数据的复制是单向的,由主节点复制到从节点(主节 ...

  9. redis sentinel哨兵模式集群搭建教程

    1.环境说明 我们将使用192.168.220.128.192.168.220.129两台机器搭建sentinel交叉主从为例 当前我们已在192.168.220.128上按redis安装教程安装了r ...

  10. 【redis】哨兵模式

    哨兵模式是redis高可用的一种解决方案. 哨兵必须用三个实例取保证自己的高可用,但是哨兵+主从模式是不能保证消息不丢失的. 为什么用三个来保证呢? 假设现在有两个服务器,第一台有redis主节点M1 ...

最新文章

  1. shell脚本逻辑判断,文件目录属性判断,if,case用法
  2. mysql dba系统学习(12)mysql的数据文件 mysql dba系统学习(13)mysql的体系结构
  3. 从零开始的 React 组件开发之路 (一):表格篇
  4. kotlin学习之函数(二)
  5. Windows终止进程
  6. C#中Abstract和Virtual的区别
  7. VirtualBox安装的Mac虚拟机,安装增强功能失败,应该是版本太新
  8. dpkg-buildpackage: error: debian/rules binary subprocess was killed by signal 2
  9. 用Python做一个游戏辅助脚本,完整编程思路分享!
  10. 第五章软件项目风险管理
  11. c语言向量乘法,运用C语言实现向量积
  12. 64位系统装32位计算机,32位的cpu能不能装64位系统|cpu是32位的可以装64位系统吗...
  13. UWP笔记-消息弹窗自动淡出
  14. easyui教程 php,jQuery EasyUI 教程-Panel(面板)
  15. Android生物识别
  16. Oracle11g数据库的下载与安装(Windows 10)
  17. python中exception方法_python中try except处理程序异常的三种常用方法
  18. Android win10 平板 省电,Win10平板模式省电吗?如何设置?
  19. 对账与清分、清算、结算
  20. Docker镜像报错:Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request cance

热门文章

  1. 人脸验证与识别——从模型训练到项目部署
  2. [bzoj3611][Heoi2014]大工程
  3. Word文档转换Markdown文档
  4. 【Maven】org.codehaus.plexus.component.repository.exception.ComponentLookupException
  5. 详解“==”和equals的区别
  6. Aiseesoft Mac Video Converter Ultimate for Mac(视频转换工具)
  7. 说一说ADI公司的DSP发展历程
  8. 2022-04-13 工作记录--LayUI-动态渲染数据表格的表头参数
  9. 运行tomcat7w.exe tomcat7.exe ,提示 指定的服务未安装 unable to open the service 'tomcat7'
  10. 那些堪称神器的PPT制作小工具