【MySQL Shell】8.10 升级 InnoDB ClusterSet

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

  1. 升级 MySQL Router
  2. 升级 MySQL Shell
  3. 升级 MySQL Server
  4. 升级后状态检查

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

  • mysqlrouter --version : 检查安装的 MySQL Router 的版本。
  • mysqlsh --version : 检查安装的 MySQL Shell 的版本。
  • mysqld --version : 检查安装的 MySQL Server 版本。

升级 MySQL Router

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

  1. 停止 MySQL Router 。

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

    ./stop.sh
    

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

    .\stop.ps1
    

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

    systemctl stop mysqlrouter.service
    

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

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

  3. 启动 MySQL Router 。

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

    ./start.sh
    

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

    #!/bin/bash
    basedir=/tmp/myrouter
    ROUTER_PID=$basedir/mysqlrouter.pid /usr/bin/mysqlrouter -c $basedir/mysqlrouter.conf &
    disown %-
    

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

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

    .\start.ps1
    

    译者注
    此处与官网在线文档不同。译者调整了“在 Microsoft Windows 上”与“在使用 systemd 的 Linux 系统上”的顺序,以与前文呼应。而官方在线文档前后文并未做到呼应。

    或者在使用 systemd 的 Linux 系统上,通过执行以下命令启动 MySQL Router 服务:

    systemctl start mysqlrouter.service
    

    使用新的路由器二进制文件启动 MySQL 路由器时,路由器的版本将升级:

    mysqlrouter --version
    

升级 MySQL Shell

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

  1. 获取并安装最新版本的 MySQL Shell。
  2. 通过执行以下命令停止并退出 MySQL Shell:
    \q
    
  3. 执行以下命令从命令行重启 MySQL Shell :
    mysqlsh
    
  4. 升级 InnoDB ClusterSet 元数据
    • 要升级 ClusterSet, 请将 MySQL Shell 的全局会话连接到 ClusterSet, 并使用 dba.upgradeMetadata() 操作将 ClusterSet 的元数据升级为新的元数据。

      如果需要升级 ClusterSet 的元数据架构,那么应该在 ClusterSet 的主集群中执行升级过程本身。

      元数据升级
      如果 InnoDB ClusterSet 已经使用了最新版本,则元数据升级可能没有任何作用。

升级 MySQL Server

通过首先升级所有副本集群的实例,然后升级主集群的实例来升级 MySQL Server。

升级每个集群、主集群或副本集群时,请在升级主实例之前升级所有辅助实例。

升级 MySQL Server 是可选的
升级 MySQL Server 是可选的。服务器升级可能会比升级 MySQL Shell 和 MySQL Router 产生更大的影响。此外,您应该始终保持 MySQL Shell 和 MySQL Router 的最新版本,即使服务器不是;这对于 InnoDB Clusters 和 ReplicaSet 来说是正确的。

有关使用组复制升级的详细信息,请参阅 升级组复制成员

通过执行以下命令之一停止 MySQL Server:

  • 如果 MySQL Server 正在使用 systemd执行:

    systemctl stop mysqld
    
  • 如果 MySQL Server 正在使用 init.d执行:

    /etc/init.d/mysql stop
    
  • 如果 MySQL Server 正在使用 service执行:

    service mysql stop
    
  • 如果您在 Microsoft Windows 上部署了 MySQL Server ,执行:

    mysqladmin -u root -p shutdown
    
  1. 获取并安装最新版本的 MySQL Server 。
  2. 通过执行以下命令之一启动 MySQL Server :
  • 如果 MySQL Server 正在使用 systemd执行:

    systemctl start mysqld
    
  • 如果 MySQL Server 正在使用 init.d执行:

    /etc/init.d/mysql start
    
  • 如果 MySQL Server 正在使用 service执行:

    service mysql start
    
  • 如果您在 Microsoft Windows 上部署了 MySQL Server ,执行:

    mysqld
    
  1. 升级所有辅助实例后,升级主实例以完成升级过程。

升级后状态检查

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

  1. 通过执行 <ClusterSet>.status()检查 ClusterSet 的状态 。有关 <ClusterSet>.status() 的更多信息,请参阅 8.6 InnoDB ClusterSet 的状态和拓扑
  2. 解决 <ClusterSet>.status() 操作返回的 任何 clusterErrorsstatusText
  3. 通过执行 <ClusterSet>.status() 检查 ClusterSet 中的每个集群并解决任何问题。有关 <Cluster>.status() 的详细信息,请参阅 使用 Cluster.status() 检查集群的状态
  4. 通过执行 <ClusterSet>.listRouters() 检查所有注册的 MySQL 路由器实例的详细信息 。有关更多信息,请参阅 8.5 将 MySQL Router 与 InnoDB ClusterSet 集成
    这些命令允许您检查升级是否成功,或者是否需要完成任何其他步骤。

