CentOS Linux release 8.5.2111下的CVE-2026-31431 Linux内核提权漏洞处置 过程问题记录

CentOS 8.5,内核 4.18.0-348.el8受 CVE-2026-31431 高危影响,以下是 CentOS 8.5 迁移到 AlmaLinux 8处置过程中的一些问题记录:

------------------------

# dnf makecache 在"/etc/yum.repos.d", "/etc/yum/repos.d", "/etc/distro.repos.d"中没有被启用的仓库。

仓库目录是空的,所以 dnf 完全无法工作----重建 yum 仓库


rpm -ivh --force http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm 获取http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm 错误:依赖检测失败: centos-repos(8) 与 centos-linux-repos-8-3.el8.noarch 冲突 centos-repos(8) 与 (已安裝) centos-linux-repos-8-3.el8.noarch 冲突

---强制删除冲突的源包(解决依赖报错)


rpm -ivh --force http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm 获取http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm 错误:依赖检测失败: centos-repos(8) 与 centos-linux-repos-8-3.el8.noarch 冲突 centos-repos(8) 与 (已安裝) centos-linux-repos-8-3.el8.noarch 冲突 root@GSGD-ZQB-YWZJ-001 yum.repos.d# rpm -e --nodeps centos-linux-repos 警告:文件 /etc/yum.repos.d/CentOS-Linux-Sources.repo:移除失败:没有那个文件或目录 警告:文件 /etc/yum.repos.d/CentOS-Linux-PowerTools.repo:移除失败:没有那个文件或目录

----------手动自建 CentOS8.5 Vault 源 → 直接系统离线升级迁移

dnf makecache Repository appstream is listed more than once in the configuration Repository extras is listed more than once in the configuration CentOS Linux 8 AppStream 1.2 MB/s | 8.4 MB 00:06 CentOS Linux 8 Extras 3.0 kB/s | 10 kB 00:03 CentOS Linux 8 - BaseOS 0.0 B/s | 0 B 00:00 Errors during downloading metadata for repository 'baseos': - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=BaseOS&infra=stock Could not resolve host: [mirrorlist.centos.org](https://mirrorlist.centos.org/ "mirrorlist.centos.org") 错误:为仓库 'baseos' 下载元数据失败 : Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=BaseOS&infra=stock Could not resolve host: [mirrorlist.centos.org](https://mirrorlist.centos.org/ "mirrorlist.centos.org")

--------------系统里还残留旧的 mirrorlist 配置,导致还在访问已失效的 mirrorlist.centos.org

1. 先清空所有 repo(彻底干净)

复制代码
rm -rf /etc/yum.repos.d/*

2. 一键创建 纯 vault 源(无 mirrorlist,绝对能用)

复制代码
cat > /etc/yum.repos.d/CentOS-Vault.repo <<'EOF'
[baseos]
name=CentOS Linux 8 - BaseOS
baseurl=http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[appstream]
name=CentOS Linux 8 - AppStream
baseurl=http://vault.centos.org/8.5.2111/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[extras]
name=CentOS Linux 8 - Extras
baseurl=http://vault.centos.org/8.5.2111/extras/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF

3. 清理缓存 + 重建(这步一定成功)

复制代码
dnf clean all
dnf makecache

==================

AlmaLinux 迁移(最稳,不挑环境)

复制代码
cd /tmp
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
chmod +x almalinux-deploy.sh
bash almalinux-deploy.sh

bash almalinux-deploy.sh Check root privileges OK Check centos-8.x86_64 is supported OK Enabled repositories list created OK Download RPM-GPG-KEY-AlmaLinux OK Import RPM-GPG-KEY-AlmaLinux to RPM DB OK Download almalinux-release package OK Verify almalinux-release package OK Your OS is supported OK 警告:文件 /etc/yum.repos.d/CentOS-Linux-Sources.repo:移除失败:没有那个文件或目录 警告:文件 /etc/yum.repos.d/CentOS-Linux-PowerTools.repo:移除失败:没有那个文件或目录 警告:文件 /etc/yum.repos.d/CentOS-Linux-Plus.repo:移除失败:没有那个文件或目录事务无法启动: file /usr/lib/node_modules/npm/docs from install of npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64 conflicts with file from package nodejs-2:24.12.0-1nodesource.x86_64 下载的软件包保存在缓存中,直到下次成功执行事务。 您可以通过执行 'dnf clean packages' 删除软件包缓存。 错误:不能执行事务。 Run dnf distro-sync -y. Exit code: 1 ERROR

--------卡在 nodesource 第三方 nodejs 包 与 AlmaLinux 官方源 nodejs 包冲突

第一步:卸载冲突的第三方 nodejs 包

复制代码
# 强制卸载 nodesource 安装的 nodejs 和 npm(不影响你的业务数据)
dnf remove -y nodejs npm

第二步:同步系统所有包到 AlmaLinux 官方版本

复制代码
# 强制同步所有包,解决所有依赖冲突
dnf distro-sync -y

第三步:重新运行迁移脚本(完成最后一步)

复制代码
cd /tmp
bash almalinux-deploy.sh

这次会直接完成迁移,不会再报错!成功标志:输出 Migration to AlmaLinux is completed

第四步:重启系统生效

复制代码
reboot

======================

pm2 --list /usr/bin/env: "node": 没有那个文件或目录 gul@[localhost](https://localhost/ "localhost") \~$ pm2 list /usr/bin/env: "node": 没有那个文件或目录

重新安装 nodesource 最新版(推荐生产环境,和之前一致)

1. 添加 nodesource 24.x 源(和你之前用的版本相同)

复制代码
curl -fsSL https://rpm.nodesource.com/setup_24.x | sudo bash -

2. 安装 nodejs 和 npm

复制代码
sudo dnf install -y nodejs

3. 验证安装

复制代码
node -v
# 输出:v24.12.0

npm -v
# 输出:10.8.3
相关推荐
AlfredZhao2 天前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
戴为沐3 天前
Linux内存扩容指南
linux
zylyehuo4 天前
Linux 彻底且安全地删除文件
linux
用户805533698034 天前
主线 U-Boot 上 RK3506:和闭源 rkbin 拔河的三个隐性契约
linux·嵌入式
用户034095297914 天前
linux fcitx 5 雾凇拼音 设置在中文输入法下仍然输入英文标点
linux
乘云数字DATABUFF4 天前
5分钟部署开源APM Databuff:OpenTelemetry全链路追踪入门实战
运维·后端
Web3探索者6 天前
可视化服务器管理和传统命令行区别是什么?新手教程:Linux 运维到底该用图形界面还是 SSH 命令行?
linux·ssh
zylyehuo6 天前
Linux系统中网线与USB网络共享冲突
linux
荣--6 天前
一键部署不是为了省时间 —— 它是把"买来的 PaaS"变成"自己的平台"的拐点
运维·zabbix·工程化·一键部署·平台化·边界设计
江华森6 天前
动手实战学 Docker — 从零到集群编排完全指南
运维