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
相关推荐
Cosolar2 小时前
LlamaIndex索引类型全解析:原理与实战指南
运维·服务器
方便面不加香菜4 小时前
Linux--基础IO(一)
linux·运维·服务器
鼎讯信通7 小时前
风电光缆运维提质增效:G-4000A 光缆故障追踪仪破解风场巡检难题
运维·网络·数据库
三十..7 小时前
MySQL 从入门到高可用架构实战精要
运维·数据库·mysql
跨境数据猎手8 小时前
大数据在电商行业的应用
大数据·运维·爬虫
linyanRPA8 小时前
影刀RPA店群自动化实战:多店铺活动自动报名与促销管理架构设计
运维·自动化·办公自动化·rpa·python脚本·爬虫自动化·店群自动化
mounter6259 小时前
现代 Linux 内存管理的演进与变革:从传统 LRU 到多代架构 MGLRU
linux·服务器·kernel
会Tk矩阵群控的小木9 小时前
安卓群控系统对于游戏工作室实战教程
android·运维·游戏·adb·开源软件·个人开发
赵渝强老师9 小时前
【赵渝强老师】Kubernetes(K8s)中的金丝雀升级
linux·docker·云原生·容器·kubernetes
佛山个人技术开发9 小时前
GitCode SSH连接配置教程
运维·ssh·gitcode