Centos6.8更新yum

一、重新安装

1. 卸载yum

  • CentOS6停止维护更新日期2020年11月30日,下架了包括官方所有的CentOS6源(包括国内的镜像站)
#查看yum
 rpm -qa yum
 #卸载yum
 rpm -qa | grep yum | xargs rpm -e --nodeps

2. 到https://vault.centos.org/下载yum相关的RPM包

  • 选择你要的版本,这里使用6.8版本https://vault.centos.org/6.8/os/x86_64/Packages/

在这里插入图片描述

python-iniparse-0.3.1-2.1.el6.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-3.2.29-73.el6.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm

3. 安装rpm包

  • 下载完成之后,上传至服务器,用rpm命令进行安装
rpm -ivh --force --nodeps python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh --force --nodeps yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh --force --nodeps yum-3.2.29-73.el6.centos.noarch.rpm
rpm -ivh --force --nodeps yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm

4. 下载yum-3.4.3.tar.gz

  • http://yum.baseurl.org/wiki

在这里插入图片描述

  • 上传到服务器解压
tar -zxvf yum-3.4.3.tar.gz 
  • 进入到yum-3.4.3文件夹中,执行下面命令
./yummain.py update 
  • 再输入yum,看是否成功安装

二、切换yum源

1. 使用官方centos-vault源

vi /etc/yum.repos.d/CentOS-Base.repo
  • 使用下面的配置,这里是6.8,根据个人需要可以更换成其他的
# 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-6.8 - Base - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.8 - Updates - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.8 - Extras - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.8 - Plus - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.8 - Contrib - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

2. 清除缓存

  • 替换CentOS-Base.repo文件内容后清除下缓存
yum clean all && yum makecache

猜你喜欢

转载自blog.csdn.net/qq_40977118/article/details/114308873
今日推荐