本文援引自MySQL官方文档两处内容,如下:
-
一、官方文档《为 InnoDB 集群使用配置生产实例》MySQL :: MySQL Shell 8.0 :: 7.4.2 Configuring Production Instances for InnoDB Cluster Usage
Once
dba.configureInstance()
is issued against an instance, the command checks if the instance's settings are suitable for InnoDB Cluster usage. A report is displayed which shows the settings required by InnoDB Cluster . If the instance does not require any changes to its settings you can use it in an InnoDB Cluster, and can proceed to Section 7.4.3, “Creating an InnoDB Cluster”. If the instance's settings are not valid for InnoDB Cluster usage thedba.configureInstance()
command displays the settings which require modification. Before configuring the instance you are prompted to confirm the changes shown in a table with the following information:
Variable
- the invalid configuration variable.
Current Value
- the current value for the invalid configuration variable.
Required Value
- the required value for the configuration variable.
How you proceed depends on whether the instance supports persisting settings, see Section 6.2.4, “Persisting Settings”. When
dba.configureInstance()
is issued against the MySQL instance which MySQL Shell is currently running on, in other words the local instance, it attempts to automatically configure the instance. Whendba.configureInstance()
is issued against a remote instance, if the instance supports persisting configuration changes automatically, you can choose to do this. If a remote instance does not support persisting the changes to configure it for InnoDB Cluster usage, you have to configure the instance locally. See Configuring Instances with dba.configureLocalInstance().
google翻译:
一旦
dba.configureInstance()
针对实例发出,该命令将检查实例的设置是否适合 InnoDB Cluster 使用。将显示一份报告,其中显示 InnoDB Cluster 所需的设置。如果实例不需要对其设置进行任何更改,您可以在 InnoDB Cluster 中使用它,并且可以继续 第 7.4.3 节,“创建 InnoDB Cluster”。如果实例的设置对于 InnoDB Cluster 使用无效,则该dba.configureInstance()
命令会显示需要修改的设置。在配置实例之前,系统会提示您确认表格中显示的更改以及以下信息:
Variable
- 无效的配置变量。
Current Value
- 无效配置变量的当前值。
Required Value
- 配置变量的必需值。
如何继续取决于实例是否支持持久设置,请参阅 第 6.2.4 节,“持久设置”。当
dba.configureInstance()
针对 MySQL Shell 当前运行的 MySQL 实例(即本地实例)发出时,它会尝试自动配置该实例。当dba.configureInstance()
针对远程实例发出时,如果该实例支持自动持久化配置更改,您可以选择执行此操作。如果远程实例不支持持久化更改以配置它以供 InnoDB Cluster 使用,则必须在本地配置实例。请参阅 使用配置实例 dba.configureLocalInstance()。
6.2.4 Persisting Settings
The AdminAPI commands you use to work with an InnoDB Cluster, InnoDB ClusterSet, InnoDB ReplicaSet, and the individual member server instances in these deployments modify the configuration of MySQL Server on the instance. Depending on the way MySQL Shell is connected to an instance and the version of MySQL Server installed on the instance, these configuration changes can be persisted to the instance automatically.
By making settings to the instance persistent, you ensure that after the instance restarts, configuration changes are retained. For background information see SET PERSIST. This persistence is essential for reliable usage. For example, if settings are not persistent, an instance added to a cluster does not rejoin the cluster after a restart because configuration changes are lost.
Instances which meet the following requirements support persisting configuration changes automatically:
The instance is running MySQL version 8.0.11 or later.
persisted_globals_load is set to
ON
.The instance has not been started with the --no-defaults option.
Instances which do not meet these requirements do not support persisting configuration changes automatically, and when AdminAPI operations result in changes to the instance's settings to be persisted you receive warnings such as:
WARNING: On instance 'localhost:3320' membership change cannot be persisted since MySQL version 5.7.21 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please use the <Dba>.configureLocalInstance command locally to persist the changes.
When AdminAPI commands are issued against the MySQL instance which MySQL Shell is currently running on, in other words, the local instance, MySQL Shell persists configuration changes directly to the instance. On local instances which support persisting configuration changes automatically, configuration changes are persisted to the instance's
mysqld-auto.cnf
file, and the configuration change does not require any further steps.You must make the changes locally on local instances that do not support persisting configuration changes automatically. For more information, see Configuring Instances with dba.configureLocalInstance().
When run against a remote instance, in other words, an instance other than the one which MySQL Shell is currently running on, if the instance supports persisting configuration changes automatically, the AdminAPI commands persist configuration changes to the instance's
mysql-auto.conf
option file.If a remote instance does not support persisting configuration changes automatically, the AdminAPI commands can not automatically configure the instance's option file. So, the AdminAPI commands can read information from the instance, for example, to display the current configuration. But changes to the configuration cannot be persisted to the instance's option file. In this case, you need to persist the changes locally. For more information, see Configuring Instances with dba.configureLocalInstance().
google翻译:
6.2.4 持久设置
用于处理 InnoDB Cluster、InnoDB ClusterSet、InnoDB ReplicaSet 以及这些部署中的各个成员服务器实例的 AdminAPI 命令会修改实例上 MySQL Server 的配置。根据 MySQL Shell 连接到实例的方式以及实例上安装的 MySQL 服务器的版本,这些配置更改可以自动持久化到实例。
通过对实例进行持久化设置,您可以确保在实例重新启动后,配置更改得以保留。有关背景信息,请参阅 SET PERSIST。这种持久性对于可靠使用至关重要。例如,如果设置不是持久性的,添加到集群的实例在重启后不会重新加入集群,因为配置更改会丢失。
满足以下要求的实例支持自动持久化配置更改:
实例运行的是 MySQL 8.0.11 或更高版本。
persisted_globals_load设置为
ON
。该实例尚未使用该 --no-defaults选项启动。
不满足这些要求的实例不支持自动持久化配置更改,并且当 AdminAPI 操作导致对实例设置的更改被持久化时,您会收到警告,例如:
WARNING: On instance 'localhost:3320' membership change cannot be persisted since MySQL version 5.7.21 does not support the SET PERSIST command (MySQL version >= 8.0.5 required). Please use the <Dba>.configureLocalInstance command locally to persist the changes.
当针对 MySQL Shell 当前运行的 MySQL 实例(即本地实例)发出 AdminAPI 命令时,MySQL Shell 会将配置更改直接保存到该实例。在支持自动持久化配置更改的本地实例上,配置更改会持久保存到实例的
mysqld-auto.cnf
文件中,并且配置更改不需要任何进一步的步骤。您必须在不支持自动持久配置更改的本地实例上进行本地更改(补充:即执行<Dba>.configureLocalInstance(...)方法)。有关详细信息,请参阅使用配置实例 dba.configureLocalInstance()。
当针对远程实例运行时,换句话说,不是当前运行 MySQL Shell 的实例,如果实例支持自动持久化配置更改,则 AdminAPI 命令将配置更改持久化到实例的选项文件中
mysql-auto.conf
。如果远程实例不支持自动持久化配置更改,则 AdminAPI 命令无法自动配置实例的选项文件。因此,AdminAPI 命令可以从实例中读取信息,例如,显示当前配置。但是对配置的更改无法持久保存到实例的选项文件中。在这种情况下,您需要在本地保留更改。有关详细信息,请参阅 使用配置实例 dba.configureLocalInstance()。