我最近安装了一个InnoDB集群,并尝试创建一个没有任何主键或等效键的表来测试集群索引的概念,其中“如果表包含以下内容,InnoDB会在包含行ID值的综合列上内部生成一个名为GEN_CLUST_INDEX的隐藏集群索引。没有PRIMARY KEY或合适的UNIQUE索引”。
我创建了如下表格:
create table repl_test (Name varchar(10));
检查是否创建了GEN_CLUST_INDEX:
select * from mysql.innodb_index_stats where database_name='test' and table_name = 'repl_test';
+---------------+------------+-----------------+---------------------+--------------+------------+-------------+-----------------------------------+
| database_name | table_name | index_name | last_update | stat_name | stat_value | sample_size | stat_description |
+---------------+------------+-----------------+---------------------+--------------+------------+-------------+-----------------------------------+
| test | repl_test | GEN_CLUST_INDEX | 2019-02-22 06:29:26 | n_diff_pfx01 | 0 | 1 | DB_ROW_ID |
| test | repl_test | GEN_CLUST_INDEX | 2019-02-22 06:29:26 | n_leaf_pages | 1 | NULL | Number of leaf pages in the index |
| test | repl_test | GEN_CLUST_INDEX | 2019-02-22 06:29:26 | size | 1 | NULL | Number of pages in the index |
+---------------+------------+-----------------+---------------------+--------------+------------+-------------+-----------------------------------+
3 rows in set (0.00 sec)
但是,当我尝试插入行时,出现以下错误:
insert into repl_test values ('John');
ERROR 3098 (HY000): The table does not comply with the requirements by an external plugin.
2019-02-22T14:32:53.177700Z 594022 [ERROR] [MY-011542] [Repl] Plugin group_replication reported: 'Table repl_test does not have any PRIMARY KEY. This is not compatible with Group Replication.'
下面是我的conf文件:
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld_safe]
socket = /tmp/mysql.sock
[mysqld]
socket = /tmp/mysql.sock
port = 3306
basedir = /mysql/product/8.0/TEST
datadir = /mysql/data/TEST/innodb_data
log-error = /mysql/admin/TEST/innodb_logs/mysql.log
log_bin = /mysql/binlog/TEST/innodb_logs/mysql-bin
server-id=1
max_connections = 500
open_files_limit = 65535
expire_logs_days = 15
innodb_flush_log_at_trx_commit=1
sync_binlog=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
binlog_checksum = NONE
enforce_gtid_consistency = ON
gtid_mode = ON
relay-log=<<hostname>>-relay-bin
我的MySQL版本:x86_64上的linux-glibc2.12的mysql Ver 8.0.11(MySQL社区服务器-GPL)
答案 0 :(得分:0)
对于非集群设置,自动生成PK应该可以正常工作。但是,InnoDB Cluster(组复制)和Galera需要一个用户 PK(或可以升级的UNIQUE
)。
如果愿意,请向bugs.mysql.com提交 documentation 错误,抱怨此限制不清楚。确保指向需要修复的页面。