我使用的是自己的虚拟机,需要先配置域名解析,可以访问外网之后才能配置yum源
1、添加解析并测试,命令如下:
echo "nameserver 223.5.5.5" >> /etc/resolv.conf
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
ping -c 4 www.baidu.com
2、测试yum及python包是否有,如果有就卸载掉:
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps
3、我是要通过rom包进行安装,所以要先创建放置软件包的文件夹
mkdir -p /opt/soft/yum
cd /opt/soft/yum
4、下载相关软件包,亲测可用
wget -c http://vault.centos.org/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget -c http://vault.centos.org/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget -c http://vault.centos.org/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
wget -c http://vault.centos.org/6.5/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget -c http://vault.centos.org/6.5/os/x86_64/Packages/python-urlgrabber-3.9.1-9.el6.noarch.rpm
5、安装各个包
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh python-urlgrabber-3.9.1-9.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm yum-3.2.29-40.el6.centos.noarch.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm yum-3.2.29-40.el6.centos.noarch.rpm
rpm -qa|grep python
rpm -qa|grep yum
6、编辑配置文件:
cd /etc/yum.repos.d
mkdir bak
ll
mv * bak/
wget -c wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
sed -i "s;\$releasever;6;g" CentOS6-Base-163.repo
7、清除缓存
yum clean all
yum makecache