升級 OpenResty Edge

我們建議您升級生產環境前,使用生產環境的資料構建一個與生產環境一樣的測試環境進行升級測試,測試透過後再進行正式環境的升級。詳細步驟見 克隆 OpenResty Edge 環境

1. 升級 Log Server DB

  • 如果您想要進行線上升級(推薦),可以直接下載安裝器

    curl -O https://openresty.com/client/oredge/openresty-edge-installer.sh
    
  • 如果您想要用 bundle 包進行升級

    1. 請到下載中心 下載以下檔案,如果沒有請與我們聯絡:

      a. openresty-edge-bundle-VERSION.tar.gz:包含 OpenResty Edge 的業務包、配置包及初始化資料等。舊名稱是 openresty-edge-bundle-VERSION.tar.gz

    2. 解壓 openresty-edge-bundle-VERSION.tar.gz 並進入解壓後的目錄

      tar xf openresty-edge-bundle-VERSION.tar.gz
      cd openresty-edge-bundle-VERSION
      
  • 執行安裝器

    sudo /bin/bash openresty-edge-installer.sh
    
  • 輸入您要執行的操作 Upgrade

    > Checking network...
    > Welcome to the OpenResty Edge Installer.
    [1] Install
    [2] Upgrade
    [3] Downgrade
    [4] Uninstall
    [5] Self Check
    [6] Get Default Info
    What would you like to do? 2
    > You chose: Upgrade.
    
  • 輸入您想要升級的版本 (可以從 變更日誌 獲取最新的版本資訊),如果使用安裝器中的預設版本,可以直接回車

    Which version would you like to upgrade to? (Default: 23.12.1, Press Enter to use the default version)
    [WARN] Using default version number: 23.12.1
    
  • 輸入您要升級的元件 Log Server DB

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 1
    > You chose: Edge Log Server Database
    
  • 如果成功,最後會有如下提示

    Great! update log-server database successfully.
    

2. 升級 Log Server

  • 操作步驟相同,升級時元件選擇 Log Server

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 2
    > You chose: Edge Log Server.
    
  • 如果成功,最後會有如下提示

    Great! Upgrade openresty-edge-log-server successfully.
    

在升級過程中,安裝器會自動生成一個包含歷史操作記錄的目錄。您將看到類似以下的提示資訊:

This execution process will be saved in the /home/USER/openresty-edge-VERSION/oredge-history/2024-07-01-02-03-04

請注意,這個目錄對於未來可能的降級操作至關重要。因此,我們強烈建議您保留此目錄,不要刪除它。

3. 升級 Edge Node

3.1 備份 Edge Node 資料庫

如果你當前的 OpenResty Edge Admin 版本小於 1.3.0,則跳過此步驟。

  • 登入 OpenResty Edge Admin 控制檯
  • 【閘道器叢集】-【備份與還原】-【開始備份】

3.2 遷移流量(可選)

為避免影響業務,Edge Node 節點升級前,把該節點上的流量轉移到其他未升級節點上。 此步驟為可選,但是強烈建議對最初升級的少數 Edge Node 執行此步驟:

  • 遷移走流量
  • 升級
  • 驗證

沒問題後,再升級剩下的 Edge Node。另外,升級過程中請關注錯誤日誌。

如果使用的 OpenResty Edge 的 DNS 控制流量,請按以下步驟把即將升級的 Edge Node 節點下線。

  • 進入 OpenResty Edge 控制檯
  • 進入【閘道器叢集】頁面
  • 對節點所在叢集進行【編輯】
  • 修改節點【狀態】為【關閉 DNS,關閉叢集快取】
  • 儲存

等待節點不再有流量或只有少量流量。可透過檢視訪問日誌確定:

tail -f /usr/local/oredge-node/logs/access.log

3.3 升級

  • 操作步驟相同,升級時元件選擇 Edge Node

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 3
    > You chose: Edge Node.
    
  • 如果成功,最後會有如下提示

    Great! Upgrade openresty-edge-node successfully.
    

在升級過程中,安裝器會自動生成一個包含歷史操作記錄的目錄。您將看到類似以下的提示資訊:

This execution process will be saved in the /home/USER/openresty-edge-VERSION/oredge-history/2024-07-01-02-03-04

請注意,這個目錄對於未來可能的降級操作至關重要。因此,我們強烈建議您保留此目錄,不要刪除它。

