1、查询安装的rpm包
1
|
rpm -qa | grep yum
|
2. 删除自带的 rpm包
1
|
rpm -qa| grep yum| xargs rpm -e --nodeps
|
因为一些包之间可能会有依赖关系,所以我们需要加上参数 --nodeps 无视依赖关系。
3. 下载rpm包
rpm包下载地址http://mirrors.163.com/centos/6.9/os/x86_64/
在这个网站里,你可以自己选择需要下载的文件,进入形如5/或者6/的文件下载,其他的无法下载。
1
2
3
4
5
6
|
# mkdir yum # cd yum/ wget http: //mirrors .163.com /centos/6 .9 /os/x86_64/Packages/yum-3 .2.29-81.el6.centos.noarch.rpm
wget http: //mirrors .163.com /centos/6 .9 /os/x86_64/Packages/yum-plugin-fastestmirror-1 .1.30-40.el6.noarch.rpm
wget http: //mirrors .163.com /centos/6 .9 /os/x86_64/Packages/yum-metadata-parser-1 .1.2-16.el6.x86_64.rpm
wget http: //mirrors .163.com /centos/6 .9 /os/x86_64/Packages/yum-metadata-parser-1 .1.2-16.el6.x86_64.rpm
|
4、安装RPM包
1
2
|
# rpm -ivh *.rpm # rpm -ivh yum*.rpm |
5、删除原来的yum源
1
2
|
# cd /etc/yum.repos.d # rm -f *.repo |
6、下载163的yum源
1
|
# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo |
7、编辑yum源repo文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
vim CentOS6-Base-163.repo name=CentOS-$releasever - Base - 163.com baseurl=http: //mirrors .163.com /centos/6 .9 /os/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http: //mirror .centos.org /centos/RPM-GPG-KEY-CentOS-6
#released updates [updates] name=CentOS-$releasever - Updates - 163.com baseurl=http: //mirrors .163.com /centos/6 .9 /updates/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http: //mirror .centos.org /centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com baseurl=http: //mirrors .163.com /centos/6 .9 /extras/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http: //mirror .centos.org /centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - 163.com baseurl=http: //mirrors .163.com /centos/6 .9 /centosplus/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http: //mirror .centos.org /centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - 163.com baseurl=http: //mirrors .163.com /centos/6 .9 /contrib/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http: //mirror .centos.org /centos/RPM-GPG-KEY-CentOS-6
|
8、清理并重建缓存
1
2
|
yum clean all yum makecache fast |
9、更换完毕。
本文转自 喵来个鱼 51CTO博客,原文链接:http://blog.51cto.com/m51cto/1964876,如需转载请自行联系原作者