Documentation Home
MySQL 外壳 8.0  / 第 7 章 MySQL InnoDB 集群  / 7.10 升级InnoDB集群  /  7.10.1 InnoDB集群升级

7.10.1 InnoDB集群升级

要升级 InnoDB Cluster 中的服务器实例,请完成以下步骤:

检查已安装二进制文件的版本:

  • mysqlrouter --version:检查安装的 MySQL Router 的版本。

  • mysqlsh --version:检查安装的 MySQL Shell 的版本。

  • mysqld --version:检查安装的 MySQL 服务器的版本。

升级 MySQL 路由器。

要升级 MySQL Router,请完成以下步骤:

  1. 停止 MySQL 路由器。

    在 Unix 系统上,如果您使用了可选的 引导程序选项,则会在您引导 路由器--directory时选择的位置创建一个包含所有生成的目录和文件的独立安装 。这些文件包括. 导航到该目录并发出以下命令: stop.sh

    Press CTRL+C to copy
    ./stop.sh

    在 Microsoft Windows 上,如果您使用了可选的-bootstrap 选项,则会在您引导 路由器-directory时选择的位置创建一个包含所有生成的目录和文件的独立安装 。这些文件包括. 导航到该目录并发出以下命令: stop.ps1

    Press CTRL+C to copy
    .\stop.ps1

    或者在使用 的 Linux 系统上systemd,通过发出以下命令停止 MySQL Router 服务:

    Press CTRL+C to copy
    systemctl stop mysqlrouter.service

    否则,终止关联的 mysqlrouter进程的进程 ID (PID)

  2. 获取并安装最新版本的 MySQL Router。

  3. 启动 MySQL 路由器。

    在 Unix 系统上,如果您使用了可选的-directory-bootstrap 选项,则会在您选择的位置创建一个包含所有生成的目录和文件的独立安装。这些文件包括start.sh. 导航到目录并发出以下命令:

    Press CTRL+C to copy
    ./start.sh

    如果新路由器的路径已更改,则必须更新start.shshell 脚本以反映该路径。

    Press CTRL+C to copy
    #!/bin/bash basedir=/tmp/myrouter ROUTER_PID=$basedir/mysqlrouter.pid /usr/bin/mysqlrouter -c $basedir/mysqlrouter.conf & disown %-

    如果您手动升级 MySQL Router,而不是使用包管理,您可以更新 basedir=. 如果您再次引导路由器,start.sh则会重新生成 shell 脚本。

    或者在使用 的 Linux 系统上systemd,通过发出以下命令启动 MySQL 路由器服务:

    Press CTRL+C to copy
    systemctl start mysqlrouter.service

    在 Microsoft Windows 上,如果您使用了可选的-directory-bootstrap 选项,则会在您选择的位置创建一个独立安装,其中包含所有生成的目录和文件。这些文件包括start.ps1. 导航到目录并发出以下命令:

    Press CTRL+C to copy
    .\start.ps1

    在使用新的路由器二进制文件启动 MySQL Router 时,通过发出以下命令检查路由器的版本是否已升级:

    Press CTRL+C to copy
    mysqlrouter --version

升级 MySQL 外壳

通过安装新的二进制文件并停止和启动 MySQL Shell 来升级 MySQL Shell:

  1. 获取并安装最新版本的 MySQL Shell。

  2. 通过发出以下命令停止并退出 MySQL Shell:

    Press CTRL+C to copy
    \q
  3. 通过发出以下命令从命令行重新启动 MySQL Shell:

    Press CTRL+C to copy
    mysqlsh
  4. 升级 InnoDB 集群元数据

    • 要升级 InnoDB 集群的元数据,请将 MySQL Shell 的全局会话连接到您的集群,并使用该dba.upgradeMetadata()操作将集群的元数据升级为新的元数据。

    元数据升级

    如果集群已经使用最新版本,元数据升级可能什么都不做。

