文件首頁
MySQL Shell 8.4
下載本手冊
PDF (US Ltr) - 2.2Mb
PDF (A4) - 2.3Mb


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

7.10.1 InnoDB Cluster 升級

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

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

  • mysqlrouter --version:檢查已安裝的 MySQL Router 版本。

  • mysqlsh --version:檢查已安裝的 MySQL Shell 版本。

  • mysqld --version:檢查已安裝的 MySQL 伺服器版本。

升級 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 伺服器

藉由在升級主要執行個體之前,先升級所有次要執行個體來升級 MySQL 伺服器。

升級 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 伺服器使用 service,請發出

      service mysql stop
    • 如果您在 Microsoft Windows 上部署 MySQL 伺服器,請發出

      mysqladmin -u root -p shutdown
  2. 取得並安裝最新版本的 MySQL 伺服器。

  3. 發出下列其中一個命令來啟動 MySQL 伺服器

    • 如果 MySQL 伺服器使用 systemd,請發出

      systemctl start mysqld
    • 如果 MySQL 伺服器使用 init.d,請發出

      /etc/init.d/mysql start
    • 如果 MySQL 伺服器使用 service,請發出

      service mysql start
    • 如果您在 Microsoft Windows 上部署 MySQL 伺服器,請發出

      mysqld
  4. 當所有次要執行個體都升級之後,請升級主要執行個體來完成升級程序。

升級後狀態檢查

在升級 MySQL Router、MySQL Shell 和 MySQL 伺服器之後

  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() 操作可讓您重新掃描叢集,以查找新的和過時的 Group Replication 實例,以及所用拓撲模式的變更。有關更多資訊,請參閱重新掃描叢集

    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 叢集所需的所有設定。有關更多資訊,請參閱為 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.

有關疑難排解叢集升級的資訊,請參閱疑難排解 InnoDB 叢集升級