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);
相关推荐
DevilSeagull3 小时前
MySQL(2) 客户端工具和建库
开发语言·数据库·后端·mysql·服务
远洪5 小时前
claude code 国内安装使用
数据库·mysql
wangbing11257 小时前
MySQL 官方 GPG 密钥过期问题
数据库·mysql
重生之我是Java开发战士7 小时前
【MySQL】事务 & 用户与权限管理
android·数据库·mysql
2401_895521348 小时前
MySQL中的count函数
数据库·mysql
.小小陈.8 小时前
MySQL 入门到实战:从基础概念到核心存储引擎
数据库·mysql
yoyo_zzm8 小时前
Laravel10.x新特性全解析
数据库·mysql·架构
雨辰AI9 小时前
从 MySQL 迁移至人大金仓 V9 完整改造指南|分页 / 函数 / 语法兼容全部解决
java·开发语言·数据库·后端·mysql·政务
dvjr cloi10 小时前
Linux(CentOS)安装 MySQL
linux·mysql·centos
庞轩px10 小时前
第四篇:多级缓存架构——Caffeine + Redis + MySQL 三级协同
java·redis·mysql·读写分离·caffeine·本地缓存