OCIでOracle Linux 7.9を8.9へアップグレード

# はじめに
- 本記事はOCIのコンピュート上で稼働しているOracle Linux 7.9をOracle Linux 8.9へアップグレードする手順です。また、カーネルのアップグレード(UEK R5からUEK U7へ)も行っています。
- 7.9から8.9へはleappでアップグレードできます。オンプレミス環境はもちろん、OCIにも正式に対応しています。

# 前提
- Computeは構築済み
- 利用するOS Imageは「Oracle-Linux-7.9-2022.05.31-0」[LINK](https://docs.oracle.com/en-us/iaas/images/image/1dc1e7d6-2979-40ef-b050-52377efba791/)（2024年2月時点では7.9で一番古い）

# 手順概要
1. Yum Update(色々更新
1. leappのための前提条件確認
1. leappをインストール
1. leapp preupgrade
1. leapp upgrade
1. 事後処理
1. カーネルアップデート
1. dnf update(色々更新

:::note info
手順記載していませんが、実際に行う前にはBoot Volumeのバックアップを行いましょう
:::

# 手順詳細

## 0. アップデート前の状況

- 初期構成時
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/d0c56256-48fb-57e3-552b-5797344f28a6.png)

```shell:OS内でコンピュートのメタデータを確認
[opc@ol79init ~]$ oci-metadata
Instance details:
  Display Name: ol79init
  Region: iad - us-ashburn-1 (Ashburn, VA, USA)
  Canonical Region Name: us-ashburn-1
  Availability Domain: IdmO:US-ASHBURN-AD-1
  Fault domain: FAULT-DOMAIN-1
  OCID: ocid1.instance.oc1.iad.anuwcljtzv3jruqc<SKIP>
  Compartment OCID: ocid1.compartment.oc1..aaaaaaaaccpsmjyz2b<SKIP>
  Instance shape: VM.Standard.E4.Flex
  Image ID: ocid1.image.oc1.iad.aaaaaaaaaq4ckfkl6isap35u7thzlws2q6xtcsvdurkjlrqkhdinsotnstcq
  Created at: 1707113825115
  state: Running
  Defined Tags:<SKIP>
  agentConfig:
    allPluginsDisabled: False
    managementDisabled: False
    monitoringDisabled: False
    pluginsConfig: [{'desiredState': 'DISABLED', 'name': 'Vulnerability Scanning'}, {'desiredState': 'DISABLED', 'name': 'Oracle Java Management Service'}, {'desiredState': 'ENABLED', 'name': 'OS Management Service Agent'}, {'desiredState': 'DISABLED', 'name': 'Management Agent'}, {'desiredState': 'ENABLED', 'name': 'Custom Logs Monitoring'}, {'desiredState': 'DISABLED', 'name': 'Compute RDMA GPU Monitoring'}, {'desiredState': 'ENABLED', 'name': 'Compute Instance Run Command'}, {'desiredState': 'ENABLED', 'name': 'Compute Instance Monitoring'}, {'desiredState': 'DISABLED', 'name': 'Compute HPC RDMA Auto-Configuration'}, {'desiredState': 'DISABLED', 'name': 'Compute HPC RDMA Authentication'}, {'desiredState': 'DISABLED', 'name': 'Block Volume Management'}, {'desiredState': 'DISABLED', 'name': 'Bastion'}]
  hostname: ol79init
  ociAdName: iad-ad-3
  regionInfo:
    realmDomainComponent: oraclecloud.com
    realmKey: oc1
    regionIdentifier: us-ashburn-1
    regionKey: IAD
  shapeConfig:
    maxVnicAttachments: 2
    memoryInGBs: 16.0
    networkingBandwidthInGbps: 1.0
    ocpus: 1.0
  tenantId: ocid1.tenancy.oc1..aaaaaaaaeva36myjpt<SKIP>
  Instance Metadata:
    ssh_authorized_keys: <SKIP>
Networking details:
  VNIC OCID: ocid1.vnic.oc1.iad.abuwcljtdbdd<SKIP>
  VLAN Tag: 3401
  Private IP address: 10.10.0.38
  MAC address: 02:00:17:15:9D:78
  Subnet CIDR block: 10.10.0.0/24
  Virtual router IP address: 10.10.0.1
  ```

### ★事前確認
```shell:現在のリリースバージョン、カーネルバージョン、リポジトリを確認
[opc@ol79init ~]$ uname -a
Linux ol79init 5.4.17-2136.307.3.1.el7uek.x86_64 #2 SMP Mon May 9 17:25:56 PDT 2022 x86_64 x86_64 x86_64 GNU/Linux

[opc@ol79init ~]$ cat /etc/oracle-release 
Oracle Linux Server release 7.9

[opc@ol79init ~]$ yum repolist
Loaded plugins: langpacks, ulninfo
repo id                                          repo name                                                                                 status
ol7_MySQL80/x86_64                               MySQL 8.0 for Oracle Linux 7 (x86_64)                                                        440
ol7_MySQL80_connectors_community/x86_64          MySQL 8.0 Connectors Community for Oracle Linux 7 (x86_64)                                   111
ol7_MySQL80_tools_community/x86_64               MySQL 8.0 Tools Community for Oracle Linux 7 (x86_64)                                         37
ol7_UEKR6/x86_64                                 Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 7Server (x86_64)           1,125
ol7_addons/x86_64                                Oracle Linux 7Server Add ons (x86_64)                                                        791
ol7_ksplice                                      Ksplice for Oracle Linux 7Server (x86_64)                                                 39,969
ol7_latest/x86_64                                Oracle Linux 7Server Latest (x86_64)                                                      26,574
ol7_oci_included/x86_64                          Oracle Software for OCI users on Oracle Linux 7Server (x86_64)                             4,123
ol7_optional_latest/x86_64                       Oracle Linux 7Server Optional Latest (x86_64)                                             18,319
ol7_software_collections/x86_64                  Software Collection Library release 3.0 packages for Oracle Linux 7 (x86_64)              18,275
```

## 1. Yum Update(色々更新

```
[opc@ol79init ~]$ sudo yum update
Loaded plugins: langpacks, ulninfo
ol7_MySQL80                                                                                                               | 3.0 kB  00:00:00     
ol7_MySQL80_connectors_community                                                                                          | 2.9 kB  00:00:00     
・
・
<省略>
```

## 2. leappのための前提条件確認

- こちらを確認（以下ピックアップしますが、詳細はドキュメントを確認ください）
    - [Upgrading Systems With Leapp](https://docs.oracle.com/en/operating-systems/oracle-linux/8/leapp/#Oracle-Linux-8)

    - OCIネイティブイメージはLeapp でアップグレード可能だが、BYOIなどはNG。
    - カーネルはUEK→UKEはOK。 RHCKからUEKや、その逆はNG。今回はOracle LinuxではデフォルトのUEK。
    - Btrfs　使っていると厳しい？
    - セキュア ブートが実行されている場合は無効化する
    - ロケールが en_US.UTF-8 に設定されていること
    - RootユーザによるSSHログインを許可する
    - OCIのOS管理が有効化されている場合、無効化する（OCIコンソールのGUIからプラグインを無効化）
        - 以下のイメージ
         ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/5c689623-f376-5ac2-8a79-bee46757e135.png)

## 3. leappをインストール

```shell:
[opc@ol79init ~]$ sudo yum install -y leapp-upgrade --enablerepo=ol7_leapp,ol7_latest
Loaded plugins: langpacks, ulninfo
ol7_leapp                                                                                                                 | 3.0 kB  00:00:00     
(1/2): ol7_leapp/x86_64/updateinfo                                                                                        |  34 kB  00:00:00     
(2/2): ol7_leapp/x86_64/primary_db                                                                                        |  32 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package leapp-upgrade-el7toel8.noarch 0:0.17.0-1.0.17.el7_9 will be installed
--> Processing Dependency: leapp-repository-dependencies = 7 for package: leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
--> Processing Dependency: leapp-framework >= 3.1 for package: leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
--> Processing Dependency: leapp for package: leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
--> Processing Dependency: python2-leapp for package: leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
--> Running transaction ch
・
・
Dependencies Resolved
=================================================================================================================================================
 Package                                       Arch                     Version                               Repository                    Size
=================================================================================================================================================
Installing:
 leapp-upgrade-el7toel8                        noarch                   0.17.0-1.0.17.el7_9                   ol7_leapp                    902 k
Installing for dependencies:
 dnf                                           noarch                   4.0.9.2-1.el7_6                       ol7_leapp                    356 k
 dnf-data                                      noarch                   4.0.9.2-1.el7_6                       ol7_leapp                     50 k
 leapp                                         noarch                   0.15.0-2.0.1.el7_9                    ol7_leapp                     27 k
 leapp-deps                                    noarch                   0.15.0-2.0.1.el7_9                    ol7_leapp                    9.9 k
 leapp-upgrade-el7toel8-deps                   noarch                   0.17.0-1.0.17.el7_9                   ol7_leapp                     29 k
 libcomps                                      x86_64                   0.1.8-14.el7                          ol7_leapp                     74 k
 libdnf                                        x86_64                   0.22.5-1.el7_8                        ol7_leapp                    532 k
 libmodulemd                                   x86_64                   1.6.3-1.el7                           ol7_leapp                    141 k
 librepo                                       x86_64                   1.8.1-8.el7_9                         ol7_latest                    81 k
 libsolv                                       x86_64                   0.6.34-4.el7                          ol7_latest                   328 k
 python2-dnf                                   noarch                   4.0.9.2-1.el7_6                       ol7_leapp                    413 k
 python2-hawkey                                x86_64                   0.22.5-1.el7_8                        ol7_leapp                     68 k
 python2-leapp                                 noarch                   0.15.0-2.0.1.el7_9                    ol7_leapp                    171 k
 python2-libcomps                              x86_64                   0.1.8-14.el7                          ol7_leapp                     46 k
 python2-libdnf                                x86_64                   0.22.5-1.el7_8                        ol7_leapp                    608 k
Transaction Summary
=================================================================================================================================================
Install  1 Package (+15 Dependent packages)
・
・
Installed:
  leapp-upgrade-el7toel8.noarch 0:0.17.0-1.0.17.el7_9                                                                                            
Dependency Installed:
  dnf.noarch 0:4.0.9.2-1.el7_6                dnf-data.noarch 0:4.0.9.2-1.el7_6                          leapp.noarch 0:0.15.0-2.0.1.el7_9       
  leapp-deps.noarch 0:0.15.0-2.0.1.el7_9      leapp-upgrade-el7toel8-deps.noarch 0:0.17.0-1.0.17.el7_9   libcomps.x86_64 0:0.1.8-14.el7          
  libdnf.x86_64 0:0.22.5-1.el7_8              libmodulemd.x86_64 0:1.6.3-1.el7                           librepo.x86_64 0:1.8.1-8.el7_9          
  libsolv.x86_64 0:0.6.34-4.el7               python2-dnf.noarch 0:4.0.9.2-1.el7_6                       python2-hawkey.x86_64 0:0.22.5-1.el7_8  
  python2-leapp.noarch 0:0.15.0-2.0.1.el7_9   python2-libcomps.x86_64 0:0.1.8-14.el7                     python2-libdnf.x86_64 0:0.22.5-1.el7_8  
Complete!
```

## 4. leapp preupgrade（プレアップグレード

https://docs.oracle.com/en/operating-systems/oracle-linux/8/leapp/leapp-UpgradingtheSystem.html#leapp-preupgrade

### leapp preupgradeの実行

- 前提条件や事後処理などのチェックを行う
- 実際にはアップグレードされないのでご安心を

<details><summary>（展開ください）leapp preupgradeの実行イメージ </summary>

```shell:leapp preupgradeの実行イメージ
[opc@ol79init ~]$ sudo leapp preupgrade --oci 
==> Processing phase `configuration_phase`
====> * ipu_workflow_config
        IPU workflow config actor
==> Processing phase `FactsCollection`
====> * udevadm_info
        Produces data exported by the "udevadm info" command.
====> * rpm_scanner
        Provides data about installed RPM Packages.
Loaded plugins: langpacks
====> * repository_mapping
        Produces message containing repository mapping based on provided file.
・
・
<省略>
・
・
  dnf-plugins-core-4.0.21-23.0.1.el8.noarch                                     
  libxkbcommon-0.9.1-1.el8.x86_64                                               
  pinentry-1.1.0-2.el8.x86_64                                                   
  python3-unbound-1.16.2-5.el8.x86_64                                           
  crypto-policies-scripts-20230731-1.git3177e06.el8.noarch                      
  diffutils-3.6-6.el8.x86_64
・
・
<省略>
・
・
  which-2.21-20.el8.x86_64                                                      
  xz-5.2.4-4.el8_6.x86_64                                                       
  xz-libs-5.2.4-4.el8_6.x86_64                                                  
  zlib-1.2.11-25.el8.x86_64                                                     
Complete!
==> Processing phase `TargetTransactionCheck`
====> * check_systemd_services_tasks
        Inhibits upgrade if SystemdServicesTasks tasks are in conflict
====> * local_repos_inhibit
        Inhibits the upgrade if local repositories were found.
====> * dnf_transaction_check
        This actor tries to solve the RPM transaction to verify the all package dependencies can be successfully resolved.
Applying transaction workaround - yum config fix
Last metadata expiration check: 0:02:32 ago on Mon Feb  5 07:00:50 2024.
======================================================================================================================
 Package                                 Arch    Version                                      Repository          Size
======================================================================================================================
Installing:
 authselect-compat                       x86_64  1.2.6-2.el8                                  ol8_appstream       38 k
     replacing  authconfig.x86_64 6.2.8-30.el7
 boost-python3                           x86_64  1.66.0-6.el8                                 ol8_ksplice         95 k
 compat-libpthread-nonshared             x86_64  2.28-236.0.1.el8.7                           ol8_appstream       69 k
 coreutils-common                        x86_64  8.30-15.0.1.el8                              ol8_baseos_latest  2.0 M
 dbus-common                             noarch  1:1.12.8-26.0.1.el8                          ol8_baseos_latest   46 k
・
・
<省略>
・
・
====> * verify_check_results
        Check all generated results messages and notify user about them.
============================================================
                     UPGRADE INHIBITED                      
============================================================
Upgrade has been inhibited due to the following problems:
    1. Inhibitor: Missing required answers in the answer file
Consult the pre-upgrade report for details and possible remediation.
============================================================
                     UPGRADE INHIBITED                      
============================================================
Debug output written to /var/log/leapp/leapp-preupgrade.log
============================================================
                           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                        
============================================================
Answerfile has been generated at /var/log/leapp/answerfile
```
</details>


### leapp-reportを確認する

- 出力された/var/log/leapp/leapp-report.txtを確認し、必要に応じて設定変更する
- 先ほどの前提条件が満たされていない場合も指摘してくれる
- あとは、アップグレード事後にしないといけないことも明示してくれる

私の環境で出たのは以下。

```text:抜粋１
Risk Factor: high (inhibitor)
Title: Missing required answers in the answer file
Summary: One or more sections in answerfile are missing user choices: remove_pam_pkcs11_module_check.confirm
For more information consult https://leapp.readthedocs.io/en/latest/dialogs.html
Remediation: [hint] Please register user choices with leapp answer cli command or by manually editing the answerfile.
leapp answer --section remove_pam_pkcs11_module_check.confirm=True
```

```text:日本語訳１
アンサー・ファイル内の1つ以上のセクションにユーザー選択肢がありません: remove_pam_pkcs11_module_check.confirm
詳細は、https://leapp.readthedocs.io/en/latest/dialogs.htmlを参照してください。
改善: [hint] leapp answer cliコマンドで、またはanswerfileを手動で編集して、ユーザーの選択肢を登録してください。
leapp answer --section remove_pam_pkcs11_module_check.confirm=True
```


```text:抜粋２
Risk Factor: high
Title: Packages not signed by Oracle found on the system
Summary: The following packages have not been signed by Oracle and may be removed during the upgrade process in case Oracle-signed packages to be
 removed during the upgrade depend on them:
- gpg-pubkey
- wlp-agent
```

```text:日本語訳２
次のパッケージはOracleによって署名されておらず、アップグレード中に削除されるOracle署名付きパッケージがそれらに依存する場合に備えて、アップグレード・プロセス中に削除される可能性があります。
```


```text:抜粋３
Risk Factor: high
Title: Difference in Python versions and support in OL 8
Summary: In OL 8, there is no 'python' command. Python 3 (backward incompatible) is the primary Python version and Python 2 is available with lim
ited support and limited set of packages. Read more here: https://docs.oracle.com/en/operating-systems/oracle-linux/8/python/
Remediation: [hint] Please run "alternatives --set python /usr/bin/python3" after upgrade
```

```text:日本語訳３
OL 8では、'python'コマンドはありません。Python 3(後方互換性のない)はプライマリPythonバージョンであり、Python 2は制限付きサポートと限定されたパッケージセットで利用できます。続きを読む: https://docs.oracle.com/en/operating-systems/oracle-linux/8/python/改善: [hint]アップグレード後に
"alternatives --set python /usr/bin/python3"
を実行してください
```


### 抜粋１にあるように以下だけ実行

```shell:
leapp answer --section remove_pam_pkcs11_module_check.confirm=True
```


## 5. leapp upgrade（アップグレード

- Computeにコンソール接続を行いアップグレードを実行します。
    - 事前に root ユーザにパスワードを付与しておきます、
    - コンソール接続手順は以下です。
        - https://docs.oracle.com/ja-jp/iaas/Content/Compute/References/serialconsole.htm

- 以下のイメージでコンソール接続し、rootユーザでローカルログインします。(以下はPC上、WLSのOracle Linuxから、Computeへ接続した後の状態）
    ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/f2b70b80-6008-f656-1cf2-9dd230440bcd.png)

```shell: アップグレードの実行
[root@ol79init ~]# leapp upgrade --oci
==> Processing phase `configuration_phase`
====> * ipu_workflow_config
        IPU workflow config actor
==> Processing phase `FactsCollection`
====> * storage_scanner
        Provides data about storage settings.
====> * transaction_workarounds
        Provides additional RPM transaction tasks based on bundled RPM packages.
====> * common_leapp_dracut_modules
        Influences the generation of the initram disk
====> * rpm_scanner
        Provides data about installed RPM Packages.
Loaded plugins: langpacks
====> * repository_mapping
        Produces message containing repository mapping based on provided file.
====> * pam_modules_scanner
        Scan the pam directory for services and modules used in them
====> * scan_subscription_manager_info
        Scans the current system for subscription manager information
====> * satellite_upgrade_facts
        Report which Satellite packages require upd
・
・
<省略>
・
・
  99 k
 trace-cmd                               x86_64  2.7-10.0.1.el8                               ol8_baseos_latest  258 k
Enabling module streams:
 gimp                                            2.8
 llvm-toolset                                    ol8
 perl                                            5.26
 perl-IO-Socket-SSL                              2.066
 perl-libwww-perl                                6.34
 python27                                        2.7
 python36                                        3.6
 satellite-5-client                              1.0
Transaction Summary
======================================================================================================================
Install    422 Packages
Upgrade    466 Packages
Remove     124 Packages
Downgrade   13 Packages
Total size: 1.4 G
DNF will only download packages, install gpg keys, and check the transaction.
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
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
============================================================
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
============================================================
Answerfile has been generated at /var/log/leapp/answerfile
[root@ol79init ~]# Connection to instance-console.us-ashburn-1.oci.oraclecloud.com closed by remote host.
Connection to ocid1.instance.oc1.iad.anuwcljtzv3jruqcwensf4u4mn23ji5aq4wjxroojaoxiluvux2epi7pdkkq closed by remote host.
Connection to ocid1.instance.oc1.iad.anuwcljtzv3jruqcwensf4u4mn23ji5aq4wjxrooj closed.
```

再起動します
```
reboot
```

コンソール接続では再起動中も状況を追う事が出来ます。
起動時に色々と処理が走るので、起動してくるまでに時間がかかります。状況を見ておきましょう。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/b4d7280c-51c0-5e90-b96e-80964194dfad.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/7f54a038-1223-63af-296f-94610d88af4b.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/ccbbdb6c-1459-308d-4e61-7a3d8dabdec5.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/fda19923-a114-4ff0-58ff-4ca66e887580.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/e724a1a4-c9b7-5d6d-c63e-007b20b9137e.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/d69fdb80-33a3-a852-a286-29f6da710e7f.png)

### Oracle Linux 8.9にアップグレードして初回ログイン後に、レポートが表示されました
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/ca65b3e6-9bbf-8c58-7e2e-51009c989d8d.png)

