Redis 8. redis的复制(Master/Slave)

Redis

@Author:hanguixian
@Email:[email protected]

八 Redis的复制(Master/Slave)

1 是什么

  • 官网
    • 英文:https://redis.io/topics/replication
    • 中文:http://www.redis.cn/topics/replication.html
  • 就是我们所说的主从复制,主机数据更新后根据配置和策略,自动同步到备机的master/slaver机制,Master以写为主,Slave以读为主

2 能干嘛

  • 读写分离
  • 容灾恢复

3 使用

  • 配从(库)不配主(库)
  • 从库配置:slaveof 主库IP 主库端口
    • 每次与master断开之后,都需要重新连接,除非你配置进redis.conf文件
    • info replication
  • 修改配置文件细节操作
    • 拷贝多个redis.conf文件
    • 开启daemonize yes
    • pid文件名字
    • 指定端口
    • log文件名字
    • dump.rdb名字
pidfile /var/run/redis_6380.pid
port 6380
logfile "6380.log"
dbfilename dump6380.rdb
appendfilename "appendonly6380.aof"
  • 三种方式
    • 一主二仆
      • 一个Master两个Slave
      • 日志查看
        • 主机日志
        • 备机日志
        • info replication
    • 薪火相传
      • 上一个Slave可以是下一个slave的Master,Slave同样可以接收其他slaves的连接和同步请求,那么该slave作为了链条中下一个的master,可以有效减轻master的写压力
      • 中途变更转向:会清除之前的数据,重新建立拷贝最新的
      • slaveof 新主库IP 新主库端口
    • 反客为主
      • SLAVEOF no one
        • 使当前数据库停止与其他数据库的同步,转成主数据库

4 示例

4.1 一主二仆

##端口:6379##
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_6379.conf 
[root@xxxmmm bin]# redis-cli -p 6379
127.0.0.1:6379> info replication
# Replication
##############启动起来是master################################
role:master
connected_slaves:0
master_replid:d33a8a6e37b2f0ca28ab7557c12acc8bf1d58751
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6379> KEYS *
(empty list or set)
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> set k2 v2
OK
127.0.0.1:6379> info replication
# Replication
role:master
###################配置了两个从库#######################################
connected_slaves:2
slave0:ip=127.0.0.1,port=6380,state=online,offset=70,lag=0
slave1:ip=127.0.0.1,port=6381,state=online,offset=70,lag=1
master_replid:458473b6141ebd0012dd6698913afe6be6b75c7d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:70
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:70
127.0.0.1:6379> set k3 v3
OK
127.0.0.1:6379> SHUTDOWN
not connected> exit
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_6379.conf 
[root@xxxmmm bin]# redis-cli -p 6379
127.0.0.1:6379> keys *
1) "k1"
2) "k3"
3) "k2"
127.0.0.1:6379> set k4 v4
OK
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6381,state=online,offset=192,lag=1
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:192
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:192

###############################################################################
###端口:6380###
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_6380.conf 
[root@xxxmmm bin]# redis-cli -p 6380
127.0.0.1:6380> info replication
# Replication
role:master
###############启动起来都是master###############################
connected_slaves:0
master_replid:b25d2d448e71cce4aba5168560f874715be8e67c
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6380> keys *
(empty list or set)
####################从库配置######################################
127.0.0.1:6380> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6380> info replication
# Replication
####################从库配置后变成了slave##########################
role:slave
master_host:127.0.0.1
master_port:6379
#########################连接状态up#################################
master_link_status:up
master_last_io_seconds_ago:2
master_sync_in_progress:0
slave_repl_offset:14
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:458473b6141ebd0012dd6698913afe6be6b75c7d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:14
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:14
127.0.0.1:6380> keys *
1) "k1"
2) "k2"
127.0.0.1:6380> keys *
1) "k3"
2) "k1"
3) "k2"
#####################从库默认不可写#####################################
127.0.0.1:6380> set k666 v666
(error) READONLY You can't write against a read only replica.
127.0.0.1:6380> info replication
# Replication
###################主库挂了后,salve没有变成master#######################
role:slave
master_host:127.0.0.1
master_port:6379
#######################主库挂了后,连接断开################################
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:276
master_link_down_since_seconds:9
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:458473b6141ebd0012dd6698913afe6be6b75c7d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:276
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:276
127.0.0.1:6380> keys *
1) "k3"
2) "k1"
3) "k2"
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
##################主库重新启动后,连接状态up########################################
master_link_status:up
master_last_io_seconds_ago:7
master_sync_in_progress:0
slave_repl_offset:14
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:14
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:14
127.0.0.1:6380> keys *
1) "k3"
2) "k4"
3) "k1"
4) "k2"
127.0.0.1:6380> SHUTDOWN
not connected> exit
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_6380.conf 
[root@xxxmmm bin]# redis-cli -p 6380
127.0.0.1:6380> keys *
1) "k4"
2) "k2"
3) "k1"
4) "k3"
127.0.0.1:6380> info replication
# Replication
##################从库断开重连后,变成了master########################
role:master
connected_slaves:0
master_replid:97e8893dcd75b4a4a0af650dd09a13a37b8f6923
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
########################需要重新配置##################################
127.0.0.1:6380> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6380> keys *
1) "k2"
2) "k1"
3) "k4"
4) "k3"


