3.单主模式和多主模式

1. 单主模式和多主模式的区

1.1 部署方式

两者部署方式基本相同,多主模式需额外设置以下两个参数:

bash 复制代码
group_replication_single_primary_mode = OFF
group_replication_enforce_update_everywhere_checks = ON

1.2 read_only

  • 对于单主模式,Group Replication 会自动将 Secondary 节点的 super_read_only 和 read_only 设置为 ON。

1.3 自增主键

在单主模式下,auto_increment_offset 和 auto_increment_increment 默认为 1。

多主模式下,auto_increment_offset 和 auto_increment_increment 则分别取⾃ server_id 和

group_replication_auto_increment_increment。

1.4 Group Replication 的限制

很多限制实际上是针对多主模式的。

2. 单主模式和多主模式的在线切换

在组复制中,单主模式和多主模式不能混合部署。

如果配置不兼容,会出现如下错误:

ERROR\] \[MY-011529\] \[Rep1\] Plugin group_replication reported: 'The member configuration is not compatible with the group configuration. Variables such as group_replication_single_primary_mode or group_replication_enforce_update_everywhere_checks must have the same value on every server in the group. (member configuration option: \[group_replication_single_primary_mode\], group configuration option: \[group_replication_enforce_update_everywhere_checks\]).'

在 MySQL 8.0.13 之前,不支持在线调整集群模式。如果要调整,只能重启整个组复制。

从 MySQL 8.0.13 开始,支持在线调整集群模式。

sql 复制代码
-- 单主模式切换为多主模式
SELECT group_replication_switch_to_multi_primary_mode();

-- 多主模式切换为单主模式
SELECT group_replication_switch_to_single_primary_mode(member_uuid);

-- 切换单主模式下的 Primary 节点
SELECT group_replication_set_as_primary(member_uuid);
相关推荐
阿杰 AJie11 小时前
MySQL 里给表添加索引
数据库·mysql
林鸿群13 小时前
ubuntu 26.04 安装mysql-server
linux·mysql·ubuntu
_F_y13 小时前
MySQL表的操作
android·数据库·mysql
千寻技术帮14 小时前
10336_基于SSM的少数民族文化商城
mysql·毕业设计·ssm·非遗商城
fenglllle14 小时前
MySQL explain format的差异
数据库·mysql
liux352815 小时前
MySQL主从复制技术全面解析:从基础原理到高级架构实践(八)
mysql
a程序小傲15 小时前
听说前端又死了?
开发语言·前端·mysql·算法·postgresql·深度优先
小Mie不吃饭15 小时前
MySQL慢查询日志全解析:从配置到优化实践
mysql
代码煮茶君17 小时前
MySQL 数据库死锁及核心机制全解析
android·数据库·mysql
H_unique18 小时前
MySQL数据库操作核心指南
数据库·mysql