ALTER INSTANCEinstance_actioninstance_action: { | {ENABLE|DISABLE} INNODB REDO_LOG | ROTATE INNODB MASTER KEY | ROTATE BINLOG MASTER KEY | RELOAD TLS [FOR CHANNEL {mysql_main | mysql_admin}] [NO ROLLBACK ON ERROR] | RELOAD KEYRING }
ALTER INSTANCE定义适用于 MySQL 服务器实例的操作。该语句支持以下操作:ALTER INSTANCE defines actions applicable to a
MySQL server instance. The statement supports these actions:
ALTER INSTANCE {ENABLE | DISABLE} INNODB REDO_LOG此操作用于启用或禁用
InnoDB重做日志。重做日志默认启用。此功能仅用于向新的 MySQL 实例加载数据。该语句不会写入二进制日志。This action enables or disablesInnoDBredo logging. Redo logging is enabled by default. This feature is intended only for loading data into a new MySQL instance. The statement is not written to the binary log.Warning不要在生产系统上禁用重做日志。 虽然在禁用重做日志时允许关闭并重新启动服务器,但在禁用重做日志期间服务器意外停止可能导致数据丢失和实例损坏。Do not disable redo logging on a production system. While it is permitted to shut down and restart the server while redo logging is disabled, an unexpected server stoppage while redo logging is disabled can cause data loss and instance corruption.
执行
ALTER INSTANCE [ENABLE|DISABLE] INNODB REDO_LOG操作需要独占备份锁,这会阻止其他ALTER INSTANCE操作同时执行。其他ALTER INSTANCE操作必须等待锁释放后才能执行。AnALTER INSTANCE [ENABLE|DISABLE] INNODB REDO_LOGoperation requires an exclusive backup lock, which prevents otherALTER INSTANCEoperations from executing concurrently. OtherALTER INSTANCEoperations must wait for the lock to be released before executing.有关更多信息,请参阅 禁用重做日志。For more information, see Disabling Redo Logging.
ALTER INSTANCE ROTATE INNODB MASTER KEY此操作会旋转用于
InnoDB表空间加密的主加密密钥。密钥旋转需要ENCRYPTION_KEY_ADMIN或SUPER权限。要执行此操作,必须安装并配置 keyring 插件。有关说明,请参阅 第 8.4.4 节,“MySQL Keyring”。This action rotates the master encryption key used forInnoDBtablespace encryption. Key rotation requires theENCRYPTION_KEY_ADMINorSUPERprivilege. To perform this action, a keyring plugin must be installed and configured. For instructions, see Section 8.4.4, “The MySQL Keyring”.ALTER INSTANCE ROTATE INNODB MASTER KEY支持并发 DML。然而,它不能与CREATE TABLE ... ENCRYPTION或ALTER TABLE ... ENCRYPTION操作同时运行,并且会加锁以防止因这些语句的并发执行而产生冲突。如果其中一个冲突语句正在运行,必须在另一个语句执行之前完成。ALTER INSTANCE ROTATE INNODB MASTER KEYsupports concurrent DML. However, it cannot be run concurrently withCREATE TABLE ... ENCRYPTIONorALTER TABLE ... ENCRYPTIONoperations, and locks are taken to prevent conflicts that could arise from concurrent execution of these statements. If one of the conflicting statements is running, it must complete before another can proceed.ALTER INSTANCE ROTATE INNODB MASTER KEY语句会写入二进制日志,以便可以在复制服务器上执行。ALTER INSTANCE ROTATE INNODB MASTER KEYstatements are written to the binary log so that they can be executed on replicated servers.有关额外的
ALTER INSTANCE ROTATE INNODB MASTER KEY使用信息,请参阅 第 17.13 节,“InnoDB 数据静态加密”。For additionalALTER INSTANCE ROTATE INNODB MASTER KEYusage information, see Section 17.13, “InnoDB Data-at-Rest Encryption”.ALTER INSTANCE ROTATE BINLOG MASTER KEY此操作会旋转用于二进制日志加密的二进制日志主密钥。二进制日志主密钥的密钥旋转需要
BINLOG_ENCRYPTION_ADMIN或SUPER权限。如果binlog_encryption系统变量设置为OFF,则不能使用此语句。要执行此操作,必须安装并配置密钥环插件。有关说明,请参阅 第 8.4.4 节,“MySQL 密钥环”。This action rotates the binary log master key used for binary log encryption. Key rotation for the binary log master key requires theBINLOG_ENCRYPTION_ADMINorSUPERprivilege. The statement cannot be used if thebinlog_encryptionsystem variable is set toOFF. To perform this action, a keyring plugin must be installed and configured. For instructions, see Section 8.4.4, “The MySQL Keyring”.ALTER INSTANCE ROTATE BINLOG MASTER KEY操作不会写入二进制日志,也不会在副本上执行。因此,可以在包括不同 MySQL 版本的复制环境中执行二进制日志主密钥轮换。要在所有相关的源服务器和副本服务器上定期轮换二进制日志主密钥,可以在每个服务器上启用 MySQL 事件调度器,并使用CREATE EVENT语句执行ALTER INSTANCE ROTATE BINLOG MASTER KEY语句。如果您因怀疑当前或之前的任何二进制日志主密钥可能已被泄露而进行二进制日志主密钥轮换,请在每个相关的源服务器和副本服务器上执行该语句,这样可以确保立即验证合规性。ALTER INSTANCE ROTATE BINLOG MASTER KEYactions are not written to the binary log and are not executed on replicas. Binary log master key rotation can therefore be carried out in replication environments including a mix of MySQL versions. To schedule regular rotation of the binary log master key on all applicable source and replica servers, you can enable the MySQL Event Scheduler on each server and issue theALTER INSTANCE ROTATE BINLOG MASTER KEYstatement using aCREATE EVENTstatement. If you rotate the binary log master key because you suspect that the current or any of the previous binary log master keys might have been compromised, issue the statement on every applicable source and replica server, which enables you to verify immediate compliance.有关额外的
ALTER INSTANCE ROTATE BINLOG MASTER KEY使用信息,包括在该过程未正确完成或因意外服务器中断而中断时应如何处理,请参阅 第 19.3.2 节,“加密二进制日志文件和中继日志文件”。For additionalALTER INSTANCE ROTATE BINLOG MASTER KEYusage information, including what to do if the process does not complete correctly or is interrupted by an unexpected server halt, see Section 19.3.2, “Encrypting Binary Log Files and Relay Log Files”.此操作根据定义上下文的系统变量的当前值重新配置 TLS 上下文。同时,它还会更新反映活动上下文值的状态变量。此操作需要
CONNECTION_ADMIN权限。有关重新配置 TLS 上下文的更多信息,包括哪些系统变量和状态变量与上下文相关,请参阅 加密连接的服务器端运行时配置和监控。This action reconfigures a TLS context from the current values of the system variables that define the context. It also updates the status variables that reflect the active context values. This action requires theCONNECTION_ADMINprivilege. For additional information about reconfiguring the TLS context, including which system and status variables are context-related, see Server-Side Runtime Configuration and Monitoring for Encrypted Connections.默认情况下,该语句会重新加载主连接接口的 TLS 上下文。如果指定了
FOR CHANNEL子句,该语句会重新加载指定通道的 TLS 上下文:主连接接口为mysql_main,管理连接接口为mysql_admin。有关不同接口的信息,请参见 第 7.1.12.1 节,“连接接口”。更新的 TLS 上下文属性将在性能模式tls_channel_status表中显示。请参见 第 29.12.22.9 节,“tls_channel_status 表”。By default, the statement reloads the TLS context for the main connection interface. If theFOR CHANNELclause is given, the statement reloads the TLS context for the named channel:mysql_mainfor the main connection interface,mysql_adminfor the administrative connection interface. For information about the different interfaces, see Section 7.1.12.1, “Connection Interfaces”. The updated TLS context properties are exposed in the Performance Schematls_channel_statustable. See Section 29.12.22.9, “The tls_channel_status Table”.更新主接口的 TLS 上下文也可能影响管理接口,因为除非为该接口配置了一些非默认的 TLS 值,否则它使用与主接口相同的 TLS 上下文。Updating the TLS context for the main interface may also affect the administrative interface because unless some nondefault TLS value is configured for that interface, it uses the same TLS context as the main interface.
Note当你重新加载 TLS 上下文时,OpenSSL 会在此过程中重新加载包含 CRL(证书撤销列表)的文件。如果 CRL 文件较大,服务器会分配一大块内存(文件大小的十倍),在新实例加载而旧实例尚未释放时,这块内存会加倍。大块内存释放后,进程常驻内存不会立即减少,因此如果你使用大型 CRL 文件反复执行
ALTER INSTANCE RELOAD TLS语句,可能会导致进程常驻内存使用量增加。When you reload the TLS context, OpenSSL reloads the file containing the CRL (certificate revocation list) as part of the process. If the CRL file is large, the server allocates a large chunk of memory (ten times the file size), which is doubled while the new instance is being loaded and the old one has not yet been released. The process resident memory is not immediately reduced after a large allocation is freed, so if you issue theALTER INSTANCE RELOAD TLSstatement repeatedly with a large CRL file, the process resident memory usage may grow as a result of this.默认情况下,如果配置值不允许创建新的 TLS 上下文,
RELOAD TLS操作会回滚并产生错误,且不会生效。新的连接将继续使用之前的上下文值。如果提供了可选的NO ROLLBACK ON ERROR子句且无法创建新的上下文,则不会回滚。相反,会生成警告,并且针对语句应用的接口上的新连接将禁用加密。By default, theRELOAD TLSaction rolls back with an error and has no effect if the configuration values do not permit creation of the new TLS context. The previous context values continue to be used for new connections. If the optionalNO ROLLBACK ON ERRORclause is given and the new context cannot be created, rollback does not occur. Instead, a warning is generated and encryption is disabled for new connections on the interface to which the statement applies.ALTER INSTANCE RELOAD TLS语句不会写入二进制日志(因此不会被复制)。TLS 配置是本地的,依赖于本地文件,这些文件并不一定存在于所有相关服务器上。ALTER INSTANCE RELOAD TLSstatements are not written to the binary log (and thus are not replicated). TLS configuration is local and depends on local files not necessarily present on all servers involved.如果安装了 keyring 组件,此操作会指示该组件重新读取其配置文件并重新初始化任何内存中的 keyring 数据。如果在运行时修改了组件配置,新的配置在执行此操作之前不会生效。重新加载 keyring 需要
ENCRYPTION_KEY_ADMIN权限。If a keyring component is installed, this action tells the component to re-read its configuration file and reinitialize any keyring in-memory data. If you modify the component configuration at runtime, the new configuration does not take effect until you perform this action. Keyring reloading requires theENCRYPTION_KEY_ADMINprivilege.此操作仅允许重新配置当前已安装的密钥环组件。它不允许更改已安装的组件。例如,如果您更改已安装密钥环组件的配置,
ALTER INSTANCE RELOAD KEYRING将使新配置生效。另一方面,如果您更改服务器清单文件中指定的密钥环组件,ALTER INSTANCE RELOAD KEYRING将无效,当前组件保持安装状态。This action enables reconfiguring only the currently installed keyring component. It does not enable changing which component is installed. For example, if you change the configuration for the installed keyring component,ALTER INSTANCE RELOAD KEYRINGcauses the new configuration to take effect. On the other hand, if you change the keyring component named in the server manifest file,ALTER INSTANCE RELOAD KEYRINGhas no effect and the current component remains installed.ALTER INSTANCE RELOAD KEYRING语句不会写入二进制日志(因此也不会被复制)。ALTER INSTANCE RELOAD KEYRINGstatements are not written to the binary log (and thus are not replicated).