CentOS系统下用yum update命令默认会升级到最新版本,CentOS仓库并不维护历史版本,所以只能使用 vault.centos.org 历史版本快照进行更新。
本文以将7.0.1406升级到7.7.1908为例。
mkdir -p /etc/yum.repos.d/backup mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
vi /etc/yum.repos.d/CentOS-Vault.repo
# CentOS Vault contains rpms from older releases in the CentOS-7 # tree. # C7.7.1908 [C7.7.1908-base] name=CentOS-7.7.1908 - Base baseurl=http://vault.centos.org/7.7.1908/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=1 [C7.7.1908-updates] name=CentOS-7.7.1908 - Updates baseurl=http://vault.centos.org/7.7.1908/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=1 [C7.7.1908-extras] name=CentOS-7.7.1908 - Extras baseurl=http://vault.centos.org/7.7.1908/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=1 [C7.7.1908-centosplus] name=CentOS-7.7.1908 - CentOSPlus baseurl=http://vault.centos.org/7.7.1908/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=1 [C7.7.1908-fasttrack] name=CentOS-7.7.1908 - Fasttrack baseurl=http://vault.centos.org/7.7.1908/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=1
yum repolist
yum list updates | grep "centos-release"
yum clean all rm -rf /var/cache/yum
yum -y update
到此,更新至指定版本的任务就已完成操作了。
mv /etc/yum.repos.d/CentOS-Vault.repo /etc/yum.repos.d/backup/ mv /etc/yum.repos.d/CentOS-Vault.repo.rpmnew /etc/yum.repos.d/CentOS-Vault.repo
yum clean all yum makecache