CentOs更换yum,重新安装yum卸载yum

1、卸载

rpm –e –nodeps yum

2、安装

下载安装依赖

打开浏览器,登录 http://mirrors.163.com/centos/7/os/x86_64/Packages/ ,找四个文件,如下(*****代表版本号,因为版本在不停更新,所以不能精确表明,直接下载最新即可


1、yum-*****
.rpm
2、yum-metadata-parser-*****.rpm
3、yum-plugin-fastestmirror-*****
.rpm
4、python-iniparse-*****.rpm

这里我全部以假设下载的版本为1.0.0.0为例。


因文件有相互依赖性,故先安装 python-iniparse-.rpm 文件,再安装 yum-metadata-parser-.rpm,

安装命令如下:

rpm -ivh python-iniparse-1.0.0.0.rpm
rpm -ivh yum-1.0.0.0.rpm

后面的两个依赖需要强制安装,不管依赖性文件加上  “–nodeps –force” 命令

rpm -ivh –nodeps –force yum-plugin-fastestmirror-1.0.0.0.rpm
rpm -ivh –nodeps –force yum-1.0.0.0.rpm

安装过程如果出现警告不用理,如果出现error或者其他异常,请检查下载的版本兼容性。

3、更改 yum 源

如果觉得这个官方的太麻烦,直接使用我后面的连接下载文件覆盖原配置文件即可,见3.2

3.1、前往163.com下载配置文件(如果这个操作太麻烦,直接使用3.2方案)

http://mirrors.163.com/.help/CentOS7-Base-163.repo(注意系统的版本,不兼容)

将此配置文件替换/etc/yum.repos.d 同名文件,如果没有同名文件直接上传即可。

3.2、或者直接复制我的配置文件,文件命名为CentOs-Base.repo,然后上传至etc/yum.repos.d,如果这个目录下已经有CentOs-Base.repo以外的其他文件,全部删除掉。

# 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-7 - Base - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
        
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-7 - Updates - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
      
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
       
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
        
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

4、清理缓存

yum clean all

yum makecache

5、测试

yum install vim

原文地址:https://www.cnblogs.com/Sunne/p/14798682.html