设置:
问题:
以下命令将不会运行。我可以创建用户和数据库以及删除数据库,但无法删除用户。我无法判断这是复制问题还是权限问题。
第 1 行出现错误 3098 (HY000):该表不符合外部插件的要求。
日志:[错误]插件 group_replication 报告:“表用户不使用 InnoDB 存储引擎。这与组复制不兼容。
我通过本地 mysql 控制台也以 root 身份登录,得到同样的错误。
问题:
如果您使用组复制(在 5.7 或 8.0 中),则必须通过 GRANT/DROP/CREATE USER/etc 命令而不是 INSERT/UPDATE/DELETE/etc 进行所有用户身份验证。
由于严重的技术困难,MyISAM 未在组复制中进行复制。
(以上评论也适用于 Galera / PXC。)
(警告:我所说的可能并不完全正确,但我认为这会让您摆脱麻烦,并解决手头的问题。)
组复制要求之一是 -
Every table that is to be replicated by the group must have a defined primary key, or primary key equivalent where the equivalent is a non-null unique key.
[链接]
因此,如果您使用不满足此条件的表,服务器将抛出此错误。使用带有主 ID 的表。
就我而言,我在从单主模式 MySQL 复制组恢复备份时遇到了同样的错误。我在
--single-transaction
cmd 期间使用 mysqldump
标志进行了备份。
$ mysqldump -uroot -p<root_password> -h<host> --set-gtid-purged=OFF --single-transaction --all-databases --triggers --routines --events < dump.sql
在这里,请参阅
--single-transaction
标志的用法以了解其导致的问题。
$ mysqldump --help
...
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off --lock-tables.
...
因此,在阅读@RickJames 提供的建议后,我只需在备份期间从
--single-transaction
cmd 中删除 mysqldump
标志,然后将其恢复到新的复制组。
注意: MySQL 服务器版本为 5.7.25
我也有这个问题。我发现
MySQL Group Replication requires tables must have an explicit primary key defined
。
表中缺少主键会导致此错误