技术宅

当前位置:首页 > 服务器技术 > linux主机

linux主机

CentOS升级到指定小版本

时间:11-09 作者:
CentOS 的小版本每隔一段时间,都会更新一次,比如CentOS 7是一个大系列,后面有CentOS7.1 ,7.2 , 7.3 等。截止现在,已经更新到7.9。

yum update #会直接更新到当前最新版本,切
CentOS 的小版本每隔一段时间,都会更新一次,比如CentOS 7是一个大系列,后面有CentOS7.1  ,7.2 , 7.3 等。截止现在,已经更新到7.9。

yum update   #会直接更新到当前最新版本,切记,慎重。

例如:目前是7.9, 项目需要7.6版本,现在系统上7.5,可以通过升级到指定版本解决,无需重新安装OS. 

1、备份原来源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2、编译需要升级到指定源,源版本可以在 http://olcentchan.chinacloudapp.cn/centos/ 查看,如下面是7.6.1810版本,如果需要其他版本,改成相应的版本即可。

# vim /etc/yum.repos.d/CentOS-Base.repo
 
[base]
name=CentOS-7.6.1810 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://olcentchan.chinacloudapp.cn/centos/7.6.1810/os/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/os/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/os/$basearch/
gpgcheck=1
gpgkey=http://olcentchan.chinacloudapp.cn/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-7.6.1810 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://olcentchan.chinacloudapp.cn/centos/7.6.1810/updates/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/updates/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/updates/$basearch/
gpgcheck=1
gpgkey=http://olcentchan.chinacloudapp.cn/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-7.6.1810 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://olcentchan.chinacloudapp.cn/centos/7.6.1810/extras/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/extras/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/extras/$basearch/
gpgcheck=1
gpgkey=http://olcentchan.chinacloudapp.cn/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7.6.1810 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://olcentchan.chinacloudapp.cn/centos/7.6.1810/centosplus/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/centosplus/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://olcentchan.chinacloudapp.cn/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-7.6.1810 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://olcentchan.chinacloudapp.cn/centos/7.6.1810/contrib/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/contrib/$basearch/
        http://olcentchan.chinacloudapp.cn/centos/7.6.1810/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://olcentchan.chinacloudapp.cn/centos/RPM-GPG-KEY-CentOS-7
 
3、升级

yum clean all  #清除 Yum 在本机的缓存
yum repolist   #查看仓库信息
yum update   #更新,系统会自动更新你源配置的版本
注意事项:

升级版本之前,不要通过yum install 安装或者更新相对应的软件包,容易导致软件版本和依赖的冲突,而升级失败。