标签:区别 convert tin monitor err 还需 ica daemonize master
拷贝多个配置文件分别命名区分 redis{port}.conf
daemonize yes
pidfile
redis{port}.pidlogfile
redis{port}.logdbfilename
dump{port}.rdbredis-server redis{port}.conf ps -ef|grep redis|grep -v grep redis-cli -p {port}
info replication
# Replication role:master connected_slaves:0 master_replid:d3d1de9a393d82c4dc1787800471fffba1323b3a 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
Master
set k1 v1
set k2 v2
Slave1和Slave2
get k1
slaveof 127.0.0.1 6379
get k1
get k2
info replication
可以看到匹配的信息(error) READONLY You can‘t write against a read only replica.
info replication
slaveof 127.0.0.1 6379
进行数据同步replicaof 127.0.0.1 6379
slaveof 127.0.0.1 6380
info replication
slaveof no one
,让Slave1“反客为主”新的Master(role有Slave变成Master),这样就可以对其进行写操作,并和Slave2继续主从关系vi sentinel.conf
,内容:sentinel monitor master6379 127.0.0.1 6379 1
sentinel monitor ...
指示sentinel监听后面机器上的Mastermaster6379
给后面要监听的Master取个名字127.0.0.1 6379
监听目标Master服务的ip和端口redis-sentinel sentinel.conf 或者 redis-server sentinel.conf --sentinel
# Sentinel ID is 89568e210930ec9fe58e4cf856a5ef8e14501955 # +monitor master master6379 127.0.0.1 6379 quorum 1 * +slave slave 127.0.0.1:6380 127.0.0.1 6380 @ master6379 127.0.0.1 6379 * +slave slave 127.0.0.1:6381 127.0.0.1 6381 @ master6379 127.0.0.1 6379
# +sdown master master6379 127.0.0.1 6379 # +odown master master6379 127.0.0.1 6379 #quorum 1/1 # +new-epoch 1 # +try-failover master master6379 127.0.0.1 6379 # +vote-for-leader 89568e210930ec9fe58e4cf856a5ef8e14501955 1 # +elected-leader master master6379 127.0.0.1 6379 # +failover-state-select-slave master master6379 127.0.0.1 6379 # +selected-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ master6379 127.0.0.1 6379 * +failover-state-send-slaveof-noone slave 127.0.0.1:6380 127.0.0.1 6380 @ master6379 127.0.0.1 6379 * +failover-state-wait-promotion slave 127.0.0.1:6380 127.0.0.1 6380 @ master6379 127.0.0.1 6379 # +promoted-slave slave 127.0.0.1:6380 127.0.0.1 6380 @ master6379 127.0.0.1 6379 # +failover-state-reconf-slaves master master6379 127.0.0.1 6379 * +slave-reconf-sent slave 127.0.0.1:6381 127.0.0.1 6381 @ master6379 127.0.0.1 6379 * +slave-reconf-inprog slave 127.0.0.1:6381 127.0.0.1 6381 @ master6379 127.0.0.1 6379 * +slave-reconf-done slave 127.0.0.1:6381 127.0.0.1 6381 @ master6379 127.0.0.1 6379 # +failover-end master master6379 127.0.0.1 6379 # +switch-master master6379 127.0.0.1 6379 127.0.0.1 6380 * +slave slave 127.0.0.1:6381 127.0.0.1 6381 @ master6379 127.0.0.1 6380 * +slave slave 127.0.0.1:6379 127.0.0.1 6379 @ master6379 127.0.0.1 6380 # +sdown slave 127.0.0.1:6379 127.0.0.1 6379 @ master6379 127.0.0.1 6380
* +convert-to-slave slave 127.0.0.1:6379 127.0.0.1 6379 @ master6379 127.0.0.1 6380
标签:区别 convert tin monitor err 还需 ica daemonize master
原文地址:https://www.cnblogs.com/noodlerkun/p/11549842.html