【Redis】 1主2从3哨兵 介绍与部署:replicaof、replica-priority、masterauth、sentinel monitor、sentinel auth-pass

Spring Boot整合请参考本人博客:
《Spring Boot整合Redis 1主2从3哨兵—详细图文+代码,从新建项目开始手把手教学:redisTemplate》

一、概念介绍

1.1 主从复制

在这里插入图片描述

  • 主机数据更新后根据配置和策略, 自动同步到备机的master/slaver机制
  • Master以写为主,Slave以读为主
  • 读写分离,性能扩展
  • 容灾快速恢复

1.2 哨兵模式

在这里插入图片描述

  • 当主机挂掉,从机选举中产生新的主机
  • 故障恢复
    在这里插入图片描述
    1. 优先级在redis.conf中默认:slave-priority 100,值越小优先级越高
    2. 偏移量是指获得原主机数据最全的
    3. 每个redis实例启动后都会随机生成一个40位的runid

二、相关配置

2.1 主从复制

2.1.1 replicaof

  • replicaof
  • 从机配置主机信息

2.1.2 masterauth

  • masterauth
  • 从机配置主机密码

2.1.3 replica-priority

  • replica-priority 100
  • 从机竞争主机的优先级
  • 值越小优先级越高

2.1.4 slave-serve-stale-data

  • slave-serve-stale-data yes
  • yes:从服务器可以响应客户端请求
  • no:从服务器将阻塞所有请求,有客户端请求时返回“SYNC with master in progress”

2.1.5 replica-read-only

  • replica-read-only yes
  • 从节点是否只读

2.1.6 repl-diskless-sync

  • repl-diskless-sync no

  • 是否使用socket方式复制数据(无盘同步)?

    1. no:master创建新进程dump生成RDB文件,再由主进程将RDB文件发送给slaves

    2. yes:master创建新进程直接dump(转存) RDB至slave的网络socket,不经过主进程和硬盘

  • 推荐no,因为RDB文件创建后,可以同时传输给更多的slave。如果为yes, 新slave连接到master之后得逐个同步数据。

  • 只有当磁盘I/O较慢且网络较快时,可用diskless(yes),否则一般建议使用磁盘(no)

2.1.7 repl-diskless-sync-delay

  • repl-diskless-sync-delay 5
  • 该配置作用于全量复制阶段,当主节点使用diskless复制时(repl-diskless-sync yes)
  • 决定主节点向从节点发送之前停顿的时间,单位是秒
  • 之所以设置停顿时间,是基于以下两个考虑:
    1. 多个从节点有较大的概率在短时间内建立主从复制。可以在停顿时间内让新连接的slave进入队列等待一起进行数据传输
    2. socket传输一旦开始,新连接的slave只能等待当前数据传输结束,才能开始新的数据传输。

2.1.8 repl-diskless-load

  • repl-diskless-load disabled
  • 是否使用无磁盘加载,有三项:
    1. disabled:不要使用无磁盘加载,先将rdb文件存储到磁盘
    2. on-empty-db:只有在完全安全的情况下才使用无磁盘加载
    3. swapdb:解析时在RAM中保留当前db内容的副本,直接从套接字获取数据。

2.1.9 repl-disable-tcp-nodelay

  • repl-disable-tcp-nodelay no
  • 主从同步后,后续的同步是否设置成TCP_NODELAY ?
    1. yes:则redis会合并小的TCP包从而节省带宽,但会增加同步延迟(40ms),造成master与slave数据不一致
    2. no:则redis master会立即发送同步数据,没有延迟。

2.2 哨兵模式

2.2.1 port

  • port 26379
  • sentinel监听端口

2.2.2 sentinel monitor

  • sentinel monitor
  • 监听地址为ip:port的一个master。ip 要写真实的ip地址而不要用回环地址(127.0.0.1)
  • master-name可以自定义,只能包含英文字母,数字,和“.-_”这三个字符。
  • quorum是一个数字,指明当有多少个sentinel认为一个master失效时,master才算真正失效。

2.2.3 sentinel auth-pass

  • sentinel auth-pass
  • 设置连接master和slave时的密码
  • 不能分别为master和slave设置不同的密码,因此master和slave的密码应该设置相同

2.2.4 sentinel down-after-milliseconds

  • sentinel down-after-milliseconds
  • 失效多久,这个sentinel才会主观地认为master是不可用的。
  • 单位是毫秒,默认为30秒