### ★事後確認

```shell:リリースバージョン、カーネルバージョン、リポジトリを確認
[opc@ol79init ~]$ cat /etc/oracle-release 
Oracle Linux Server release 8.9

[opc@ol79init ~]$ uname -a
Linux ol79init 5.4.17-2136.307.3.1.el7uek.x86_64 #2 SMP Mon May 9 17:25:56 PDT 2022 x86_64 x86_64 x86_64 GNU/Linux

[root@ol79init ~]# dnf repolist
repo id                                             repo name
ol8_MySQL80                                         MySQL 8.0 for Oracle Linux 8 (x86_64)
ol8_MySQL80_connectors_community                    MySQL 8.0 Connectors Community for Oracle Linux 8 (x86_64)
ol8_MySQL80_tools_community                         MySQL 8.0 Tools Community for Oracle Linux 8 (x86_64)
ol8_UEKR6                                           Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)
ol8_addons                                          Oracle Linux 8 Addons (x86_64)
ol8_appstream                                       Oracle Linux 8 Application Stream (x86_64)
ol8_baseos_latest                                   Oracle Linux 8 BaseOS Latest (x86_64)
ol8_developer                                       Oracle Linux 8 Development Packages (x86_64)
ol8_developer_EPEL                                  Oracle Linux 8 EPEL Packages for Development (x86_64)
ol8_developer_EPEL_modular                          Oracle Linux 8 EPEL Modular Packages for Development (x86_64)
ol8_ksplice                                         Ksplice for Oracle Linux 8 (x86_64)
ol8_oci_included                                    Oracle Software for OCI users on Oracle Linux 8 (x86_64)
```


