文件首頁
MySQL Shell 9.0
下載本手冊
PDF (美式信紙) - 2.3Mb
PDF (A4) - 2.3Mb


MySQL Shell 9.0  /  ...  /  InnoDB Cluster 升級

7.10.1 InnoDB Cluster 升級

若要升級 InnoDB Cluster 中的伺服器執行個體,請完成下列步驟

檢查已安裝二進位檔案的版本

  • 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

    或者,在 Linux 系統上使用 systemd,發出下列命令來停止 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 指令檔。

    或者,在 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 Cluster 中繼資料

    • 若要升級 InnoDB Cluster 的中繼資料,請將 MySQL Shell 的全域工作階段連線至您的叢集,並使用 dba.upgradeMetadata() 作業,將叢集的中繼資料升級至新的中繼資料。

    中繼資料升級

    如果叢集已使用最新版本,則中繼資料升級可能不會執行任何動作。

升級 MySQL Server

藉由在升級主要執行個體之前升級所有次要執行個體來升級 MySQL Server。

升級 MySQL Server 是選用的

升級 MySQL Server 是選用的。伺服器升級的影響可能大於升級 MySQL Shell 和 MySQL Router。此外,您應該始終保持 MySQL Shell 和 MySQL Router 處於最新版本,即使伺服器不是;這對 InnoDB Cluster 和 ReplicaSet 來說都是如此。

  1. 發出下列其中一個命令來停止 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
  2. 取得並安裝最新版本的 MySQL Server。

  3. 發出下列其中一個命令來啟動 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
  4. 當所有次要執行個體都升級後,升級主要執行個體以完成升級程序。

升級後狀態檢查

升級 MySQL Router、MySQL Shell 和 MySQL Server 後

  1. 發出 <Cluster>.status()檢查叢集。如需有關 <Cluster>.status() 的詳細資訊,請參閱使用 Cluster.status() 檢查叢集狀態

  2. 解決 <Cluster>.status() 作業傳回的任何 clusterErrorsstatusText

這些命令可讓您檢查升級是否成功,或是否需要完成任何其他步驟。

注意

其他步驟取決於您跳過了多少個版本、您要升級的版本以及您來自哪個版本。

  1. 發出 <Cluster>.status() 來檢查每個 InnoDB Cluster 的狀態。

    在下列範例中,<Cluster>.status({extended: true}) 用於提供有關叢集狀態的更詳細資訊,並傳回兩個問題

        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()

    ...
    "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() 作業可讓您重新掃描叢集,以尋找新的和過時的群組複寫執行個體,以及所用拓撲模式的變更。如需詳細資訊,請參閱重新掃描叢集

    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 Cluster

    在此範例中,我們在 InnoDB Cluster 中的每個成員上發出 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.

如需疑難排解叢集升級的相關資訊,請參閱疑難排解 InnoDB Cluster 升級