删除当前系统自带的yum
rpm -qa |grep yum
rpm -qa|grep yum|xargs rpm -e --nodeps
下载Cenots Yum源软件
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.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-plugin-fastestmirror-1.1.30-41.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/python-urlgrabber-3.9.1-11.el6.noarch.rpm
安装
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 --force python-urlgrabber-3.9.1-11.el6.noarch.rpm
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
替换
cd /etc/yum.repos.d/ && rm -f *.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo && wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo
sed -i 's/$releasever/6/g' CentOS-Base.repo
sed -i 's/$basearch/x86_64/g' CentOS-Base.repo
sed -i 's/$basearch/x86_64/g' epel-6.repo
yum clean all && yum makecache fast
============================================(20210303)
Centos6 官方停止更新源,yum无法使用后又找了个方法
把CentOS-Base.repo 里面的东西全部删掉,添加如下内容即可
[base]
name=CentOS-6
failovermethod=priority
baseurl=https://vault.centos.org/6.9/os/x86_64/
gpgcheck=0
替换后
yum clean all
yum makecache