## 6. 事後処理

### 不要パッケージの削除
```shell:以下が削除できるもの
[opc@ol79init ~]$ rpm -qa | grep el7
kernel-uek-5.4.17-2136.327.2.el7uek.x86_64
kernel-3.10.0-1160.62.1.el7.x86_64
kernel-uek-5.4.17-2136.307.3.1.el7uek.x86_64
leapp-0.15.0-2.0.1.el7_9.noarch
mysql-community-client-plugins-8.0.36-1.el7.x86_64
kernel-3.10.0-1160.105.1.0.1.el7.x86_64
python2-leapp-0.15.0-2.0.1.el7_9.noarch
leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarc

[opc@ol79init ~]$ rpm -qa | grep leapp
leapp-deps-el8-5.0.8-1.0.1.el8.noarch
leapp-0.15.0-2.0.1.el7_9.noarch
leapp-repository-deps-el8-5.0.8-1.0.1.el8.noarch
python2-leapp-0.15.0-2.0.1.el7_9.noarch
leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
```

```shell:削除
# dnf remove kernel-uek-5.4.17-2136.327.2.el7uek.x86_64　 kernel-3.10.0-1160.62.1.el7.x86_64 kernel-uek-5.4.17-2136.307.3.1.el7uek.x86_64 leapp-0.15.0-2.0.1.el7_9.noarch mysql-community-client-plugins-8.0.36-1.el7.x86_64 kernel-3.10.0-1160.105.1.0.1.el7.x86_64 python2-leapp-0.15.0-2.0.1.el7_9.noarch leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
No match for argument: kernel-uek-5.4.17-2136.327.2.el7uek.x86_64　
Dependencies resolved.
=================================================================================================================================================
 Package                                        Architecture           Version                                     Repository               Size
=================================================================================================================================================
Removing:
 kernel                                         x86_64                 3.10.0-1160.62.1.el7                        @System                  64 M
 kernel                                         x86_64                 3.10.0-1160.105.1.0.1.el7                   @System                  66 M
 kernel-uek                                     x86_64                 5.4.17-2136.307.3.1.el7uek                  @System                 113 M
 leapp                                          noarch                 0.15.0-2.0.1.el7_9                          @System                  62 k
 leapp-upgrade-el7toel8                         noarch                 0.17.0-1.0.17.el7_9                         @System                 5.2 M
 mysql-community-client-plugins                 x86_64                 8.0.36-1.el7                                @System                  20 M
 python2-leapp                                  noarch                 0.15.0-2.0.1.el7_9                          @System                 637 k
Transaction Summary
=================================================================================================================================================
Remove  7 Packages
Freed space: 268 M

[root@ol79init ~]# dnf remove leapp-deps-el8-5.0.8-1.0.1.el8.noarch leapp-0.15.0-2.0.1.el7_9.noarch leapp-repository-deps-el8-5.0.8-1.0.1.el8.noarch python2-leapp-0.15.0-2.0.1.el7_9.noarch leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
No match for argument: leapp-0.15.0-2.0.1.el7_9.noarch
No match for argument: python2-leapp-0.15.0-2.0.1.el7_9.noarch
No match for argument: leapp-upgrade-el7toel8-0.17.0-1.0.17.el7_9.noarch
Dependencies resolved.
=================================================================================================================================================
 Package                                       Architecture               Version                              Repository                   Size
=================================================================================================================================================
Removing:
 leapp-deps-el8                                noarch                     5.0.8-1.0.1.el8                      @System                       0  
 leapp-repository-deps-el8                     noarch                     5.0.8-1.0.1.el8                      @System                       0  
Transaction Summary
=================================================================================================================================================
Remove  2 Packages
Freed space: 0  
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                         1/1 
  Erasing          : leapp-repository-deps-el8-5.0.8-1.0.1.el8.noarch                                                                        1/2 
  Erasing          : leapp-deps-el8-5.0.8-1.0.1.el8.noarch                                                                                   2/2 
  Verifying        : leapp-deps-el8-5.0.8-1.0.1.el8.noarch                                                                                   1/2 
  Verifying        : leapp-repository-deps-el8-5.0.8-1.0.1.el8.noarch                                                                        2/2 
Removed:
  leapp-deps-el8-5.0.8-1.0.1.el8.noarch                             leapp-repository-deps-el8-5.0.8-1.0.1.el8.noarch                            
Complete!
```

