具有 Mysql 复制的 Drupal 8 安装

Drupal 8 installation with Mysql replication

我正在尝试使用来自 Compose.io 的 Mysql 服务 默认情况下,此服务具有复制(3 个节点) 当我尝试通过 Drush 或 WebUI 安装 Drupal 时,出现一些错误:

Failed to INSERT a value into a test table on your database server. We tried inserting a value with the command INSERT INTO {drupal_install_test} (id) VALUES (1) and the server reported the following error: SQLSTATE[HY000]: General error: 3098 The table does not comply with the requirements by an external plugin.: INSERT INTO {drupal_install_test} (id) VALUES (1); Array ( ) .

Failed to UPDATE a value in a test table on your database server. We tried updating a value with the command UPDATE {drupal_install_test} SET id = 2 and the server reported the following error: SQLSTATE[HY000]: General error: 3098 The table does not comply with the requirements by an external plugin.: UPDATE {drupal_install_test} SET id = 2; Array ( ) .

Failed to DELETE a value from a test table on your database server. We tried deleting a value with the command DELETE FROM {drupal_install_test} and the server reported the following error: SQLSTATE[HY000]: General error: 3098 The table does not comply with the requirements by an external plugin.: DELETE FROM {drupal_install_test}; Array ( ) .

当复制开启时,每个 table 都需要有一个主键,显然 Drupal 默认不添加这些。

是否有任何解决方法可以将 Drupal 配置为使用 Mysql 数据库并启用复制?

请注意,Compose.io 不会向用户公开副本,只会向用户公开主副本。

这显然是新 Group Replication 功能返回的错误消息。

是的,组复制要求所有 table 都有一个主键。

https://dev.mysql.com/doc/refman/5.7/en/group-replication-requirements.html 说:

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.

不幸的是,tableDrupal 用于测试安装的测试没有主键(或等效项)。

这已作为问题报告给 Drupal:https://www.drupal.org/project/drupal/issues/2856362

Drupal 8.5 或更高版本中可能会有修复,但与此同时,评论者可能会在该问题中提出有用的补丁。基本上,您只需要将几个文件中 drupal_install_test table 的创建更改为:

CREATE TABLE {drupal_install_test} (id INT NOT NULL PRIMARY KEY)

轻松修复 (Drupal 7)

在您的 install.inc 文件中,第 307 行必须更改为 创建 TABLE {drupal_install_test} (id int NOT NULL PRIMARY KEY)