附註:

使用 Leapp 升級 Oracle Linux

簡介

Leapp 公用程式是更新和升級作業系統與應用程式的架構。公用程式的元件套件可建立不同工作流程至設定檔以更新軟體。

Leapp 作業包含兩個階段:

Leapp 可用於升級 Oracle Linux Oracle Cloud Infrastructure 執行個體以及 Oracle Linux 內部部署系統。

本自學課程分為兩部分:

  1. 它會引導您將 Oracle Linux 7 執行處理升級至 Oracle Linux 8。
  2. 它會引導您將 Oracle Linux 8 執行處理升級至 Oracle Linux 9。

備註:在生產環境中使用 Leapp 之前,建議您先熟悉測試環境中的 Leapp 升級程序。這可讓您更進一步瞭解程序及其報告,並測試可能遇到的任何安全性或相容性,以及升級前和升級後問題。

注意: Leapp 公用程式僅用於將作業系統 (OS) 升級,例如,從目前的 Oracle Linux 8 版升級至目前的 Oracle Linux 9 版。使用的步驟專用於佈建實驗室執行處理時所部署的 Oracle Linux 版本。雖然本教學課程示範從 Oracle Linux 7 升級至 Oracle Linux 8,然後繼續使用相同的系統從 Oracle Linux 8 升級至 Oracle Linux 9,但在生產環境中不建議透過多個 Oracle Linux 版本升級系統。本教學課程中的程序不適用於任何其他作業系統或版本,而且不受支援。

目標

在本教學課程中,您將學習到:

必要條件

部署 Oracle Linux

注意:如果是在您自己的租用戶中執行,請先閱讀 linux-virt-labs GitHub 專案 README.md 並完成先決條件,再部署實驗環境環境。

  1. 在 Luna Desktop 上開啟終端機。

  2. 複製 linux-virt-labs GitHub 專案。

    git clone https://github.com/oracle-devrel/linux-virt-labs.git
    
  3. 變更至工作目錄。

    cd linux-virt-labs/ol
    
  4. 安裝必要的集合。

    ansible-galaxy collection install -r requirements.yml
    
  5. 部署實驗環境環境。

    ansible-playbook create_instance.yml -e localhost_python_interpreter="/usr/bin/python3.6" -e os_version="7.9"
    

    自由實驗環境環境需要額外的變數 local_python_interpreter,此變數會設定在 localhost 上執行的播放 ansible_python_interpreter。由於環境會安裝 Oracle Cloud Infrastructure SDK for Python 的 RPM 套件 (位於 python3.6 模組底下),因此需要此變數。

    預設部署資源配置使用 AMD CPU 和 Oracle Linux 7。若要使用 Intel CPU 或 Oracle Linux 8,請在部署命令中新增 -e instance_shape="VM.Standard3.Flex"-e os_version="8"

    重要事項: 請等待播放手冊順利執行,然後到達暫停工作。在手冊的這個階段,Oracle Linux 的安裝已完成,實例已就緒。記下先前的播放,此播放會列印其部署節點的公用和專用 IP 位址,以及執行實驗室時所需的任何其他部署資訊。

準備從 Oracle Linux 7 升級至 Oracle Linux 8

此實驗室中使用的執行處理已預先設定環境特定的設定值,例如代理主機設定值。

通常會略過某些升級前檢查,因為在此環境中不需要這些檢查。

您可以在此文件連結中檢視使用 Leapp 升級之前應進行的完整系統和核心先決條件和升級前檢查清單:Oracle Linux 8 - Performing System Upgrades with Leapp

  1. 開啟終端機,並透過 SSH 連線至 ol-node-01 執行處理。

    ssh oracle@<ip_address_of_instance>
    
  2. 確認系統語言環境設定為 en_US.UTF-8

    cat /etc/locale.conf
    

    若未正確設定語言環境,請使用 sudo localectl set-locale LANG=en_US.UTF-8 指令來設定語言環境。

更新至最新的套裝程式

將所有系統套裝軟體更新為最新版本。

sudo yum update -y

這需要幾分鐘的時間,當更新完成時,請重新啟動系統。

sudo reboot

請稍候幾分鐘的時間讓重新啟動完成,然後將您的 SSH 連線重新連線至執行處理。

如果連線失敗,請稍候再試一次。

安裝 Leapp 公用程式

安裝 Leapp 公用程式及其支援的儲存區域。

sudo yum install -y leapp-upgrade --enablerepo=ol7_leapp,ol7_latest

執行升級前檢查

升級前程序會評估系統是否已準備好進行成功升級。它會識別可能影響或阻止升級程序的潛在問題。