### ★重要:DHCPクライアント設定を上書き
- この手順の通り「/etc/dhcp/exit-hooks.d/dhclient-exit-hook-set-hostname.sh」を更新する
- [Updated dhclient Script](https://docs.oracle.com/en/operating-systems/oracle-linux/8/leapp/leapp-dhclientScript.html#topic_hbg_m44_r5b)

### firewalldの有効化
```shell:
sudo systemctl start firewalld
sudo systemctl enable firewalld
```

### /root/tmp_leapp_py3ディレクトリを削除
```shell:
# ls /root/tmp_leapp_py3
leapp  leapp3

# rm -rf /root/tmp_leapp_py3
# ls /root/
<何も表示されなくなった>
```

### /etc/dnf/dnf.conf　から不要行の削除
-「#exclude=python2-leapp,snactor,leapp-upgrade-el7toel8,leapp」を削除
- 以下の一番下の行を削除
     ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/5bd63d79-fcfb-467e-5ba4-b2d059254708.png)


## 7. カーネルアップデート

アップグレードすると、5.4.17(UEK R5)のままなので、5.15.0(UEK R7)にアップグレードする
https://blogs.oracle.com/scoter/post/oracle-linux-and-unbreakable-enterprise-kernel-uek-releases

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/4cee67ee-ddba-2e08-0747-f7376187640c.png)