升级 MySQL 服务器

通过在升级主实例之前升级所有辅助实例来升级 MySQL 服务器。

升级 MySQL 服务器是可选的

升级 MySQL 服务器是可选的。服务器升级比升级 MySQL Shell 和 MySQL Router 的影响更大。另外,你应该始终将 MySQL Shell 和 MySQL Router 保持在最新版本,即使服务器不是;InnoDB 集群和 ReplicaSets 也是如此。

  1. 通过发出以下命令之一停止 MySQL 服务器:

    • 如果 MySQL 服务器正在使用 systemd问题:

      Press CTRL+C to copy
      systemctl stop mysqld
    • 如果 MySQL 服务器正在使用 init.d问题:

      Press CTRL+C to copy
      /etc/init.d/mysql stop
    • 如果 MySQL 服务器正在使用 服务问题:

      Press CTRL+C to copy
      service mysql stop
    • 如果您在 Microsoft Windows 问题上部署了 MySQL 服务器:

      Press CTRL+C to copy
      mysqladmin -u root -p shutdown
  2. 获取并安装最新版本的 MySQL 服务器。

  3. 通过发出以下命令之一启动 MySQL 服务器:

    • 如果 MySQL 服务器正在使用 systemd问题:

      Press CTRL+C to copy
      systemctl start mysqld
    • 如果 MySQL 服务器正在使用 init.d问题:

      Press CTRL+C to copy
      /etc/init.d/mysql start
    • 如果 MySQL 服务器正在使用 服务问题:

      Press CTRL+C to copy
      service mysql start
    • 如果您在 Microsoft Windows 问题上部署了 MySQL 服务器:

      Press CTRL+C to copy
      mysqld
  4. 当所有从实例升级完成后,再升级主实例,完成升级过程。

升级后状态检查

升级 MySQL Router、MySQL Shell 和 MySQL Servers 后:

  1. 通过发出 检查集群<Cluster>.status()。有关 的更多信息<Cluster>.status(),请参阅 使用 检查集群的状态 Cluster.status()

  2. 解析任何clusterErrors并由 statusText<Cluster>.status()操作 返回 。

这些命令允许您检查升级是否成功,或者您是否需要完成任何其他步骤。

笔记

