第一步:先卸载原来的yum
rpm -qa |grep yum 查看原来是否安装
yum-3.4.3-118.el7.noarch
yum-utils-1.1.31-24.el7.noarch
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
直接卸载:
rpm -qa|grep yum|xargs rpm -e --nodeps
在次运行 :rpm -qa |grep yum 发现卸载干净了
第二步:替换原有yum
可以在home文件下建一个yum文件夹,然后将以下6个文件(只是rpm)在
http://mirrors.163.com/centos/7/os/x86_64/Packages/
网址中找到,并复制到其中。
第三步:进入yum文件夹中
安装所有rpm
rpm -ivh *.rpm
第四步:建立文件CentOS-Base.repo
vim /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
#mirrorlist=http://mirrorlist.centos.org/?release=KaTeX parse error: Expected 'EOF', got '&' at position 2: 7&̲arch=basearch&repo=os
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
#mirrorlist=http://mirrorlist.centos.org/?release=KaTeX parse error: Expected 'EOF', got '&' at position 2: 7&̲arch=basearch&repo=updates
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
#mirrorlist=http://mirrorlist.centos.org/?release=KaTeX parse error: Expected 'EOF', got '&' at position 2: 7&̲arch=basearch&repo=extras
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
−
P
l
u
s
−
163.
c
o
m
b
a
s
e
u
r
l
=
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
163.
c
o
m
/
c
e
n
t
o
s
/
7
/
c
e
n
t
o
s
p
l
u
s
/
7 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7/centosplus/
7−Plus−163.combaseurl=http://mirrors.163.com/centos/7/centosplus/basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
第六步:执行清除缓存命令
yum clear all