事前確認
```
[root@ol79init ~]# dnf repolist
repo id                                             repo name
ol8_MySQL80                                         MySQL 8.0 for Oracle Linux 8 (x86_64)
ol8_MySQL80_connectors_community                    MySQL 8.0 Connectors Community for Oracle Linux 8 (x86_64)
ol8_MySQL80_tools_community                         MySQL 8.0 Tools Community for Oracle Linux 8 (x86_64)
ol8_UEKR6                                           Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)
ol8_addons                                          Oracle Linux 8 Addons (x86_64)
ol8_appstream                                       Oracle Linux 8 Application Stream (x86_64)
ol8_baseos_latest                                   Oracle Linux 8 BaseOS Latest (x86_64)
ol8_developer                                       Oracle Linux 8 Development Packages (x86_64)
ol8_developer_EPEL                                  Oracle Linux 8 EPEL Packages for Development (x86_64)
ol8_developer_EPEL_modular                          Oracle Linux 8 EPEL Modular Packages for Development (x86_64)
ol8_ksplice                                         Ksplice for Oracle Linux 8 (x86_64)
ol8_oci_included                                    Oracle Software for OCI users on Oracle Linux 8 (x86_64)
```

ol8_UEKR7を有効化
```
dnf config-manager --enable ol8_UEKR7
```

