背景:掛載RHEL ISO使用kickstart安裝操作系統,安裝包未指定安裝perl,但是安裝完可以查到其版本,且安裝的是ISO中多個版本中的最低版本。
原因:(1)為什么沒有裝perl,perl -v可以看到版本?
因為安裝perl其它包而安裝了perl-libs等
如何找到是哪個包依賴了perl-libs等?
- 針對包組,查看@core里裝哪些包?dnf groupinfo core -> 排除是這里面默認裝的
- 針對指定包,查看其它指定包依賴于哪些包,例如perl-xxx
查看依賴關系的命令
dnf repoquery –requires <pkg name> 查看指定包依賴于哪些包
dnf repoquery –whatrequires <pkg name> 查看哪些包依賴于指定包
dnf repoquery --help | grep require
? ? ? ? ? ? ? ? ? ? ?[--whatrequires REQ] [--whatrecommends REQ]
? ? ? ? ? ? ? ? ? ? ?[--conflicts | --depends | --enhances | --provides | --recommends | --requires | --requires-pre | --suggests | --supplements]
? --whatdepends REQ ? ? shows results that requires, suggests, supplements,
? --whatrequires REQ ? ?shows results that requires package provides and files
? --recursive ? ? ? ? ? used with --whatrequires, and --requires --resolve,
? --requires ? ? ? ? ? ?Display capabilities that the package depends on.
? --requires-pre ? ? ? ?If the package is not installed display capabilities
? --recursive ? ? ? ? ? used with --whatrequires, and --requires --resolve,
? ? ? ? ? ? ? ? ? ? ? ? query packages recursively.
[root@xxx?~]# dnf repoquery --requires perl-DBD-SQLite-1.58-2.module+el8.6.0+13408+461b4ab5.x86_64
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.Last metadata expiration check: 2:02:32 ago on Sat 15 Mar 2025 01:18:35 PM CST.
libc.so.6(GLIBC_2.14)(64bit)
libperl.so.5.32()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libsqlite3.so.0()(64bit)
perl(:MODULE_COMPAT_5.32.1)
perl(:VERSION) >= 5.6.0
perl(DBD::SQLite)
perl(DBD::SQLite::VirtualTable)
perl(DBI) >= 1.57
perl(DynaLoader)
perl(Exporter)
perl(Scalar::Util)
perl(Tie::Hash)
perl(base)
perl(constant)
perl(locale)
perl(strict)
perl(warnings)
rtld(GNU_HASH)
(2)為什么安裝的是最低版本
RHEL 8 使用 模塊化(modular)倉庫,某些軟件包(如 perl-libs)屬于 應用流(AppStream),系統會默認啟用某個流(stream)。Kickstart 默認安裝的軟件包可能受 默認模塊流 影響,而非安裝最高版本。
解決方案:
指定好repo,例如將iso掛載到/mnt,編輯os.repo
# cat /etc/yum.repos.d/os.repo
...[rhel-baseos]
name=RHEL8
baseurl=file:///mnt/BaseOS
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[rhel-appstream]
name=RHEL8
baseurl=file:///mnt/AppStream
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
執行?dnf clean all
查看 dnf repolist
# dnf repolist
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id???????????????????????????????????????????????????????? repo name
rhel-appstream????????????????????????????????????????????????? RHEL8
rhel-baseos???????????????????????????????????????????????????? RHEL8
重置并啟用指定模塊的最新流
dnf module reset -y perl?
dnf module enable -y perl:5.32
dnf distro-sync -y
說明:
dnf module reset 清除默認模塊流,防止使用默認的舊版本。
dnf module enable 指定最新版本的模塊流。
dnf distro-sync 確保所有包同步到最高版本。
=================================================
附1:
RHEL 8 本地 RPM 升級(包括模塊化包)完整步驟
適用于 從本地目錄升級 RPM 包,確保 模塊化包(AppStream)使用較新版本。
步驟 1:準備本地升級包
將所有 需要升級的 RPM 包放在一個目錄,例如:
mkdir -p /var/update-packages
cp /path/to/rpms/*.rpm /var/update-packages/
步驟 2:創建本地倉庫
RHEL 8 需要 createrepo_c 來索引 RPM 包:
dnf install -y createrepo_c
cd /var/update-packages/
createrepo_c ?.
如果包含 模塊化包(AppStream),還需要 處理 module metadata:
# cd /var/update-packages/
# repo2module -s stable /var/update-packages/
# modifyrepo_c --mdtype=modules modules.yaml repodata/
步驟 3:配置本地 repo
在 /etc/yum.repos.d/local.repo 添加以下內容:
[local-updates]
name=Local Update Repo
baseurl=file:///var/update-packages/
enabled=1
gpgcheck=0
然后執行:
dnf clean all
dnf makecache
步驟 4:重置 & 啟用模塊
dnf module reset -y perl python nodejs
dnf module enable -y perl:5.32 python:3.9 nodejs:18
步驟 5:執行升級
dnf upgrade --disablerepo=* --enablerepo=local-updates -y
步驟 6(可選):檢查結果
dnf list installed | grep perl
dnf module list | grep '[e]'
=================================================
附2:chatGPT提問記錄
Q: 哪些軟件涉及模塊流?
RHEL 8+ 里,涉及模塊流的軟件通常是:
- 編程語言:
- perl(5.26, 5.30, 5.32)
- python(3.6, 3.8, 3.9, 3.11)
- nodejs(10, 12, 14, 16, 18)
- ruby(2.5, 2.6, 2.7, 3.0)
- php(7.2, 7.3, 7.4, 8.0)
- gcc-toolset(9, 10, 11, 12)
- 數據庫:
- postgresql(9.6, 10, 12, 13, 14)
- mariadb(10.3, 10.5)
- Web 服務器 & 代理:
- httpd(Apache HTTP Server)
- nginx
- varnish
- 消息隊列:
- redis
- rabbitmq
- 其他開發工具:
- llvm-toolset
- subversion
Q: 如何查看系統里有哪些模塊流?
dnf module list --all
- [d] 代表默認啟用的模塊流(default)
- [e] 代表已啟用的模塊流(enabled)
# dnf module list
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.@modulefailsafe
Name Stream Profiles Summary
perl 5.26 [e] common, minimal Practical Extraction and Report Language
perl-DBD-SQLite 1.58 [e] common SQLite DBI driver
perl-DBI 1.641 [e] common A database access API for Perl
perl-IO-Socket-SSL 2.066 [e] common Perl library for transparent TLS
perl-libwww-perl 6.34 [e] common A Perl interface to the World-Wide Web
x86_64 stable [e] everything <auto-generated module summary>Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
說明:
Name 列:模塊名稱,如 perl、perl-DBI 等。
Stream 列:已啟用的模塊流(版本),例如:
Profiles 列:模塊的 可選配置,如 common, minimal。
Summary 列:簡要描述。
perl 5.26 [e]
[e] 代表 已啟用(enabled),表示當前 dnf 只能從這個流 安裝 perl 相關包。
perl 5.26 已啟用,所以無法直接安裝 perl 5.32,需要先 dnf module reset perl,然后 dnf module enable perl:5.32。
@modulefailsafe
說明 dnf 處于“failsafe”模式,因為你的系統沒有 Red Hat 訂閱(RHSM 未注冊)。
這意味著 dnf 只能使用 本地已啟用的模塊流,不會嘗試訪問外部倉庫。
Q: 為什么環境裝了python3.12 卻不能在dnf module list里查到
- AppStream 里有兩種類型的軟件包:
- 模塊化軟件包(module-based),可以使用 dnf module 管理,例如 perl, nodejs, python:3.9。
- 非模塊化軟件包(普通 RPM 包),可以直接用 dnf install 安裝,例如 python3.12。
- ?python3.12 可能是 AppStream 里的普通 RPM 包,而不是模塊流,所以 dnf module list 里不會列出來。RHEL 8 默認的 Python 模塊流最高是 python:3.9
Q: 查看某個rpm包來自哪個倉庫
dnf repoquery --info python3.12
Name???????? : python3.12 Version????? : 3.12.1 Release????? : 4.el8 Architecture : x86_64 Size???????? : 29 k Source?????? : python3.12-3.12.1-4.el8.src.rpm Repository?? : rhel-appstream Summary????? : Version 3.12 of the Python interpreter URL????????? : https://www.python.org/ License????? : Python Description? : Python 3.12 …… |
dnf module list python
[root@testVM1 ~]# dnf module list | grep python libselinux-python??? 2.8???????????? common?????????????????????????????????? Python 2 bindings for libselinux?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? python27???????????? 2.7 [d]???????? common [d]?????????????????????????????? Python programming language, version 2.7?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? python36???????????? 3.6 [d]???????? build, common [d]??????????????????????? Python programming language, version 3.6?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? python38???????????? 3.8 [d]???????? build, common [d]??????????????????????? Python programming language, version 3.8?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? python39???????????? 3.9 [d]???????? build, common [d]??????????????????????? Python programming language, version 3.9?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? [root@testVM1 ~]# |