概要
MySQL Shell 实用程序用于配置 MySQL InnoDB 集群。配置 MySQL 引擎后,为了准备集群,该实用程序会尝试自动远程重新启动它。但是,如果远程 MySQL 实例在 Linux 容器中运行,使用 Docker,重启过程将失败。
我在一个容器内并排运行 MySQL Shell 8.0.26,连接到同一个 Docker 网络和两个额外的容器,每个容器都运行 MySQL Server 8.0.26。
我注意到MySQL 支持RESTART
statement,前提是已向调用用户授予了适当的权限。但是,似乎 MySQL Shell 没有使用它,或者至少将其作为重新启动机制。
问题:这是 MySQL Shell 重启远程 MySQL 实例的一个错误吗?
复制步骤
- 创建 Docker 网络
- 创建几个 MySQL 服务器容器
- 为 MySQL Shell 创建一个单独的容器
docker network create mysql
docker run --detach --restart always --pull always --env MYSQL_ROOT_PASSWORD=beer --network mysql --name mysql-node1 mysql:8.0.26
docker run --detach --restart always --pull always --env MYSQL_ROOT_PASSWORD=beer --network mysql --name mysql-node2 mysql:8.0.26
docker run --interactive --tty --restart always --network mysql --name mysql-shell ubuntu:focal
- 将 MySQL Shell 安装到 Ubuntu 容器中。
apt update && apt-get install httpie --yes
export FILENAME='mysql-shell_8.0.26-1ubuntu20.04_amd64.deb'
http --download https://cdn.mysql.com//Downloads/MySQL-Shell/$FILENAME
dpkg --install $FILENAME
apt-get install --fix-broken --yes
apt-get install mysql-client --yes
- 尝试使用 MySQL Shell 创建 InnoDB 集群
mysqlsh
\py
dba.configure_instance('root@mysql-node1:3306');
Please provide the password for 'root@mysql-node1:3306': ******
Save password for 'root@mysql-node1:3306'? [Y]es/[N]o/Ne[v]er (default No): y
Configuring MySQL instance at 542aec7032fd:3306 for use in an InnoDB cluster...
This instance reports its own address as 542aec7032fd:3306
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.
applierWorkerThreads will be set to the default value of 4.
NOTE: Some configuration options need to be fixed:
+----------------------------------------+---------------+----------------+--------------------------------------------------+
| Variable | Current Value | Required Value | Note |
+----------------------------------------+---------------+----------------+--------------------------------------------------+
| binlog_transaction_dependency_tracking | COMMIT_ORDER | WRITESET | Update the server variable |
| 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 |
| replica_parallel_type | DATABASE | LOGICAL_CLOCK | Update the server variable |
| replica_preserve_commit_order | OFF | ON | Update the server variable |
| server_id | 1 | <unique ID> | Update read-only variable and restart the server |
+----------------------------------------+---------------+----------------+--------------------------------------------------+
实际结果
Some variables need to be changed, but cannot be done dynamically on the server.
Do you want to perform the required configuration changes? [y/n]: y
Do you want to restart the instance after configuring it? [y/n]: y
Configuring instance...
The instance '542aec7032fd:3306' was configured to be used in an InnoDB cluster.
Restarting MySQL...
ERROR: Remote restart of MySQL server failed: MySQL Error 3707 (HY000): Restart server failed (mysqld is not managed by supervisor process).
Please restart MySQL manually
Traceback (most recent call last):
File "<string>", line 1, in <module>
mysqlsh.DBError: MySQL Error (3707): Dba.configure_instance: Restart server failed (mysqld is not managed by supervisor process).
预期结果
MySQL Shell 远程重启 MySQL 引擎,没有任何错误。