如需升級前準備步驟在您自己的系統上執行的資訊,請參閱 Oracle 文件中的升級準備

您可以隨時使用升級前檢查來評估系統的狀態,並識別可能發生衝突的位置。它不會變更系統,但會建立報告檔案與除錯日誌,其中包含關於系統的資訊、其配置,以及潛在的升級問題。

  1. 執行 leapp preupgrade 命令以啟動升級前處理作業。

    此實驗環境系統是雲端執行處理,因此請使用命令交換器 --oci

    sudo leapp preupgrade --oci
    

    如果系統是非雲端系統,則使用交換器 --oraclelinux

    --oci--oraclelinux 是方便使用的交換器,可用來預先設定與雲端或非雲端系統相關的儲存庫和組態資訊。

    • 範例輸出:
    Debug output written to /var/log/leapp/leapp-preupgrade.log
    
    ============================================================
                          REPORT OVERVIEW                       
    ============================================================
    
    Upgrade has been inhibited due to the following problems:
        1. Possible problems with remote login using root account
        2. Missing required answers in the answer file
    
    HIGH and MEDIUM severity reports:
        1. Difference in Python versions and support in OL 8
        2. Detected customized configuration for dynamic linker.
        3. Default Boot Kernel
    
    Reports summary:
        Errors:                      0
        Inhibitors:                  2
        HIGH severity reports:       2
        MEDIUM severity reports:     1
        LOW severity reports:        5
        INFO severity reports:       2
    
    Before continuing consult the full report:
        A report has been generated at /var/log/leapp/leapp-report.json
        A report has been generated at /var/log/leapp/leapp-report.txt
    
    ============================================================
                       END OF REPORT OVERVIEW                   
    ============================================================
    
    Answerfile has been generated at /var/log/leapp/answerfile
      
    

    leapp-report.txtleapp-report.json 檔案以及 answerfile 都已建立。除錯資訊會儲存在 leapp-preupgrade.log 檔案中。

    在此環境中,在 Reports summary: 節下,Inhibitors: 表示有兩個會禁止升級的問題。另有其他非禁止的嚴重度問題列示為 HIGHMEDIUMLOWINFO,但無法進行升級。

    這些內容也詳述於 leapp-report 文字和 JSON 檔案中。

  2. 檢查 leapp-report.txt 檔案。

    sudo cat /var/log/leapp/leapp-report.txt
    

    識別標示為 Risk Factor: high (inhibitor) 的高風險項目。這些將會讓升級無法完成。

    此報表提供問題的摘要,並提供解決方法。

    此報表是有用的自我檢查工具,可讓您檢視系統中設定的項目,以及可能存在哪些衝突 (無論您是否會升級)。

  3. 編輯 /etc/ssh/sshd_config 以取消註解 PermitRootLogin 項目並新增 PermitRootLogin prohibit-password 項目來清除第一個抑制器。

    sudo sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/;/PermitRootLogin yes/a PermitRootLogin prohibit-password' /etc/ssh/sshd_config
    

    請檢查 /etc/ssh/sshd_config 檔案以確認新的設定值。

    sudo cat /etc/ssh/sshd_config
    

    確認存在並啟用這兩個項目。

    • 範例輸出:
    .   
    # Authentication:
    
    #LoginGraceTime 2m
    PermitRootLogin yes
    PermitRootLogin prohibit-password
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10
    .
    

    注意:如果您偏好使用 sudo vi /etc/ssh/sshd_config 命令編輯 sshd_config ,然後新增兩個設定值。

  4. 檢查 answerfile

    sudo cat /var/log/leapp/answerfile
    
    • 範例輸出:
    [remove_pam_pkcs11_module_check]  
    # Title:              None  
    # Reason:             Confirmation  
    # =================== remove_pam_pkcs11_module_check.confirm ==================  
    # Label:              Disable pam_pkcs11 module in PAM configuration? If no, the upgrade process will be interrupted.  
    # Description:        PAM module pam_pkcs11 is no longer available in OL-8 since it was replaced by SSSD.  
    # Type:               bool  
    # Default:            None  
    # Available choices: True/False  
    # Unanswered question. Uncomment the following line with your answer  
    # confirm =  
    

    Available Choices: True/False 區段會通知如何修改 answerfile 以解決找到的問題。

    使用 sudo leapp answer 命令提供 [remove_pam_pkcs11_module_check] PAM 模組項目的答案 True

    sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=True
    

    注意:如果您偏好使用 sudo vi /var/log/leapp/answerfile 命令編輯 answerfile ,然後插入 True 設定。

  5. 確認 answerfile 已經修改。

    sudo cat /var/log/leapp/answerfile
    
    • 範例輸出:
    [remove_pam_pkcs11_module_check]  
    confirm = True  
    

    請記住, answerfile 中的所有項目都必須回答,而且 leapp-report.txt 檔案中的任何高風險 Risk Factor: high (inhibitor) 項目都必須解析。

    您可以隨時執行升級前命令來產生報告檔案,並確定已處理必要的項目。

  6. 重複升級前命令來驗證沒有禁止者可防止升級。Inhibitors: 行應該顯示 0,您才能繼續升級。

    • 範例輸出:
    Debug output written to /var/log/leapp/leapp-preupgrade.log
    
    ============================================================
                          REPORT OVERVIEW                       
    ============================================================
    
    HIGH and MEDIUM severity reports:
        1. Detected customized configuration for dynamic linker.
        2. Difference in Python versions and support in OL 8
        3. Module pam_pkcs11 will be removed from PAM configuration
        4. Default Boot Kernel
    
    Reports summary:
        Errors:                      0
        Inhibitors:                  0
        HIGH severity reports:       2
        MEDIUM severity reports:     2
        LOW severity reports:        5
        INFO severity reports:       2
    
    Before continuing consult the full report:
        A report has been generated at /var/log/leapp/leapp-report.json
        A report has been generated at /var/log/leapp/leapp-report.txt
    
    ============================================================
                       END OF REPORT OVERVIEW                   
    ============================================================
    
    Answerfile has been generated at /var/log/leapp/answerfile
    

