暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

8.10 升级InnoDB ClusterSet

由迪 2024-03-05
213

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

  1. 升级MySQL Route
  2. 升级 MySQL Shell
  3. 升级MySQL服务器
  4. 升级后状态检查

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

  • ****mysqlrouter --version****:检查安装的 MySQL Router 的版本。
  • ****mysqlsh --version****:检查安装的 MySQL Shell 版本。
  • ****mysqld --version****:检查安装的 MySQL 服务器的版本。

升级 MySQL 路由器。

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

  1. 停止 MySQL 路由器。

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

    ./stop.sh
    

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

    .\stop.ps1
    

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

    systemctl stop mysqlrouter.service
    

    否则,杀死关联的mysqlrouter进程的 进程 ID (PID)

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

  3. 启动 MySQL 路由器。

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

    ./start.sh
    

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

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

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

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

    systemctl start mysqlrouter.service
    

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

    .\start.ps1
    

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

    mysqlrouter --version
    

升级 MySQL Shell

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

  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服务器

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

升级每个集群、主集群或副本集群时,请先升级所有辅助实例,然后再升级主实例。

升级 MySQL 服务器是可选的

升级 MySQL 服务器是可选的。服务器升级比升级 MySQL Shell 和 MySQL Router 产生的影响更大。另外,你应该始终将 MySQL Shell 和 MySQL Router 保持在最新版本,即使服务器不是;对于 InnoDB Cluster 和 ReplicaSet 来说也是如此。

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

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

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

      systemctl stop mysqld
      
    • 如果 MySQL 服务器正在使用 init.d问题:

      /etc/init.d/mysql stop
      
    • 如果MySQL Server正在使用 服务 问题:

      service mysql stop
      
    • 如果您在 Microsoft Windows 上部署 MySQL Server 问题:

      mysqladmin -u root -p shutdown
      
  2. 获取并安装最新版本的 MySQL Server。

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

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

      systemctl start mysqld
      
    • 如果 MySQL 服务器正在使用 init.d 问题:

      /etc/init.d/mysql start
      
    • 如果MySQL Server正在使用 服务 问题:

      service mysql start
      
    • 如果您在 Microsoft Windows 上部署 MySQL Server 问题:

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

升级后状态检查

升级 MySQL Router 后,MySQL Shell 和 MySQL Server 都会升级:

  1. 通过发出 来 检查 ClusterSet 的状态<ClusterSet>.status()。有关 的更多信息<ClusterSet>.status(),请参阅第 8.6 节 “InnoDB ClusterSet 状态和拓扑”
  2. 解决任何 clusterErrors``statusText操作返回的 问题 <ClusterSet>.status()
  3. 通过发出命令来 检查 ClusterSet 中的每个集群<Cluster>.status()并解决任何问题。有关 的更多信息 <Cluster>.status(),请参阅 使用 检查集群的状态 Cluster.status()
  4. 通过发出 来检查所有注册的 MySQL Router 实例的详细信息<ClusterSet>.listRouters()。有关更多信息,请参阅 将 MySQL Router 与 InnoDB ClusterSet 集成

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

笔记

额外的步骤取决于;您要跳过多少个版本、要升级哪个版本以及要从哪个版本开始。

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

    在这个例子中,我们发出 <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 中的副本集群存在问题。

    解释  ...
      "replicacluster1": {
        "clusterErrors": [
                      "ERROR: Could not connect to any ONLINE members but there are unreachable instances 
                              that could still be ONLINE."
                  ],
      ...        
       "statusText": "Primary Cluster available, there are issues with a Replica cluster."
    }
    

    在此示例中,我们需要检查 InnoDB Cluster 的状态replicacluster1并确保其重新上线。

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

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

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

    解释    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 中的每个成员 发出<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 Cluster 以查找新的和过时的组复制实例,以及所用拓扑模式的更改。有关更多信息,请参阅 重新扫描集群

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

    笔记

    您只能<Cluster>.rescan()在 ClusterSet 的各个 Cluster 上运行,而不能在整个 ClusterSet 上运行。

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

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

    解释  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 Router 实例的详细信息。详细信息提供有关每个注册的 MySQL Router 实例的信息,例如元数据中的名称、主机名、端口等。有关更多信息,请参阅 将 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 路由器实例的名称。
    • 最后签入时间戳,由存储在元数据中的 MySQL 路由器的定期 ping 生成。
    • 运行 MySQL Router 实例的主机名。
    • MySQL 路由器为经典 MySQL 协议连接发布的只读和读写端口。
    • MySQL 路由器为 X 协议连接发布的只读和读写端口。
    • 目标集群的名称。在此示例中,MySQL Router 将流量从客户端应用程序定向到 InnoDB ClusterSet 部署中当前为主集群的集群。
    • 此 MySQL Router 实例的版本。

    在这个例子中,还有关于 routerErrors返回的信息。

    通知routerErrors我们 MySQL Router 需要重新引导。出现此错误的原因是,如果您基于该独立 Cluster 创建 ClusterSet,则必须再次引导 MySQL Router 以通知 Router 它正在处理 ClusterSet。

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

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论