2.2.5 sentinel parallel-syncs

  • sentinel parallel-syncs
  • 在发生failover主备切换时,最多有多少个slave同时对新的master进行同步
  • 数字越小failover所需的时间就越长。
  • 数字越大,就意味着越多的slave因为replication而不可用

2.2.6 sentinel failover-timeout

  • sentinel failover-timeout
  • 同一个sentinel对同一个master两次failover之间的间隔时间
  • 当想要取消一个正在进行的failover所需要的时间。
  • 当一个slave从一个错误的master那里同步数据开始计算时间。直到slave被纠正为向正确的master那里同步数据时。
  • 当进行failover时,配置所有slaves指向新的master所需的最大时间。不过,即使过了这个超时,slaves依然会被正确配置为指向master,但是就不按parallel-syncs所配置的规则来了。

2.2.7 sentinel notification-script

  • sentinel notification-script

  • 通知型脚本:当sentinel有任何警告级别的事件发生时(比如说redis实例的主观失效和客观失效等等),将会去调用这个脚本。

  • 这时这个脚本应该通过邮件,SMS等方式去通知系统管理员关于系统不正常运行的信息。

  • 调用该脚本时,将传给脚本两个参数,一个是事件的类型,一个是事件的描述。

  • 如果sentinel.conf配置文件中配置了这个脚本路径,那么必须保证这个脚本存在于这个路径,并且是可执行的,否则sentinel无法正常启动成功。

  • 脚本规则

    - 若脚本执行后返回1,那么该脚本稍后将会被再次执行,重复次数目前默认为10
    
    - 若脚本执行后返回2,或者比2更高的一个返回值,脚本将不会重复执行。
    
    - 如果脚本在执行过程中由于收到系统中断信号被终止了,则同返回值为1时的行为相同。
    
    - 一个脚本的最大执行时间为60s,如果超过这个时间,脚本将会被一个SIGKILL信号终止,之后重新执行。
    

2.2.8 sentinel client-reconfig-script

  • sentinel client-reconfig-script

  • 当一个master由于failover而发生改变时,这个脚本将会被调用,通知相关的客户端关于master地址已经发生改变的信息。

  • 以下参数将会在调用脚本时传给脚本:

    <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
    
    目前总是“failover”, 是“leader”或者“observer”中的一个。 
    参数 from-ip, from-port, to-ip, to-port是用来和旧的master和新的master(即旧的slave)通信的。这个脚本应该是通用的,能被多次调用,不是针对性的。
    
  • 脚本规则

    - 若脚本执行后返回1,那么该脚本稍后将会被再次执行,重复次数目前默认为10
    
    - 若脚本执行后返回2,或者比2更高的一个返回值,脚本将不会重复执行。
    
    - 如果脚本在执行过程中由于收到系统中断信号被终止了,则同返回值为1时的行为相同。
    
    - 一个脚本的最大执行时间为60s,如果超过这个时间,脚本将会被一个SIGKILL信号终止,之后重新执行。
    

三、实验操作

3.1 实验介绍

  • 搭建一主二从三哨兵的实验的环境
  • 同一服务器下不同端口
    1. 192.168.100.103:6379:主机
    2. 192.168.100.103:6380:从机
    3. 192.168.100.103:6381:从机
    4. 192.168.100.103:26379:哨兵
    5. 192.168.100.103:26380:哨兵
    6. 192.168.100.103:26381:哨兵

3.2 环境搭建

3.2.1 创建配置文件

[root@demo03 replication]# cd /opt/myredis/replication/
[root@demo03 replication]# ll
总用量 116
-rw-r--r--. 1 root root   135 823 17:34 redis_6379.conf
-rw-r--r--. 1 root root   166 823 17:34 redis_6380.conf
-rw-r--r--. 1 root root   166 823 17:35 redis_6381.conf
-rw-r--r--. 1 root root 92244 823 15:42 redis.conf
-rw-r--r--. 1 root root    95 823 17:35 sentinel_26379.conf
-rw-r--r--. 1 root root   109 823 17:37 sentinel_26380.conf
-rw-r--r--. 1 root root   109 823 17:38 sentinel_26381.conf


3.2.2 redis_6379.conf

[root@demo03 replication]# vim redis_6379.conf 

  1 include /opt/myredis/replication/redis.conf
  2 pidfile "/var/run/redis_6379.pid"
  3 port 6379
  4 dbfilename "dump_6379.rdb"
  5 masterauth "123456"

3.2.3 redis_6380.conf

[root@demo03 replication]# vim redis_6380.conf 

  1 include /opt/myredis/replication/redis.conf
  2 pidfile "/var/run/redis_6380.pid"
  3 port 6380
  4 dbfilename "dump_6380.rdb"
  5 masterauth "123456"
  6 replicaof 192.168.100.103 6379