升級系統

若要在升級後進行比較,請確認系統的目前作業系統和核心版本。

  1. 檢查系統上執行的 Oracle Linux 版本。

    sudo cat /etc/oracle-release
    
  2. 檢查使用的核心版本。

    uname -r
    
  3. 執行升級處理程序。

    sudo leapp upgrade --oci
    

    注意:實驗環境系統是一個雲端執行處理,因此再度使用命令交換器 --oci

    升級程序大約需要 10 分鐘,並在完成後返回指令提示。

    • 範例輸出:
    Complete!
    ====> * add_upgrade_boot_entry
            Add new boot entry for Leapp provided initramfs.
    A reboot is required to continue. Please reboot your system.
    
    
    Debug output written to /var/log/leapp/leapp-upgrade.log
    
    ============================================================
                          REPORT OVERVIEW                       
    ============================================================
    
    HIGH and MEDIUM severity reports:
        1. Difference in Python versions and support in OL 8
        2. Detected customized configuration for dynamic linker.
        3. Module pam_pkcs11 will be removed from PAM configuration
        4. Default Boot Kernel
    
    Reports summary:
        Errors:                      0
        Inhibitors:                  0
        HIGH severity reports:       2
        MEDIUM severity reports:     2
        LOW severity reports:        5
        INFO severity reports:       2
    
    Before continuing consult the full report:
        A report has been generated at /var/log/leapp/leapp-report.json
        A report has been generated at /var/log/leapp/leapp-report.txt
    
    ============================================================
                       END OF REPORT OVERVIEW                   
    ============================================================
    
    Answerfile has been generated at /var/log/leapp/answerfile
      
    

    升級程序也更新了 answerfileleapp-report.txt ,並建立一個 leapp-upgrade.log 檔案。

    注意:如果您尚未處理 leapp-report.txt 檔案中的 answerfile 項目和 Risk Factor: high (inhibitor) 項目,處理作業將會終止回命令行,並通知發生的問題。

  4. 升級完成後,請重新啟動系統。

    sudo reboot
    

    重新開機將會中斷 SSH 連線。在啟動程序期間,Leapp 程序會自動升級套裝軟體。

    升級作業也包含多次自動重新啟動。在完成所有重新啟動之前,您將無法重新連線 SSH 階段作業。

    等待大約 15 分鐘,然後將 SSH 階段作業重新連線至系統。如果連線失敗,請稍候幾分鐘後再試一次。

驗證升級

比較系統目前使用的作業系統版本和核心與升級前版本。

  1. 檢查執行中的 Oracle Linux 版本。

    sudo cat /etc/oracle-release
    
  2. 檢查使用的核心版本。

    uname -r
    

    隨著升級完成,您現在會看到系統正在執行 Oracle Linux 8.x ,核心版本會顯示 el8

升級之後以及程序所做的任何變更,請務必確認已升級的系統維持在支援的狀態。

如需有關程序和檢查以協助將已升級系統傳回作業的資訊和指引,請參閱文件中的升級後資訊

建議您閱讀在您自己的系統上執行的 Leapp 升級。

從 Oracle Linux 8 升級至 Oracle Linux 9

