sentinel发起failover命令
sentinelFailoverStateMachine
sentinelFailoverSelectSlave
日志:
2837:X 27 Jul 2020 10:45:09.636 # +selected-slave slave 192.168.27.128:6479 192.168.27.128 6479 @ mymaster 192.168.27.128 6379
2837:X 27 Jul 2020 10:45:09.636 * +failover-state-send-slaveof-noone slave 192.168.27.128:6479 192.168.27.128 6479 @ mymaster 192.168.27.128 6379
2837:X 27 Jul 2020 10:45:09.703 * +failover-state-wait-promotion slave 192.168.27.128:6479 192.168.27.128 6479 @ mymaster 192.168.27.128 6379
slave收到信息,设置当前配置信息为master相关
{"slaveof",replicaofCommand,3,
"admin no-script ok-stale",
0,NULL,0,0,0,0,0,0},
void replicaofCommand(client *c)
##
/* The special host/port combination "NO" "ONE" turns the instance
* into a master. Otherwise the new master address is set. */
if (!strcasecmp(c->argv[1]->ptr,"no") &&
!strcasecmp(c->argv[2]->ptr,"one")) {
if (server.masterhost) {
replicationUnsetMaster();
sds client = catClientInfoString(sdsempty(),c);
serverLog(LL_NOTICE,"MASTER MODE enabled (user request from '%s')",
client);
sdsfree(client);
}
日志:
2811:M 27 Jul 2020 10:45:09.704 # Setting secondary replication ID to 53800b91899d420c81b7c170c03e63cbfa378cb7, valid up to offset: 18684. New replication ID is 710727bc0c2596d189135eea774afe10da43d22b
2811:M 27 Jul 2020 10:45:09.704 * Discarding previously cached master state.
2811:M 27 Jul 2020 10:45:09.704 * MASTER MODE enabled (user request from 'id=16 addr=192.168.27.128:58900 fd=15 name=sentinel-97661441-cmd age=59 idle=0 flags=x db=0 sub=0 psub=0 multi=3 qbuf=140 qbuf-free=32628 obl=36 oll=0 omem=0 events=r cmd=exec')