正德厚生,臻于至善

MySQL 5.7 MGR单主确定主节点方法

MGR查找主节点可以通过group_replication_primary_member参数查看:
SHOW STATUS LIKE 'group_replication_primary_member';
如果是单主模式,上述命令会返回主节点的server_uuid,再结合以下命令找出该节点即可:
show variables like 'server_uuid';

如果MGR是多主模式,SHOW STATUS LIKE 'group_replication_primary_member'将不会返回任何server_uuid,即也可以通过这个参数来判断当前MGR是单主还是多主模式。

SHOW STATUS LIKE 'group_replication_primary_member';
show variables like 'server_uuid';
select * from performance_schema.replication_group_members;
show variables like '%read_only';

SELECT
MEMBER_ID,
MEMBER_HOST,
MEMBER_PORT,
MEMBER_STATE,
IF(global_status.VARIABLE_NAME IS NOT NULL,
'PRIMARY',
'SECONDARY') AS MEMBER_ROLE
FROM
performance_schema.replication_group_members
LEFT JOIN
performance_schema.global_status ON global_status.VARIABLE_NAME = 'group_replication_primary_member'
AND global_status.VARIABLE_VALUE = replication_group_members.MEMBER_ID;
赞(0) 打赏
未经允许不得转载:徐万新之路 » MySQL 5.7 MGR单主确定主节点方法

评论 抢沙发

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫

微信扫一扫

登录

找回密码

注册