##########################################################################
###端口:6381###
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_6381.conf 
[root@xxxmmm bin]# redis-cli -p 6381
127.0.0.1:6381> KEYS *
(empty list or set)
127.0.0.1:6381> info repalication
127.0.0.1:6381> info replication
# Replication
role:master
connected_slaves:0
master_replid:d1d3fc86699f0947975c1d7986c95e0d3a846602
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6381> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6381> keys *
1) "k1"
2) "k2"
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:276
master_link_down_since_seconds:20
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:458473b6141ebd0012dd6698913afe6be6b75c7d
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:276
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:57
repl_backlog_histlen:220
127.0.0.1:6381> keys *
1) "k1"
2) "k4"
3) "k2"

##########################################################################
###端口查看###
[root@xxxmmm bin]# ps -ef|grep redis
root     17162     1  0 21:59 ?        00:00:00 redis-server 127.0.0.1:6379
root     17171 17116  0 22:00 pts/0    00:00:00 redis-cli -p 6379
root     17248     1  0 22:07 ?        00:00:00 redis-server 127.0.0.1:6380
root     17252 17174  0 22:07 pts/1    00:00:00 redis-cli -p 6380
root     17254     1  0 22:07 ?        00:00:00 redis-server 127.0.0.1:6381
root     17258 17222  0 22:08 pts/2    00:00:00 redis-cli -p 6381
root     17290 17261  0 22:10 pts/3    00:00:00 grep --color=auto redis

4.2 薪火相传

###################端口:6379##########################
[root@xxxmmm bin]# redis-cli -p 6379
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=127.0.0.1,port=6381,state=online,offset=119626,lag=0
slave1:ip=127.0.0.1,port=6380,state=online,offset=119626,lag=1
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:119626
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:119626
127.0.0.1:6379> set kuu vuu
OK
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6380,state=online,offset=120030,lag=1
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:120030
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:120030

###################端口:6380##########################
[root@xxxmmm bin]# redis-cli -p 6380
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_repl_offset:119710
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:119710
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:221
repl_backlog_histlen:119490
127.0.0.1:6380> keys *
1) "k2"
2) "k1"
3) "k4"
4) "k3"
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:119850
slave_priority:100
slave_read_only:1
connected_slaves:1
slave0:ip=127.0.0.1,port=6381,state=online,offset=119850,lag=1
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:119850
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:221
repl_backlog_histlen:119630
127.0.0.1:6380> keys *
1) "k2"
2) "k1"
3) "k4"
4) "k3"
127.0.0.1:6380> set km vm11
(error) READONLY You can't write against a read only replica.
127.0.0.1:6380> keys *
1) "k4"
2) "k1"
3) "k2"
4) "kuu"
5) "k3"

###################端口:6381##########################
[root@xxxmmm bin]# redis-cli -p 6381
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:3
master_sync_in_progress:0
slave_repl_offset:119780
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:119780
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:119780
127.0.0.1:6381> keys *
1) "k1"
2) "k4"
3) "k2"
4) "k3"
127.0.0.1:6381> SLAVEOF 127.0.0.1 6380
OK
127.0.0.1:6381> keys *
1) "k1"
2) "k4"
3) "k2"
4) "k3"
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6380
master_link_status:up
master_last_io_seconds_ago:8
master_sync_in_progress:0
slave_repl_offset:119836
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:119836
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:119836
127.0.0.1:6381> keys *
1) "k3"
2) "k2"
3) "k4"
4) "k1"
5) "kuu"

4.3 反客为主

#################端口:6379########################################
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6380,state=online,offset=120030,lag=1
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:120030
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:120030
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:0
master_replid:568ced83b66508a1bd5ab472ea60a81242f3141e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:120744
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:120744

