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
相关推荐
一叶龙洲4 小时前
wslg打开Ubuntu24.04默认打开图形界面
linux·服务器·数据库·ubuntu
敖行客 Allthinker6 小时前
Parallels Ubuntu虚拟机项目如何让手机访问?完整解决方案
linux·运维·ubuntu
keyipatience7 小时前
线程栈与TLS和线程互斥
java·linux·服务器·开发语言·ubuntu
元Y亨H7 小时前
生产环境监控与故障应急处理(5-5-5 标准)指南
运维
j7~7 小时前
【Linux】二十二.《Linux 信号机制完全指南:表示、捕捉与处理》
linux·信号处理·volatile·可入重函数·保存信号
观山岳五楼8 小时前
Ubuntu 24 怎么使用Ubuntu 20 的镜像源
linux·运维·ubuntu
m0_715646769 小时前
20260720
linux·arm
寒晓星9 小时前
[linux]线程及多线程
linux·运维
辰痕~9 小时前
物理机装Linux操作系统(Ubuntu为例)
linux·ubuntu
慧一居士9 小时前
Linux如何设置固定的静态ip
运维