[centos][yum] centos升级到特定版本
我们已知,yum upgrade命令可以将整个系统升级到最新版本。
但是很多时候,我们需要更新到指定版本,比如,当前最新的CentOS版本是7.6.1810
但是我需要更新到7.4,可以如下这样做:
1. CentOS的repo是不维护历史版本的。所有历史版本都在这里,
在OS里,有这样的一个repo, /etc/yum.repos.d/CentOS-Vault.repo
里边是,当前版本之前的历史版本。所以里边没有7.4 。
2. 更新centos-release包,拿到7,4的vault
yum install centos-release
3 查看所有可用的repo
yum repolist all
详见:

repo id repo name status C7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled C7.0.1406-centosplus/x86_64 CentOS-7.0.1406 - CentOSPlus disabled C7.0.1406-extras/x86_64 CentOS-7.0.1406 - Extras disabled C7.0.1406-fasttrack/x86_64 CentOS-7.0.1406 - Fasttrack disabled C7.0.1406-updates/x86_64 CentOS-7.0.1406 - Updates disabled C7.1.1503-base/x86_64 CentOS-7.1.1503 - Base disabled C7.1.1503-centosplus/x86_64 CentOS-7.1.1503 - CentOSPlus disabled C7.1.1503-extras/x86_64 CentOS-7.1.1503 - Extras disabled C7.1.1503-fasttrack/x86_64 CentOS-7.1.1503 - Fasttrack disabled C7.1.1503-updates/x86_64 CentOS-7.1.1503 - Updates disabled C7.2.1511-base/x86_64 CentOS-7.2.1511 - Base disabled C7.2.1511-centosplus/x86_64 CentOS-7.2.1511 - CentOSPlus disabled C7.2.1511-extras/x86_64 CentOS-7.2.1511 - Extras disabled C7.2.1511-fasttrack/x86_64 CentOS-7.2.1511 - Fasttrack disabled C7.2.1511-updates/x86_64 CentOS-7.2.1511 - Updates disabled C7.3.1611-base/x86_64 CentOS-7.3.1611 - Base disabled C7.3.1611-centosplus/x86_64 CentOS-7.3.1611 - CentOSPlus disabled C7.3.1611-extras/x86_64 CentOS-7.3.1611 - Extras disabled C7.3.1611-fasttrack/x86_64 CentOS-7.3.1611 - Fasttrack disabled C7.3.1611-updates/x86_64 CentOS-7.3.1611 - Updates disabled C7.4.1708-base/x86_64 CentOS-7.4.1708 - Base disabled C7.4.1708-centosplus/x86_64 CentOS-7.4.1708 - CentOSPlus disabled C7.4.1708-extras/x86_64 CentOS-7.4.1708 - Extras disabled C7.4.1708-fasttrack/x86_64 CentOS-7.4.1708 - Fasttrack disabled C7.4.1708-updates/x86_64 CentOS-7.4.1708 - Updates disabled C7.5.1804-base/x86_64 CentOS-7.5.1804 - Base disabled C7.5.1804-centosplus/x86_64 CentOS-7.5.1804 - CentOSPlus disabled C7.5.1804-extras/x86_64 CentOS-7.5.1804 - Extras disabled C7.5.1804-fasttrack/x86_64 CentOS-7.5.1804 - Fasttrack disabled C7.5.1804-updates/x86_64 CentOS-7.5.1804 - Updates disabled C7.6.1810-base/x86_64 CentOS-7.6.1810 - Base disabled C7.6.1810-centosplus/x86_64 CentOS-7.6.1810 - CentOSPlus disabled C7.6.1810-extras/x86_64 CentOS-7.6.1810 - Extras disabled C7.6.1810-fasttrack/x86_64 CentOS-7.6.1810 - Fasttrack disabled C7.6.1810-updates/x86_64 CentOS-7.6.1810 - Updates disabled base/7/x86_64 CentOS-7 - Base enabled: 10,097 base-debuginfo/x86_64 CentOS-7 - Debuginfo enabled: 7,293 base-source/7 CentOS-7 - Base Sources enabled: 0 !c7-media CentOS-7 - Media disabled centosplus/7/x86_64 CentOS-7 - Plus disabled centosplus-source/7 CentOS-7 - Plus Sources enabled: 0 cr/7/x86_64 CentOS-7 - cr disabled epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 enabled: 13,485 epel-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Debug disabled !epel-source/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Source disabled epel-testing/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 disabled epel-testing-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Debug disabled epel-testing-source/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Source disabled extras/7/x86_64 CentOS-7 - Extras enabled: 305 extras-source/7 CentOS-7 - Extras Sources enabled: 0 fasttrack/7/x86_64 CentOS-7 - fasttrack disabled updates/7/x86_64 CentOS-7 - Updates enabled: 953 updates-source/7 CentOS-7 - Updates Sources enabled: 0 repolist: 32,133
4 清空缓存
yum clean all rm -f /var/cache/yum
5 安装更新
通过对3中repo id的查询,可用使用如下命令,进行全局更新到指定版本
yum --disablerepo='*' --enablerepo='C7.4*' upgrade
6 更新指定软件
yum --disablerepo='*' --enablerepo='C7.4*,epel' update kernel
7 回到正确的release
centos-release是版本标识,我们应该始终保持它指示着正确的信息。
将centos-release包降级回7.4, 之后所有的默认repo便都指向了7.4。
yum --disablerepo="*" --enablerepo="C7.4.1708-*" --enablerepo="epel*" downgrade centos-release
8 常见问题
8.1
Error: Multilib version problems found. This often means that the root cause is something else and multilib version checking is just pointing out that there is a problem. Eg.: 1. You have an upgrade for systemd-libs which is missing some dependency that another package requires. Yum is trying to solve this by installing an older version of systemd-libs of the different architecture. If you exclude the bad architecture yum will tell you what the root cause is (which package requires what). You can try redoing the upgrade with --exclude systemd-libs.otherarch ... this should give you an error message showing the root cause of the problem. 2. You have multiple architectures of systemd-libs installed, but yum can only see an upgrade for one of those architectures. If you don't want/need both architectures anymore then you can remove the one with the missing update and everything will work. 3. You have duplicate versions of systemd-libs installed already. You can use "yum check" to get yum show these errors. ...you can also use --setopt=protected_multilib=false to remove this checking, however this is almost never the correct thing to do as something else is very likely to go wrong (often causing much more problems). Protected multilib versions: systemd-libs-219-42.el7_4.10.i686 != systemd-libs-219-57.el7.x86_64 Error: Protected multilib versions: elfutils-libs-0.168-8.el7.i686 != elfutils-libs-0.170-4.el7.x86_64 Error: Protected multilib versions: libselinux-2.5-11.el7.i686 != libselinux-2.5-14.1.el7.x86_64 Error: Protected multilib versions: elfutils-libelf-0.168-8.el7.i686 != elfutils-libelf-0.170-4.el7.x86_64 Error: Protected multilib versions: pam-1.1.8-18.el7.i686 != pam-1.1.8-22.el7.x86_64 Error: Protected multilib versions: nss-softokn-freebl-3.28.3-8.el7_4.i686 != nss-softokn-freebl-3.36.0-5.el7_5.x86_64 Error: Protected multilib versions: libsepol-2.5-6.el7.i686 != libsepol-2.5-10.el7.x86_64
没有解决。。。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
2016-12-06 [Virtualization][qemu][kvm][virtio] 使用 QEMU/KVM 模拟网卡多队列
2016-12-06 [archlinux][hardware] 查看SSD的使用寿命