```
[root@ol79init ~]# dnf repolist | grep UEK 
ol8_UEKR6                        Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)
ol8_UEKR7                        Latest Unbreakable Enterprise Kernel Release 7 for Oracle Linux 8 (x86_64)
```

## カーネルアップグレードの実行

以下を実行する
```
dnf install kernel-uek
```

<details><summary> (展開ください) カーネルアップグレードの実行実際の動き </summary>

```shell:カーネルアップグレードの実行実際の動き
[root@ol79init ~]# dnf install kernel-uek
Latest Unbreakable Enterprise Kernel Release 7 for Oracle Linux 8 (x86_64)                                        74 MB/s |  27 MB     00:00    
Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)                                       165 kB/s | 3.0 kB     00:00    
Last metadata expiration check: 0:00:01 ago on Mon 05 Feb 2024 09:26:19 AM GMT.
Package kernel-uek-5.4.17-2136.327.2.el7uek.x86_64 is already installed.
Package kernel-uek-5.4.17-2136.327.2.el8uek.x86_64 is already installed.
Dependencies resolved.
=================================================================================================================================================
 Package                               Architecture              Version                                      Repository                    Size
=================================================================================================================================================
Installing:
 kernel-uek                            x86_64                    5.15.0-202.135.2.el8uek                      ol8_UEKR7                    2.0 M
Installing dependencies:
 kernel-uek-core                       x86_64                    5.15.0-202.135.2.el8uek                      ol8_UEKR7                     59 M
 kernel-uek-modules                    x86_64                    5.15.0-202.135.2.el8uek                      ol8_UEKR7                     64 M
Transaction Summary
=================================================================================================================================================
Install  3 Packages
Total download size: 125 M
Installed size: 172 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): kernel-uek-5.15.0-202.135.2.el8uek.x86_64.rpm                                                              30 MB/s | 2.0 MB     00:00    
(2/3): kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64.rpm                                                         48 MB/s |  59 MB     00:01    
(3/3): kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64.rpm                                                      35 MB/s |  64 MB     00:01    
-------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                             69 MB/s | 125 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                         1/1 
  Running scriptlet: kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          1/3 
  Installing       : kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          1/3 
  Running scriptlet: kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          1/3 
  Installing       : kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64                                                                       2/3 
  Running scriptlet: kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64                                                                       2/3 
  Installing       : kernel-uek-5.15.0-202.135.2.el8uek.x86_64                                                                               3/3 
  Running scriptlet: kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          3/3
Total                                                                                                             69 MB/s | 125 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                         1/1 
  Running scriptlet: kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          1/3 
  Installing       : kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          1/3 
  Running scriptlet: kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          1/3 
  Installing       : kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64                                                                       2/3 
  Running scriptlet: kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64                                                                       2/3 
  Installing       : kernel-uek-5.15.0-202.135.2.el8uek.x86_64                                                                               3/3 
  Running scriptlet: kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          3/3 
bash
systemd
systemd-initrd
modsign
nss-softokn
rngd
i18n
network-legacy
network
ifcfg
btrfs
crypt
dm
kernel-modules
kernel-modules-extra
kernel-network-modules
lvm
mdraid
multipath
qemu
qemu-net
iscsi
lunmask
nfs
resume
rootfs-block
terminfo
udev-rules
virtfs
biosdevname
dracut-systemd
usrmount
-uptrack
base
fs-lib
memstrack
microcode_ctl-fw_dir_override
shutdown
  Running scriptlet: kernel-uek-5.15.0-202.135.2.el8uek.x86_64                                                                               3/3 
  Verifying        : kernel-uek-5.15.0-202.135.2.el8uek.x86_64                                                                               1/3 
  Verifying        : kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64                                                                          2/3 
  Verifying        : kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64                                                                       3/3 
Installed:
  kernel-uek-5.15.0-202.135.2.el8uek.x86_64  kernel-uek-core-5.15.0-202.135.2.el8uek.x86_64  kernel-uek-modules-5.15.0-202.135.2.el8uek.x86_64 
Complete!
```
</details>