3.2.4 redis_6381.conf

[root@demo03 replication]# vim redis_6381.conf 

  1 include /opt/myredis/replication/redis.conf
  2 pidfile "/var/run/redis_6381.pid"
  3 port 6381
  4 dbfilename "dump_6381.rdb"
  5 masterauth "123456"
  6 replicaof 192.168.100.103 6379

3.2.5 sentinel_26379.conf

[root@demo03 replication]# vim sentinel_26379.conf 

  1 sentinel monitor mymaster 192.168.100.103 6379 2
  2 sentinel auth-pass mymaster 123456
  3 port 26379
  

3.2.5 sentinel_26380.conf

[root@demo03 replication]# vim sentinel_26380.conf 

  1 sentinel monitor mymaster 192.168.100.103 6379 2
  2 sentinel auth-pass mymaster 123456
  3 port 26380
  4 daemonize yes

3.2.5 sentinel_26381.conf

[root@demo03 replication]# vim sentinel_26381.conf 

  1 sentinel monitor mymaster 192.168.100.103 6379 2
  2 sentinel auth-pass mymaster 123456
  3 port 26381
  4 daemonize yes
  

3.2.6 注意

  • /opt/myredis/replication/redis.conf:在redis初始配置文件的基础上将bind注释掉,dir /opt/myredis,requirepass 123456。
  • 主从密码必须一致:因为哨兵配置sentinel auth-pass mymaster不能分别为master和slave设置不同的密码
  • 主机和从机都需要设置:masterauth “123456”。因为主机和从机可能随时切换,如果主机没有此配置,当主机切换为从机时将无法连接上当前主机

3.3 效果演示

3.3.1 启动服务

[root@demo03 replication]# redis-server redis_6379.conf 
[root@demo03 replication]# redis-server redis_6380.conf 
[root@demo03 replication]# redis-server redis_6381.conf 
[root@demo03 replication]# redis-sentinel sentinel_26380.conf 
[root@demo03 replication]# redis-sentinel sentinel_26381.conf 
[root@demo03 replication]# redis-sentinel sentinel_26379.conf 
4922:X 23 Aug 2022 17:44:39.552 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4922:X 23 Aug 2022 17:44:39.552 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=4922, just started
4922:X 23 Aug 2022 17:44:39.552 # Configuration loaded
4922:X 23 Aug 2022 17:44:39.553 * Increased maximum number of open files to 10032 (it was originally set to 1024).
4922:X 23 Aug 2022 17:44:39.553 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.1 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379
 |    `-._   `._    /     _.-'    |     PID: 4922
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

4922:X 23 Aug 2022 17:44:39.553 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4922:X 23 Aug 2022 17:44:39.556 # Sentinel ID is f671603a46c2b046ee98f604f1960f4cb22f3e38
4922:X 23 Aug 2022 17:44:39.556 # +monitor master mymaster 192.168.100.103 6379 quorum 2
4922:X 23 Aug 2022 17:44:39.557 * +slave slave 192.168.100.103:6380 192.168.100.103 6380 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:44:39.559 * +slave slave 192.168.100.103:6381 192.168.100.103 6381 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:44:39.630 * +sentinel sentinel f7cb42a7bec5f23e7bcad33382d2e7320fca8b3e 192.168.100.103 26381 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:44:40.564 * +sentinel sentinel e6799ccb2f9163e3f4c12ede5887197fce0c969a 192.168.100.103 26380 @ mymaster 192.168.100.103 6379


3.3.2 进程显示

[root@demo03 replication]# ps aux | grep redis
root       4876  0.3  0.3 165100  9676 ?        Ssl  17:44   0:00 redis-server *:6379
root       4882  0.3  0.3 240880  9720 ?        Ssl  17:44   0:00 redis-server *:6380
root       4890  0.3  0.3 165100  9708 ?        Ssl  17:44   0:00 redis-server *:6381
root       4911  0.5  0.3 162540 10060 ?        Ssl  17:44   0:00 redis-sentinel *:26380 [sentinel]
root       4917  2.0  0.3 162540 10200 ?        Ssl  17:44   0:00 redis-sentinel *:26381 [sentinel]
root       4922  0.6  0.3 162540 10580 pts/0    Sl+  17:44   0:00 redis-sentinel *:26379 [sentinel]
root       4928  0.0  0.0 112824   984 pts/4    R+   17:45   0:00 grep --color=auto redis