您將使用 Leapp 將實驗室系統從 Oracle Linux 8 升級至 Oracle Linux 9。

注意:本實驗環境可讓您繼續使用先前步驟的已升級系統,以準備從 Oracle Linux 8 升級至 9。不過,不建議在生產環境中使用此方式將 Oracle Linux 7 系統升級至 Oracle Linux 9。

注意: Leapp 公用程式僅用於將作業系統升級,例如,從目前的 Oracle Linux 8 發行版本升級到目前的 Oracle Linux 9 版本。本教學課程中的程序不適用於任何其他作業系統或版本,而且不受支援。

準備從 Oracle Linux 8 升級至 Oracle Linux 9

在使用 Leapp 將系統升級至 Oracle Linux 9 之前,必須先進行一些準備。

您可以在此文件連結中檢視使用 Leapp 升級之前應進行的完整系統和核心先決條件和升級前檢查清單:Oracle Linux 9 - Performing System Upgrades with Leapp

例如,請確保 /boot 分割區中有足夠的磁碟空間特別重要,請參閱文件中的 Requirements for Upgrading 小節。

  1. 開啟終端機,並透過 SSH 連線至 ol-node-01 執行處理。

    ssh oracle@<ip_address_of_instance>
    
  2. 確認系統語言環境設定為 en_US.UTF-8

    cat /etc/locale.conf
    

    若未正確設定語言環境,請使用 sudo localectl set-locale LANG=en_US.UTF-8 指令來設定語言環境。

  3. 將所有系統套裝軟體更新為最新版本。

    sudo dnf update -y
    

    完成更新後,請重新啟動系統。

    sudo reboot
    

    請稍候幾分鐘的時間讓重新啟動完成,然後將您的 SSH 連線重新連線至執行處理。

    如果連線失敗,請稍候再試一次。

  4. 編輯 /etc/dnf/dnf.conf 以註釋參照先前升級之任何舊版應用程式套裝程式的 exclude= 行。

    注意:只有在系統先前從 Oracle Linux 7 升級至 8 之後,才會執行此步驟來準備系統。

    sudo sed -i 's/exclude=python2-leapp,snactor,leapp-upgrade-el7toel8,leapp/#exclude=python2-leapp,snactor,leapp-upgrade-el7toel8,leapp/' /etc/dnf/dnf.conf
    
  5. 安裝 NetworkManager 套裝軟體,然後取消遮罩並啟動服務。以此順序執行這些命令。

    注意:只有在系統先前從 Oracle Linux 7 升級至 8 之後,才會執行此步驟來準備系統。

    sudo dnf install -y NetworkManager 
    sudo systemctl unmask NetworkManager 
    sudo systemctl start NetworkManager 
    sudo systemctl enable NetworkManager
    
    
  6. 移除任何不再適用的核心、核心模組和剩餘套裝程式。在名稱中以 el7 搜尋任何項目。

    注意:只有在系統先前從 Oracle Linux 7 升級至 8 之後,才會執行此步驟來準備系統。

    sudo rpm -qa | grep el7
    
    • 範例輸出:
    python2-leapp-0.17.0-1.0.2.el7_9.noarch
    kernel-uek-5.4.17-2136.336.5.1.el7uek.x86_64
    kernel-uek-5.4.17-2136.338.4.1.el7uek.x86_64
    leapp-0.17.0-1.0.2.el7_9.noarch
    kernel-3.10.0-1160.119.1.0.5.el7.x86_64
    leapp-upgrade-el7toel8-0.20.0-2.0.5.el7_9.noarch
    

    注意:您在實驗室中看到的檔案名稱可能會與此處範例輸出中顯示的不同。

    sudo dnf remove -y leapp-upgrade
    sudo dnf remove -y python2-leapp
    sudo dnf remove -y *el7*
    
    

    備註:如果您看到無法移除 Leapp 套件的錯誤,請驗證您已對 dnf.conf 檔案進行較早的編輯。

  7. 清除 DNF 快取中的所有項目。

    sudo dnf clean all
    

安裝 Oracle Linux 8 適用的 Leapp 公用程式

使用的 Leapp 公用程式專用於要升級的作業系統,因此必須安裝 Oracle Linux 8 版的 Leapp 公用程式。這就是為什麼您先前可能已從先前的升級中移除任何剩餘的舊版 Leapp 套件。

安裝 Oracle Linux 8 Leapp 公用程式。

   sudo dnf install -y leapp-upgrade

執行升級前檢查

如需升級前準備步驟在您自己的系統上執行的資訊,請參閱 Oracle 文件中的升級準備

