1、首先到http://mirrors.163.com/centos下载软件包
x86 地址:http://mirrors.163.com/centos/6/os/i386/Packages/
x86_64 地址:http://mirrors.163.com/centos/6/os/x86_64/Packages/
必要下载的软件包有(以64位系统为例):
a python-iniparse-0.3.1-2.1.el6.noarch.rpm
b yum-3.2.29-40.el6.centos.noarch.rpm
c yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
d yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
下载命令:
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
(有时候会出现mirrors.163.com无法解析,解决办法有2种,其一是直接访问http://mirrors.163.com/centos/6/os/ 选择对应的系统版本然后搜索需要的安装包;另一种方法是在ifcfg-etho 中加入DNS1:114.114.114.114或者8.8.8.8 )
2、卸载RedHat自带的yum
rpm -qa | grep yum | xargs rpm -e --nodeps
--nodeps 强制卸载,不管依赖关系
3、安装下载的centos的yum包:
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
最后2个需要一起安装,否则会出现依赖性错误
4.下载CentOS6-Base-163.repo文件,存放到/etc/yum.repo.d中
cd /etc/yum.repo/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
5、编辑CentOS6-Base-163.repo文件,将其中的$releasever更改为centos的版本号
vi CentOS6-Base-163.repo
在命令模式下输入 :0,$s/\$releasever/6/g
6、yum clean all 清除原有缓存
7、yum makecache 获取yum列表