```shell:再起動前のカーネルバージョン
[root@ol79init ~]# uname -a
Linux ol79init 5.4.17-2136.327.2.el8uek.x86_64 #2 SMP Fri Jan 5 14:55:52 PST 2024 x86_64 x86_64 x86_64 GNU/Linux

reboot
```

```shell:再起動後にカーネルが更新されていることがわかる
[root@ol79init ~]# uname -a
Linux ol79init 5.15.0-202.135.2.el8uek.x86_64 #2 SMP Fri Jan 5 16:12:57 PST 2024 x86_64 x86_64 x86_64 GNU/Linux
```

起動カーネルの確認
```shell:複数あり、Oracle Linux 8.9がデフォルトであることが分かる
[root@ol79init ~]# grubby --info=ALL |grep title
title="Oracle Linux Server 8 (5.15.0-202.135.2.el8uek.x86_64) "
title="Oracle Linux Server 8 (5.4.17-2136.327.2.el8uek.x86_64) "
title="Oracle Linux Server (5.4.17-2136.327.2.el7uek.x86_64) 8.9"
title="Oracle Linux Server (5.4.17-2136.307.3.1.el7uek.x86_64) 8.9"
title="Oracle Linux Server (4.18.0-513.11.0.1.el8_9.x86_64) 8.9"
title="Oracle Linux Server (3.10.0-1160.105.1.0.1.el7.x86_64) 8.9"
title="Oracle Linux Server (3.10.0-1160.62.1.el7.x86_64) 8.9"
title="Oracle Linux Server (0-rescue-4bb20c7bccac4ca3bfd2aa7aa94b6a9f) 8.9"

[root@ol79init ~]# grubby --default-kernel
/boot/vmlinuz-5.15.0-202.135.2.el8uek.x86_64

[root@ol79init ~]# grubby --default-title
Oracle Linux Server 8 (5.15.0-202.135.2.el8uek.x86_64)
```

## 8. dnf update(色々更新
＜割愛＞

### Cloud Agentは最新になっていた（2024/2/5時点)

```shell:
[root@ol79init ~]# yum info oracle-cloud-agent
Last metadata expiration check: 0:14:05 ago on Mon 05 Feb 2024 09:26:23 AM GMT.
Installed Packages
Name         : oracle-cloud-agent
Version      : 1.37.2
Release      : 10459.el8
Architecture : x86_64
Size         : 468 M
Source       : oracle-cloud-agent-1.37.2-10459.el8.src.rpm
Repository   : @System
Summary      : Oracle Cloud Agent
URL          : https://docs.cloud.oracle.com/iaas/
License      : https://oss.oracle.com/licenses/upl/
Description  : Oracle Cloud Infrastructure agent for management and monitoring.
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/266598/d460b722-f089-a798-5b47-1473f5949876.png)


# 参考情報
- [Oracle Linux and Unbreakable Enterprise Kernel (UEK) Releases](https://blogs.oracle.com/scoter/post/oracle-linux-and-unbreakable-enterprise-kernel-uek-releases)
- [Upgrading Systems With Leapp](https://docs.oracle.com/en/operating-systems/oracle-linux/8/leapp/index.html#Oracle-Linux-8)