4. 升級 Edge Admin 資料庫

  • 操作步驟相同,升級時元件選擇 Edge Admin DB

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 4
    > You chose: Edge Admin DB.
    
  • 備份 Edge Admin 資料庫

    Do you want to backup db? [Y/N]:  y
    
  • 如果成功,最後會有如下提示

    Great! update admin database successfully.
    

5. 升級 Edge Admin-web

  • 操作步驟相同,升級時元件選擇 Edge Admin

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 5
    > You chose: Edge Admin.
    
  • 如果成功,最後會有如下提示

    Great! Upgrade openresty-edge-admin successfully.
    

在升級過程中,安裝器會自動生成一個包含歷史操作記錄的目錄。您將看到類似以下的提示資訊:

This execution process will be saved in the /home/USER/openresty-edge-VERSION/oredge-history/2024-07-01-02-03-04

請注意,這個目錄對於未來可能的降級操作至關重要。因此,我們強烈建議您保留此目錄,不要刪除它。

6. (可選)升級 WAF 規則集

  • 首先備份 WAF 規則集:
    • 登入 Edge Admin 管理介面
    • 進入 全域性配置 > 全域性 WAF > 匯出 WAF 規則

接著升級 WAF 規則集,有兩個方法,選擇其中一個即可:

  • 方法一:透過下載中心下載 WAF 規則集,然後在 進入 全域性配置 > 全域性 WAF > 匯入 WAF 規則,進行升級。

  • 方法二:與前面的操作步驟相同,升級時元件選擇 Edge Built-in WAF Rules

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 6
    > You chose: Edge Built-in WAF Rules.
    

7. 重新編譯

  • 操作步驟相同,升級時元件選擇 Rebuild

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 7
    > You chose: Rebuild.
    
  • 先重新編譯幾個流量較少的不包含泛域名的 HTTP 應用,再編譯幾個大流量的不包含泛域名的 HTTP 應用

    Do you want to rebuild one application for test? [Y/N]:  y
    Please input the application id: 1
    rebuild application 1
    
  • 再繼續根據提示進行編譯

    Do you want to rebuild upgrade config? [Y/N]:  y
    rebuild upgrade config
    recompile upgrade configurations successfully
    
    Do you want to rebuild all wilecard apps? [Y/N]:  y
    rebuild all wilecard apps
    
    Do you want to rebuild all apps? [Y/N]:  y
    Do you want to compile concurrently? [Y/N]:  n
    rebuild all apps
    
    Do you want to rebuild all http_proxy apps? [Y/N]:  y
    rebuild all http_proxy apps
    
    Do you want to rebuild all socks5_apps? [Y/N]:  y
    rebuild all sock5_proxy apps
    
    Do you want to rebuild global? [Y/N]:  y
    rebuild global
    recompile global successfully
    
    Do you want to rebuild waf? [Y/N]:  y
    rebuild waf
    recompiled all of the WAF rule sets successfully.
    
    Do you want to rebuild dns? [Y/N]:  y
    rebuild dns
    recompile dns successfully.
    
    Do you want to rebuild global-action? [Y/N]:  y
    rebuild global-action
    recompile global action successfully
    
    Do you want to rebuild gateway? [Y/N]:  y
    rebuild gateway
    recompiled gateway successfully
    
    rebuild done!
    

如果業務指標都表現正常,升級完成!

如果 HTTP/HTTPS 應用數量很多,可能這一步的編譯時間會比較長:

Do you want to rebuild all apps? [Y/N]:  y

此時,接下來可以選擇併發編譯,將啟動 4 個程序來編譯:

Do you want to compile concurrently? [Y/N]:  y

如果不夠快,可以修改安裝器指定更大的併發,但是不能超過 8,比如:

sudo /bin/bash utils/parallel-recompile.sh 8

8. (可選)升級完成後

在執行完前面的步驟並驗證完成後,可以執行此步驟來清理不再需要的資料庫欄位或者對資料庫欄位增加約束。

  • 操作步驟相同,升級時元件選擇 Clean db after upgrade

    [WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/.
    [1] Edge Log Server Database
    [2] Edge Log Server
    [3] Edge Node
    [4] Edge Admin Database
    [5] Edge Admin
    [6] Edge Built-in WAF Rules
    [7] Rebuild
    [8] Clean database after upgrade
    [9] Exit
    What would you like to do? 8
    > You chose: Clean db after upgrade.
    
  • 如果成功,最後會有如下提示

    Great! upgrade admin database successfully.
    

有問題我們隨時溝通 :)