#################端口:6380########################################
127.0.0.1:6380> SLAVEOF no one
OK
127.0.0.1:6380> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6381,state=online,offset=120786,lag=1
master_replid:d411a5594443b42429ae25d38c3269e28c743d27
master_replid2:568ced83b66508a1bd5ab472ea60a81242f3141e
master_repl_offset:120786
second_repl_offset:120745
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:221
repl_backlog_histlen:120566
127.0.0.1:6380> keys *
1) "k4"
2) "k1"
3) "k2"
4) "kuu"
5) "k3"
###############端口:6381########################################
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6380
master_link_status:up
master_last_io_seconds_ago:2
master_sync_in_progress:0
slave_repl_offset:120842
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:d411a5594443b42429ae25d38c3269e28c743d27
master_replid2:568ced83b66508a1bd5ab472ea60a81242f3141e
master_repl_offset:120842
second_repl_offset:120745
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:120842

5 复制原理

  • slave启动成功连接到master后会发送一个sync命令
  • Master接到命令启动后台的存盘进程,同时收集所有接收到的用于修改数据集命令,在后台进程执行完毕之后,master将传送整个数据文件到slave,以完成一次完全同步
  • 全量复制:而slave服务在接收到数据库文件数据后,将其存盘并加载到内存中。
  • 增量复制:Master继续将新的所有收集到的修改命令依次传给slave,完成同步
  • 但是只要是重新连接master,一次完全同步(全量复制)将被自动执行

6 哨兵模式(sentinel)

6.1 是什么

  • 反客为主的自动版,能够后台监控主机是否故障,如果故障了根据投票数自动将从库转换为主库

6.2 使用

  • 1 调整结构,6379带着80、81
  • 2 自定义的/myredis目录下新建sentinel.conf文件,名字绝不能错
  • 3 配置哨兵,填写内容
    • sentinel monitor 被监控数据库名字(自己起名字) 127.0.0.1 6379 1
    • 上面最后一个数字1,表示主机挂掉后salve投票看让谁接替成为主机,得票数多少后成为主机
  • 4 启动哨兵
    • redis-sentinel /myredis/sentinel.conf
####端口:6379###
[root@xxxmmm bin]# redis-cli -p 6379
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=127.0.0.1,port=6381,state=online,offset=120814,lag=0
slave1:ip=127.0.0.1,port=6380,state=online,offset=120814,lag=1
master_replid:75a7031ef8688d571732a359971c32ccbe8cccbe
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:120814
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:120745
repl_backlog_histlen:70
127.0.0.1:6379> SHUTDOWN
not connected> exit
[root@xxxmmm bin]# ps -ef|grep redis
root     17254     1  0 Dec10 ?        00:02:18 redis-server 127.0.0.1:6381
root     17338     1  0 Dec10 ?        00:02:16 redis-server 127.0.0.1:6380
root     20022 20004  0 22:39 pts/1    00:00:00 redis-cli -p 6380
root     20042 20025  0 22:39 pts/2    00:00:00 redis-cli -p 6381
root     20075 20054  0 22:44 pts/3    00:00:00 redis-sentinel *:26379 [sentinel]
root     20082 19980  0 22:46 pts/0    00:00:00 grep --color=auto redis
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_63
redis_6379.conf  redis_6380.conf  redis_6381.conf  
[root@xxxmmm bin]# redis-server /hanguixian/myredis/redis_6379.conf 
[root@xxxmmm bin]# redis-cli -p 6379
127.0.0.1:6379> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6381
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_repl_offset:191974
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:989c58ab7281d1858cb244f0e12ea18f50c8e3cd
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:191974
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:189945
repl_backlog_histlen:2030

###############端口:6380#####################
127.0.0.1:6380> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_repl_offset:120800
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:75a7031ef8688d571732a359971c32ccbe8cccbe
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:120800
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:120801
repl_backlog_histlen:0
127.0.0.1:6380> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6381
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:126927
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:989c58ab7281d1858cb244f0e12ea18f50c8e3cd
master_replid2:75a7031ef8688d571732a359971c32ccbe8cccbe
master_repl_offset:126927
second_repl_offset:123836
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:120801
repl_backlog_histlen:6127