注意
附加步骤取决于:取决于您要跳过多少版本、要升级的版本以及要从哪个版本开始。

  1. 通过检查 InnoDB ClusterSet 的状态开始升级后检查。此检查使用 <ClusterSet>.status({extended:1} 操作。

    在本例中,我们执行 <ClusterSet>.status({extended:1}

      mysql-js><ClusterSet>.status({extended:1})
    {
        "clusters": {
            "cluster1": {
                "clusterRole": "PRIMARY",
                "globalStatus": "OK",
                "primary": "127.0.0.1:3310",
                "status": "OK_NO_TOLERANCE",
                "statusText": "Cluster is NOT tolerant to any failures.",
                "topology": {
                    "127.0.0.1:3310": {
                        "address": "127.0.0.1:3310",
                        "memberRole": "PRIMARY",
                        "mode": "R/W",
                        "status": "ONLINE",
                        "version": "8.0.28"
                    }
                },
                "transactionSet": "c0361cad-9093-11ec-94ce-0a0027000010:1-90,c0362acf-9093-11ec-94ce-0a0027000010:1"
            },
            "replicacluster1": {
                "clusterErrors": [
                    "ERROR: Cluster members are reachable but they're all OFFLINE.",
                    "WARNING: Replication from the Primary Cluster not in expected state"
                ],
                "clusterRole": "REPLICA",
                "clusterSetReplication": {
                    "applierStatus": "OFF",
                    "applierThreadState": "",
                    "applierWorkerThreads": 4,
                    "receiver": "127.0.0.1:3320",
                    "receiverStatus": "OFF",
                    "receiverThreadState": "",
                    "source": "127.0.0.1:3310"
                },
                "clusterSetReplicationStatus": "STOPPED",
                "globalStatus": "NOT_OK",
                "status": "OFFLINE",
                "statusText": "All members of the group are OFFLINE",
                "topology": {
                    "127.0.0.1:3320": {
                        "address": "127.0.0.1:3320",
                        "instanceErrors": [
                            "NOTE: group_replication is stopped."
                        ],
                        "memberRole": "SECONDARY",
                        "memberState": "OFFLINE",
                        "mode": "R/O",
                        "status": "(MISSING)",
                        "version": "8.0.28"
                    }
                },
                "transactionSet": "1ec95a0b-9094-11ec-9bc5-0a0027000010:1,c0361cad-9093-11ec-94ce
                                   -0a0027000010:1-90,c0362acf-9093-11ec-94ce-0a0027000010:1",
                "transactionSetConsistencyStatus": "OK",
                "transactionSetErrantGtidSet": "",
                "transactionSetMissingGtidSet": ""
            },
            "replicacluster2": {
                "clusterRole": "REPLICA",
                "clusterSetReplication": {
                    "applierStatus": "APPLIED_ALL",
                    "applierThreadState": "Waiting for an event from Coordinator",
                    "applierWorkerThreads": 4,
                    "receiver": "127.0.0.1:3330",
                    "receiverStatus": "ON",
                    "receiverThreadState": "Waiting for source to send event",
                    "source": "127.0.0.1:3310"
                },
                "clusterSetReplicationStatus": "OK",
                "globalStatus": "OK",
                "status": "OK_NO_TOLERANCE",
                "statusText": "Cluster is NOT tolerant to any failures.",
                "topology": {
                    "127.0.0.1:3330": {
                        "address": "127.0.0.1:3330",
                        "memberRole": "PRIMARY",
                        "mode": "R/O",
                        "replicationLagFromImmediateSource": "",
                        "replicationLagFromOriginalSource": "",
                        "status": "ONLINE",
                        "version": "8.0.28"
                    }
                },
                "transactionSet": "329dc243-9094-11ec-b9dd-0a0027000010:1,c0361cad-9093-11ec
                                   -94ce-0a0027000010:1-90,c0362acf-9093-11ec-94ce-0a0027000010:1",
                "transactionSetConsistencyStatus": "OK",
                "transactionSetErrantGtidSet": "",
                "transactionSetMissingGtidSet": ""
            }
        },
        "domainName": "clusterset1",
        "globalPrimaryInstance": "127.0.0.1:3310",
        "metadataServer": "127.0.0.1:3310",
        "primaryCluster": "cluster1",
        "status": "AVAILABLE",
        "statusText": "Primary Cluster available, there are issues with a Replica cluster."
    }
    

    更多有关 <ClusterSet>.status() 的信息,请参阅 ClusterSet.status()

  2. 解决 <ClusterSet>.status({extended:1}) 操作返回的所有错误。
    在本例中,我们在 clusterErrors 中返回了一个错误,通知我们 <ClusterSet>.status({extended:1}) 操作无法连接到任何在线成员,并且 statusText 显示主集群可用,但 InnoDB ClusterSet 中的副本集群存在问题。

    在本例中,我们需要检查 InnoDB Cluster replicacluster1的状态,并确保其重新联机。

  3. 解决了 <ClusterSet>.status({extended:1}) 操作返回的问题后,我们检查 ClusterSet 中每个 InnoDB 集群的状态。

    通过执行 <Cluster>.status() 检查每个 InnoDB 集群的状态。

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

        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 检查集群的状态

    instanceErrors 建议在这次升级中,我们应该在 InnoDB 集群中的每个成员上执行 <Cluster>.rescan()dba.configureInstance()

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

    mysqlsh> cluster1.rescan();
    Rescanning the cluster...
    
    Result of the rescanning operation for the 'MyCluster1' cluster:
    {
        "name": "MyCluster1",
        "newTopologyMode": null,
        "newlyDiscoveredInstances": [],
        "unavailableInstances": [],
        "updatedInstances": []
    }
    

    注意
    只能对 ClusterSet 的单个集群运行 <Cluster>.rescan() ,而不能对整个 ClusterSet 运行。

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

    在本例中,我们对集群中的每个成员执行 dba.configureInstance() ,以确保在实例上启用所需的并行应用程序(parallel-appliers)设置:

      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.
    
  4. 一旦解决了 <ClusterSet>.status({extended:1})<Cluster>.status({extended:1}) 操作返回的问题,就必须运行 <ClusterSet>.listRouters()

    <ClusterSet>.listRouters() 返回所有注册的 MySQL 路由器实例的详细信息。详细信息提供了每个注册的 MySQL Router 实例的信息,如元数据中的名称、主机名、端口等。有关更多信息,请参阅 8.5 将 MySQL Router 与 InnoDB ClusterSet 集成
    例如,在我们的示例 ClusterSet 中,我们执行:

    mysqlsh> <ClusterSet>.listRouters();
    
    WARNING: The following Routers were bootstrapped before the ClusterSet was created: [EXAMPLE::R1]. 
             Please re-bootstrap the Routers to ensure the optimal configurations are set.
    
    {
        "domainName": "MyClusterSet",
        "routers": {
            "EXAMPLE::R1": {
                "hostname": "EXAMPLE",
                "lastCheckIn": "2022-02-23 07:14:50",
                "roPort": 6447,
                "roXPort": 6449,
                "routerErrors": [
                    "WARNING: Router needs to be re-bootstraped."
                ],
                "rwPort": 6446,
                "rwXPort": 6448,
                "targetCluster": null,
                "version": "8.0.28"
            }
        }
    }
    

    返回的信息显示:

    • MySQL 路由器实例的名称。
    • 最后一个签入(check-in)时间戳,由存储在元数据中的 MySQL 路由器的定期 ping 生成。
    • 运行 MySQL 路由器实例的主机名。
    • MySQL 路由器为 经典 MySQL 协议 连接发布的只读和读写端口。
    • MySQL 路由器为 X 协议 连接发布的只读和读写端口。
    • 目标集群的名称。在本例中,MySQL Router 将流量从客户端应用程序引导到 InnoDB ClusterSet 部署中的集群,该部署当前是主集群。
    • 此 MySQL 路由器实例的版本。

    在本例中,还返回了有关 routerErrors 的信息。

    routerErrors 通知我们 MySQL 路由器需要重新引导。出现此错误的原因是,如果您基于该独立集群创建 ClusterSet, 则必须再次引导 MySQL 路由器,以通知路由器它正在使用 ClusterSet。

    解决这些警告以完成升级后检查。如果没有收到任何警告,升级后检查将完成。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

独上西楼影三人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值