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);
相关推荐
洛豳枭薰17 小时前
Innodb一次更新动作
mysql
xcLeigh18 小时前
Python 项目实战:用 Flask 实现 MySQL 数据库增删改查 API
数据库·python·mysql·flask·教程·python3
Fleshy数模18 小时前
MySQL 表创建全攻略:Navicat 图形化与 Xshell 命令行双模式实践
linux·mysql
Nandeska19 小时前
15、基于MySQL的组复制
数据库·mysql
AllData公司负责人19 小时前
AllData数据中台-数据同步平台【Seatunnel-Web】整库同步MySQL同步Doris能力演示
大数据·数据库·mysql·开源
醇氧20 小时前
【docker】mysql 8 的健康检查(Health Check)
mysql·docker·容器
lekami_兰20 小时前
MySQL 长事务:藏在业务里的性能 “隐形杀手”
数据库·mysql·go·长事务
爱学英语的程序员1 天前
面试官:你了解过哪些数据库?
java·数据库·spring boot·sql·mysql·mybatis
·云扬·1 天前
MySQL Redo Log落盘机制深度解析
数据库·mysql
码界筑梦坊1 天前
330-基于Python的社交媒体舆情监控系统
python·mysql·信息可视化·数据分析·django·毕业设计·echarts