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);
相关推荐
星恒随风9 小时前
MySQL 从零入门(四):表的增删改查与基础查询详解
linux·服务器·数据库·笔记·mysql
Pniubi11 小时前
MySQL靠什么实现事务的?事务隔离级别有哪些?
java·数据库·mysql
aiks_yuan11 小时前
MySQL 死锁怎么排查:看懂 INNODB STATUS 死锁日志,先查后插为什么必死锁(MySQL 8.2 实测)
mysql
进击的荆棘14 小时前
MySQL——库的操作
数据库·mysql
计算机毕设定制辅导-无忧学长15 小时前
《基于Spring Boot的迷游哈游戏综合服务平台的开发》
java·vue.js·spring boot·mysql·迷游哈游戏综合服务平台
这个DBA有点耶1 天前
函数索引的“完全一致”有多苛刻:写法、字符集、类型,差一处就失效
数据库·mysql·代码规范
星恒随风1 天前
MySQL 从零入门(三):表的约束详解
linux·服务器·数据库·笔记·mysql
杨凯凡2 天前
MySQL 死锁怎么排查?InnoDB 锁等待与 Spring Boot 整事务重试实战
数据库·spring boot·mysql
Decay__2 天前
01_SQLServer 体系架构全解 —— 实例进程、关系引擎、SQLOS 与事务日志深入
运维·数据库·sql·mysql·架构
瑞雪兆丰年兮2 天前
JavaWeb-day07-MySQL(DQL&多表设计)
java·开发语言·数据库·sql·mysql·javaweb·web