下载本手册

MySQL Shell 9.0  /  ...  /  在使用 InnoDB Cluster 之前检查实例配置

7.4.1 在使用 InnoDB Cluster 之前检查实例配置

在从服务器实例创建生产部署之前,您需要检查每个实例上的 MySQL 是否配置正确。dba.configureInstance() 函数会在配置实例时执行此操作,但您也可以选择使用 dba.checkInstanceConfiguration(实例) 函数。这会在不更改实例上的任何配置的情况下,检查实例是否满足第 7.1 节 “InnoDB Cluster 要求”中列出的要求。

您用于连接到实例的用户必须具有适当的权限,例如在手动配置 InnoDB Cluster 管理员帐户中配置的权限。以下演示了如何在运行的 MySQL Shell 中发出此命令

mysql-js> dba.checkInstanceConfiguration('icadmin@ic-1:3306')
Please provide the password for 'icadmin@ic-1:3306': ***
Validating MySQL instance at ic-1:3306 for use in an InnoDB cluster...

This instance reports its own address as ic-1
Clients and other cluster members will communicate with it through this address by default.
If this is not correct, the report_host MySQL system variable should be changed.

Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected

Checking instance configuration...

Some configuration options need to be fixed:
+--------------------------+---------------+----------------+--------------------------------------------------+
| Variable                 | Current Value | Required Value | Note                                             |
+--------------------------+---------------+----------------+--------------------------------------------------+
| enforce_gtid_consistency | OFF           | ON             | Update read-only variable and restart the server |
| gtid_mode                | OFF           | ON             | Update read-only variable and restart the server |
| server_id                | 1             |                | Update read-only variable and restart the server |
+--------------------------+---------------+----------------+--------------------------------------------------+

Please use the dba.configureInstance() command to repair these issues.

{
    "config_errors": [
        {
            "action": "restart",
            "current": "OFF",
            "option": "enforce_gtid_consistency",
            "required": "ON"
        },
        {
            "action": "restart",
            "current": "OFF",
            "option": "gtid_mode",
            "required": "ON"
        },
        {
            "action": "restart",
            "current": "1",
            "option": "server_id",
            "required": ""
        }
    ],
    "status": "error"
}

对您计划用作集群一部分的每个服务器实例重复此过程。运行 dba.checkInstanceConfiguration() 后生成的报告提供了有关在 InnoDB Cluster 部署中使用该实例所需的任何配置更改的信息。报告的 config_error 部分中的 action 字段告诉您实例上的 MySQL 是否需要重新启动才能检测对配置文件所做的任何更改。