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);
相关推荐
zxcvb1534 小时前
运维实践里把备份mysql数据库做稳的一些思路
运维·数据库·mysql
一级新生6 小时前
Dify 迭代节点:从输入输出到九步实操
数据库·人工智能·mysql·低代码·工作流·dify
唐青枫8 小时前
MySQL mysql.help_topic 详解及实战 Demo
mysql
xixiaoyunya9 小时前
MySQL 全库备份:用 mysqldump 打好基线,再补上自动化与异地能力
数据库·mysql·自动化
箓维10 小时前
MySQL_数据库基础与库表操作
数据库·mysql·oracle
飞花漫卷,情随岁迁11 小时前
Linux 排障与性能监控
linux·运维·服务器·网络·数据库·mysql·oracle
千寻技术帮12 小时前
基于小程序的旅游管理系统(源码+脚本+文档)_50033
mysql·小程序·springboot·旅游·旅游管理系统
利威尔xu13 小时前
MySQL 事务隔离级别:脏读幻读分不清,4 档隔离选错并发数据全乱套拖垮对账
数据库·mysql·事务·隔离级别·mvcc
千寻技术帮14 小时前
基于微信小程序的家政服务系统(源码+脚本+文档)_50039
mysql·微信小程序·小程序·毕业设计·家政服务
stormsha14 小时前
`Could not create connection to database server`:MySQL 8 连不上,真凶藏在第 4 层
java·后端·mysql