额外的步骤取决于;关于您跳过了多少个版本,您要升级哪个版本,以及您要从哪个版本来。

  1. 检查每个 InnoDB Cluster 的状态,通过发出 <Cluster>.status().

    在下面的示例中 <Cluster>.status({extended: true}),用于提供有关集群状态的更详细信息,返回两个问题:

    Press CTRL+C to copy
    mysqlsh> <Cluster>.status({extended: true}); { "clusterName": "MyCluster", "defaultReplicaSet": { "GRProtocolVersion": "8.0.16", "groupName": "459ec434-8926-11ec-b8c3-02001707f44a", "groupViewChangeUuid": "AUTOMATIC", "groupViewId": "16443558036060755:13", "name": "default", "ssl": "REQUIRED", "status": "OK", "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.", "topology": { "example-el7-1644251369:33311": { "address": "example-el7-1644251369:33311", "applierWorkerThreads": 4, "fenceSysVars": [], "instanceErrors": [ "NOTE: instance server_id is not registered in the metadata. Use cluster.rescan() to update the metadata.", "NOTE: The required parallel-appliers settings are not enabled on the instance. Use dba.configureInstance() to fix it." ], "memberId": "247131ab-8926-11ec-850b-02001707f44a", "memberRole": "PRIMARY", "memberState": "ONLINE", "mode": "R/W", "readReplicas": {}, "replicationLag": null, "role": "HA", "status": "ONLINE", "version": "8.0.28" }, "example-el7-1644251369:33314": { "address": "example-el7-1644251369:33314", "applierWorkerThreads": 4, "fenceSysVars": [], "instanceErrors": [ "NOTE: instance server_id is not registered in the metadata. Use cluster.rescan() to update the metadata.", "NOTE: The required parallel-appliers settings are not enabled on the instance. Use dba.configureInstance() to fix it." ], "memberId": "303dcfa7-8926-11ec-a6e5-02001707f44a", "memberRole": "PRIMARY", "memberState": "ONLINE", "mode": "R/W", "readReplicas": {}, "replicationLag": null, "role": "HA", "status": "ONLINE", "version": "8.0.28" }, "example-el7-1644251369:33317": { "address": "example-el7-1644251369:33317", "applierWorkerThreads": 4, "fenceSysVars": [], "instanceErrors": [ "NOTE: instance server_id is not registered in the metadata. Use cluster.rescan() to update the metadata.", "NOTE: The required parallel-appliers settings are not enabled on the instance. Use dba.configureInstance() to fix it." ], "memberId": "3bb2592e-8926-11ec-8b6f-02001707f44a", "memberRole": "PRIMARY", "memberState": "ONLINE", "mode": "R/W", "readReplicas": {}, "replicationLag": null, "role": "HA", "status": "ONLINE", "version": "8.0.28" } }, "topologyMode": "Multi-Primary" }, "groupInformationSourceMember": "example-el7-1644251369:33311", "metadataVersion": "2.1.0" }

    <Cluster>.status({extended: true}) 显示有关集群的更多详细信息。在此示例中,我们使用布尔值true,它等效于 <Cluster>.status({'extended':1})。有关详细信息,请参阅 使用检查集群的状态 Cluster.status()

  2. 解决 <Cluster>.status({extended:1}) 操作返回的任何错误。

    在此示例中,instanceErrors 建议在此升级中,我们应该 在集群中的每个成员上 发出<Cluster>.rescan()和 :dba.configureInstance()

    Press CTRL+C to copy
    ... "NOTE: instance server_id is not registered in the metadata. Use <Cluster>.rescan() to update the metadata.", "NOTE: The required parallel-appliers settings are not enabled on the instance. Use dba.configureInstance() to fix it." ...

    <Cluster>.rescan()操作使您能够重新扫描集群以查找新的和过时的组复制实例,以及所用拓扑模式的更改。有关详细信息,请参阅 重新扫描集群

    Press CTRL+C to copy
    mysqlsh> <Cluster>.rescan(); Rescanning the cluster... Result of the rescanning operation for the 'MyCluster1' cluster: { "name": "MyCluster1", "newTopologyMode": null, "newlyDiscoveredInstances": [], "unavailableInstances": [], "updatedInstances": [] }

    dba.configureInstance()函数检查使实例用于 InnoDB Cluster 使用所需的所有设置。有关更多信息,请参阅 为 InnoDB 集群使用配置生产实例

    在此示例中,我们 dba.configureInstance()在 InnoDB 集群中的每个成员上发出,以确保在实例上启用所需的并行应用程序设置:

    Press CTRL+C to copy
    mysqlsh> dba.configureInstance('cladmin:cladminpw@localhost:33311') The instance 'example-el7-1644251369:33311' belongs to an InnoDB Cluster. Configuring local MySQL instance listening at port 33311 for use in an InnoDB cluster... This instance reports its own address as ^[[1mexample-el7-1644251369:33311^[[0m 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. ^[[36mNOTE: ^[[0mSome configuration options need to be fixed: +----------------------------------------+---------------+----------------+----------------------------+ | Variable | Current Value | Required Value | Note | +----------------------------------------+---------------+----------------+----------------------------+ | binlog_transaction_dependency_tracking | COMMIT_ORDER | WRITESET | Update the server variable | +----------------------------------------+---------------+----------------+----------------------------+ Configuring instance... The instance 'example-el7-1644251369:33311' was configured to be used in an InnoDB cluster.

有关集群升级故障排除的信息,请参阅 故障排除 InnoDB 集群升级