Centos5.6 升级系统
发表于:2022-04-03浏览:26次TAG: #centos
## 使用centos-vault作为停止支持的CentOS的yum源 [link](https://www.javatang.com/archives/2017/09/04/13261799.html)
CentOS 5.x在2017年3月31日结束支持,导致使用yum安装和更新程序的时候出现404错误。在CentOS官方有一个http://vault.centos.org/包含所有发行的CentOS版本,因此需要将yum源修改为centos-vault的源,这里以CentOS 5.x为例进行讲解。
将 /etc/yum.repos.d/CentOS-Base.repo 文件中所有的源主机地址修改为http://vault.centos.org,并且将$releasever替换为当前系统所使用的CentOS版本,可以使用5.x最后的版本5.11。注意,需要将所有其他备用的主机都删除,内容如下:
```
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-5.6 - Base
failovermethod=priority
baseurl=http://vault.centos.org/5.6/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-5.6 - Updates
failovermethod=priority
baseurl=http://vault.centos.org/5.6/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5.6 - Extras
failovermethod=priority
baseurl=http://vault.centos.org/5.6/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5.6 - Plus
failovermethod=priority
baseurl=http://vault.centos.org/5.6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5.6 - Contrib
failovermethod=priority
baseurl=http://vault.centos.org/5.6/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5
```
确认在 /etc/yum.repos.d/目录没有除了CentOS-Base.repo之外其他以repo结尾的文件,如果有的话需要删除,然后执行 yum clean all && yum makecache 更新和启用新的yum源。
## centos如何升级到最新版本
### 检查系统版本
```
$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
```
### 备份重要数据
(例如/etc, /var,/opt)。如果centos是安装在虚拟机上,那么可以使用快照进行备份。像VMware虚拟机可以快照备份,当然更奢侈一点是备份整个虚拟机。也可以针对重要程序数据进行备份,例如MySQL, Appache, Nginx, DNS等等。
### 运行yum命令升级
```
$ sudo yum clean all
$ sudo yum update
```
### 重启系统
```
$ sudo reboot
```
### 查看现在系统版本
```
$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
```
希望本文能够协助你顺利升级centos 7到最新版本。
### 常用命令
```
cat /etc/redhat-release,查看版本
uname -a – 显示版本和内核信息
rpm -q kernel – 显示内核版本
yum -y update – 升级所有应用版本,更新CentOS到最新镜像版本
```