執行 leapp preupgrade 命令來測試升級程序,並報告任何錯誤或抑制程式。

在此雲端執行個體中,我們再次使用指令開關 --oci

sudo leapp preupgrade --oci

============================================================
                      REPORT OVERVIEW                       
============================================================

Upgrade has been inhibited due to the following problems:
    1. Firewalld Configuration AllowZoneDrifting Is Unsupported
    2. Network configuration with disabled NetworkManager support detected
    3. OSWatcher is removed from OL9.
    4. Missing required answers in the answer file

HIGH and MEDIUM severity reports:
    1. Remote root logins globally allowed using password
    2. Packages not signed by Oracle found on the system
    3. Default Boot Kernel

Reports summary:
    Errors:                      0
    Inhibitors:                  4
    HIGH severity reports:       2
    MEDIUM severity reports:     1
    LOW severity reports:        1
    INFO severity reports:       3

Before continuing consult the full report:
    A report has been generated at /var/log/leapp/leapp-report.json
    A report has been generated at /var/log/leapp/leapp-report.txt

============================================================
                   END OF REPORT OVERVIEW                   
============================================================

檢查 Reports summary: 區段中是否有任何抑制者的輸出。

此外,請檢查 /var/log/leapp/leapp-report.txt 中是否有任何禁止器項目,以及檢查 /var/log/leapp/answerfile 中是否有任何未回答的項目。

清除抑制劑

在此環境中,前次從 Oracle Linux 7 升級至 Oracle Linux 8 後,將會出現某些抑制器。

升級後系統檢查通常會先解決問題,然後才讓系統恢復運作。

使用下列指令來清除這些抑制劑。

  1. 啟用實驗室系統上網路介面組態的 NetworkManager 支援。

    sudo sed -i 's/NM_CONTROLLED=no/NM_CONTROLLED=yes/' /etc/sysconfig/network-scripts/ifcfg-ens3
    
  2. 停用防火牆組態檔 /etc/firewalld/firewalld.conf 中的 AllowZoneDrifting,以防止 Leapp 升級被封鎖。

    sudo sed -i 's/^AllowZoneDrifting=.*/AllowZoneDrifting=no/' /etc/firewalld/firewalld.conf
    
  3. 回答 /var/log/leapp/answerfile 中的 OSWatcher 項目。這也會將 leapp-report.txt 檔案中的第二個 OSWatcher 項目置於此處。

    sudo leapp answer --section update_oswatcher_to_pcp.confirm=True
    

再次執行升級前命令,以確認您的報表輸出中不再有禁止項目。

在此環境中,Reports summary 中仍會列出一些項目。

只有在 Inhibitors: 行顯示 0 時,才繼續升級系統。

升級系統

升級之前,請先驗證目前的 Oracle Linux 8 作業系統版本和核心。

請先檢查 Oracle Linux 版本和執行中的核心後再進行升級。

   sudo cat /etc/oracle-release
   uname -r

執行升級處理程序。

   sudo leapp upgrade --oci

升級完成後,請重新啟動系統。

   sudo reboot

系統將會多次重新啟動。在所有重新啟動完成之前,您將無法重新連線 SSH 階段作業。

等待大約 15 分鐘,然後將 SSH 階段作業重新連線至系統。如果連線失敗,請稍候幾分鐘後再試一次。

驗證升級

確認升級後的 Oracle Linux 9 版本和核心現在已用於您的系統。

   sudo cat /etc/oracle-release
   uname -r

升級已完成,且系統正在執行 Oracle Linux 9.x ,核心版本會顯示 el9

如需有關程序和檢查以協助將已升級系統傳回作業的資訊和指引,請參閱文件中的升級後資訊

建議您閱讀在您自己的系統上執行的 Leapp 升級。

備註:本實驗環境將遵循將 Oracle Linux 7 系統升級至 Oracle Linux 8 的步驟,然後使用相同的系統從 Oracle Linux 8 升級至 9。

此實驗環境僅供練習 Leapp 公用程式指令和示範之用,不建議以這種方式將 Oracle Linux 7 系統升級到 Oracle Linux 9。

接下來的步驟

完成本教學課程後,您將示範使用 Leapp 公用程式升級 Oracle Linux 系統的技能和能力。

在您自己的系統上執行 Leapp 時,請務必檢閱升級後文件,以確保系統維持在支援的狀態。

其他學習資源

docs.oracle.com/learn 上探索其他實驗室,或在 Oracle Learning YouTube 頻道上存取更多免費學習內容。此外,請造訪 education.oracle.com/learning-explorer 以成為 Oracle Learning Explorer。

如需產品文件,請造訪 Oracle Help Center