######################端口:6381######################################
127.0.0.1:6381> SLAVEOF 127.0.0.1 6379
OK
127.0.0.1:6381> info replication
# Replication
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:120758
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:75a7031ef8688d571732a359971c32ccbe8cccbe
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:120758
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:120745
repl_backlog_histlen:14
127.0.0.1:6381> KEYS *
1) "k2"
2) "k3"
3) "k4"
4) "k1"
5) "kuu"
127.0.0.1:6381> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=127.0.0.1,port=6380,state=online,offset=127320,lag=1
master_replid:989c58ab7281d1858cb244f0e12ea18f50c8e3cd
master_replid2:75a7031ef8688d571732a359971c32ccbe8cccbe
master_repl_offset:127320
second_repl_offset:123836
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:120745
repl_backlog_histlen:6576
###############编写:sentinel.conf####################################
sentinel monitor my6379 127.0.0.1 6379 1
##################运行###############################################
[root@xxxmmm bin]# redis-sentinel /hanguixian/myredis/sentinel.conf 
20075:X 12 Dec 2018 22:44:52.701 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
20075:X 12 Dec 2018 22:44:52.701 # Redis version=5.0.0, bits=64, commit=00000000, modified=0, pid=20075, just started
20075:X 12 Dec 2018 22:44:52.701 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.0 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26379
 |    `-._   `._    /     _.-'    |     PID: 20075
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

20075:X 12 Dec 2018 22:44:52.703 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
20075:X 12 Dec 2018 22:44:52.728 # Sentinel ID is 26709d9a12e01632f557b0310533f3fc8806e57c
20075:X 12 Dec 2018 22:44:52.728 # +monitor master my6379 127.0.0.1 6379 quorum 1
20075:X 12 Dec 2018 22:44:52.729 * +slave slave 127.0.0.1:6381 127.0.0.1 6381 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:44:52.748 * +slave slave 127.0.0.1:6380 127.0.0.1 6380 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.764 # +sdown master my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.764 # +odown master my6379 127.0.0.1 6379 #quorum 1/1
20075:X 12 Dec 2018 22:46:04.764 # +new-epoch 1
20075:X 12 Dec 2018 22:46:04.764 # +try-failover master my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.793 # +vote-for-leader 26709d9a12e01632f557b0310533f3fc8806e57c 1
20075:X 12 Dec 2018 22:46:04.793 # +elected-leader master my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.793 # +failover-state-select-slave master my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.855 # +selected-slave slave 127.0.0.1:6381 127.0.0.1 6381 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.855 * +failover-state-send-slaveof-noone slave 127.0.0.1:6381 127.0.0.1 6381 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:04.917 * +failover-state-wait-promotion slave 127.0.0.1:6381 127.0.0.1 6381 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:05.915 # +promoted-slave slave 127.0.0.1:6381 127.0.0.1 6381 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:05.915 # +failover-state-reconf-slaves master my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:05.970 * +slave-reconf-sent slave 127.0.0.1:6380 127.0.0.1 6380 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:06.909 * +slave-reconf-inprog slave 127.0.0.1:6380 127.0.0.1 6380 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:06.909 * +slave-reconf-done slave 127.0.0.1:6380 127.0.0.1 6380 @ my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:06.974 # +failover-end master my6379 127.0.0.1 6379
20075:X 12 Dec 2018 22:46:06.974 # +switch-master my6379 127.0.0.1 6379 127.0.0.1 6381
20075:X 12 Dec 2018 22:46:06.974 * +slave slave 127.0.0.1:6380 127.0.0.1 6380 @ my6379 127.0.0.1 6381
20075:X 12 Dec 2018 22:46:06.974 * +slave slave 127.0.0.1:6379 127.0.0.1 6379 @ my6379 127.0.0.1 6381
20075:X 12 Dec 2018 22:46:36.998 # +sdown slave 127.0.0.1:6379 127.0.0.1 6379 @ my6379 127.0.0.1 6381
20075:X 12 Dec 2018 23:02:41.759 # -sdown slave 127.0.0.1:6379 127.0.0.1 6379 @ my6379 127.0.0.1 6381
20075:X 12 Dec 2018 23:02:51.689 * +convert-to-slave slave 127.0.0.1:6379 127.0.0.1 6379 @ my6379 127.0.0.1 6381

###########################再次查看sentinel.conf##########################################
sentinel myid 26709d9a12e01632f557b0310533f3fc8806e57c
# Generated by CONFIG REWRITE
port 26379
dir "/usr/local/bin"
sentinel deny-scripts-reconfig yes
sentinel monitor my6379 127.0.0.1 6381 1
sentinel config-epoch my6379 1
sentinel leader-epoch my6379 1
sentinel known-replica my6379 127.0.0.1 6379
sentinel known-replica my6379 127.0.0.1 6380
sentinel current-epoch 1

你可能感兴趣的:(redis,redis,NoSql)