3.3.3 查看信息

  • 26379 客户端
[root@demo03 replication]# redis-cli -p 26379
127.0.0.1:26379> info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=192.168.100.103:6379,slaves=2,sentinels=3
  • 6379 客户端
[root@demo03 replication]# redis-cli -p 6379 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.100.103,port=6380,state=online,offset=22825,lag=1
slave1:ip=192.168.100.103,port=6381,state=online,offset=22680,lag=1
master_failover_state:no-failover
master_replid:5b31739e3245dfada59630aa9ddf1cf8f28d503d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:22825
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:22825

3.3.4 挂掉6379

  • 命令
127.0.0.1:6379> shutdown
not connected> 

  • 哨兵消息:选择6380为新的主节点
[root@demo03 replication]# redis-sentinel sentinel_26379.conf 
4922:X 23 Aug 2022 17:44:39.552 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4922:X 23 Aug 2022 17:44:39.552 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=4922, just started
4922:X 23 Aug 2022 17:44:39.552 # Configuration loaded
4922:X 23 Aug 2022 17:44:39.553 * Increased maximum number of open files to 10032 (it was originally set to 1024).
4922:X 23 Aug 2022 17:44:39.553 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.1 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379
 |    `-._   `._    /     _.-'    |     PID: 4922
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

4922:X 23 Aug 2022 17:44:39.553 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4922:X 23 Aug 2022 17:44:39.556 # Sentinel ID is f671603a46c2b046ee98f604f1960f4cb22f3e38
4922:X 23 Aug 2022 17:44:39.556 # +monitor master mymaster 192.168.100.103 6379 quorum 2
4922:X 23 Aug 2022 17:44:39.557 * +slave slave 192.168.100.103:6380 192.168.100.103 6380 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:44:39.559 * +slave slave 192.168.100.103:6381 192.168.100.103 6381 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:44:39.630 * +sentinel sentinel f7cb42a7bec5f23e7bcad33382d2e7320fca8b3e 192.168.100.103 26381 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:44:40.564 * +sentinel sentinel e6799ccb2f9163e3f4c12ede5887197fce0c969a 192.168.100.103 26380 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:47:21.217 # +sdown master mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:47:21.279 # +new-epoch 1
4922:X 23 Aug 2022 17:47:21.374 # +vote-for-leader e6799ccb2f9163e3f4c12ede5887197fce0c969a 1
4922:X 23 Aug 2022 17:47:21.375 # +odown master mymaster 192.168.100.103 6379 #quorum 3/2
4922:X 23 Aug 2022 17:47:21.375 # Next failover delay: I will not start a failover before Tue Aug 23 17:53:21 2022
4922:X 23 Aug 2022 17:47:22.036 # +config-update-from sentinel e6799ccb2f9163e3f4c12ede5887197fce0c969a 192.168.100.103 26380 @ mymaster 192.168.100.103 6379
4922:X 23 Aug 2022 17:47:22.036 # +switch-master mymaster 192.168.100.103 6379 192.168.100.103 6380
4922:X 23 Aug 2022 17:47:22.036 * +slave slave 192.168.100.103:6381 192.168.100.103 6381 @ mymaster 192.168.100.103 6380
4922:X 23 Aug 2022 17:47:22.036 * +slave slave 192.168.100.103:6379 192.168.100.103 6379 @ mymaster 192.168.100.103 6380

  • 重启6379,查看6380信息
[root@demo03 replication]# redis-server redis_6379.conf 
[root@demo03 replication]# redis-cli -p 6379 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> info replication
# Replication
role:slave
master_host:192.168.100.103
master_port:6380
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_repl_offset:58779
slave_priority:100
slave_read_only:1
connected_slaves:0
master_failover_state:no-failover
master_replid:55d7b9dac442d53a18b96063cbdc2997340b706c
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:58779
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:55408
repl_backlog_histlen:3372
127.0.0.1:6379> 

3.3.5 查看被重写的配置文件

  • redis_6379.conf
[root@demo03 replication]# vim redis_6379.conf 

  1 include /opt/myredis/replication/redis.conf
  2 pidfile "/var/run/redis_6379.pid"
  3 port 6379
  4 dbfilename "dump_6379.rdb"
  5 masterauth "123456"
  6 # Generated by CONFIG REWRITE
  7 daemonize yes
  8 requirepass "123456"
  9 save 3600 1
 10 save 300 100
 11 save 60 10000
 12 user default on #8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92 ~* &* +@all
 13 dir "/opt/myredis/replication"
 14 replicaof 192.168.100.103 6380

  • redis_6380.conf
[root@demo03 replication]# vim redis_6380.conf 

  1 include /opt/myredis/replication/redis.conf
  2 pidfile "/var/run/redis_6380.pid"
  3 port 6380
  4 dbfilename "dump_6380.rdb"
  5 masterauth "123456"
  6 
  7 # Generated by CONFIG REWRITE
  8 daemonize yes
  9 requirepass "123456"
 10 save 3600 1
 11 save 300 100
 12 save 60 10000
 13 user default on #8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92 ~* &* +@all
 14 dir "/opt/myredis/replication"

  • redis_6381.conf
[root@demo03 replication]# vim redis_6381.conf 

  1 include /opt/myredis/replication/redis.conf
  2 pidfile "/var/run/redis_6381.pid"
  3 port 6381
  4 dbfilename "dump_6381.rdb"
  5 masterauth "123456"
  6 replicaof 192.168.100.103 6380
  7 # Generated by CONFIG REWRITE
  8 daemonize yes
  9 requirepass "123456"
 10 save 3600 1
 11 save 300 100
 12 save 60 10000
 13 user default on #8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92 ~* &* +@all
 14 dir "/opt/myredis/replication"
  • redis_26379.conf
[root@demo03 replication]# vim sentinel_26379.conf 

  1 sentinel monitor mymaster 192.168.100.103 6380 2
  2 sentinel auth-pass mymaster 123456
  3 port 26379
  4 # Generated by CONFIG REWRITE
  5 protected-mode no
  6 user default on nopass ~* &* +@all
  7 dir "/opt/myredis/replication"
  8 sentinel myid f671603a46c2b046ee98f604f1960f4cb22f3e38
  9 sentinel config-epoch mymaster 1
 10 sentinel leader-epoch mymaster 1
 11 sentinel current-epoch 1
 12 sentinel known-replica mymaster 192.168.100.103 6379
 13 sentinel known-replica mymaster 192.168.100.103 6381
 14 sentinel known-sentinel mymaster 192.168.100.103 26380 e6799ccb2f9163e3f4c12ede5887197fce0c969a
 15 sentinel known-sentinel mymaster 192.168.100.103 26381 f7cb42a7bec5f23e7bcad33382d2e7320fca8b3e
  • redis_26380.conf
[root@demo03 replication]# vim sentinel_26380.conf 

  1 sentinel monitor mymaster 192.168.100.103 6380 2
  2 sentinel auth-pass mymaster 123456
  3 port 26380
  4 daemonize yes
  5 # Generated by CONFIG REWRITE
  6 protected-mode no
  7 pidfile "/var/run/redis.pid"
  8 user default on nopass ~* &* +@all
  9 dir "/opt/myredis/replication"
 10 sentinel myid e6799ccb2f9163e3f4c12ede5887197fce0c969a
 11 sentinel config-epoch mymaster 1
 12 sentinel leader-epoch mymaster 1
 13 sentinel current-epoch 1
 14 sentinel known-replica mymaster 192.168.100.103 6379
 15 sentinel known-replica mymaster 192.168.100.103 6381
 16 sentinel known-sentinel mymaster 192.168.100.103 26379 f671603a46c2b046ee98f604f1960f4cb22f3e38
 17 sentinel known-sentinel mymaster 192.168.100.103 26381 f7cb42a7bec5f23e7bcad33382d2e7320fca8b3e
  • redis_26381.conf
[root@demo03 replication]# vim sentinel_26381.conf 

  1 sentinel monitor mymaster 192.168.100.103 6380 2
  2 sentinel auth-pass mymaster 123456
  3 port 26381
  4 daemonize yes
  5 # Generated by CONFIG REWRITE
  6 protected-mode no
  7 pidfile "/var/run/redis.pid"
  8 user default on nopass ~* &* +@all
  9 dir "/opt/myredis/replication"
 10 sentinel myid f7cb42a7bec5f23e7bcad33382d2e7320fca8b3e
 11 sentinel config-epoch mymaster 1
 12 sentinel leader-epoch mymaster 1
 13 sentinel current-epoch 1
 14 sentinel known-replica mymaster 192.168.100.103 6379
 15 sentinel known-replica mymaster 192.168.100.103 6381
 16 sentinel known-sentinel mymaster 192.168.100.103 26379 f671603a46c2b046ee98f604f1960f4cb22f3e38
 17 sentinel known-sentinel mymaster 192.168.100.103 26380 e6799ccb2f9163e3f4c12ede5887197fce0c969a

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

愿你满腹经纶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值