redhat 6.7 切换yum源

redhat 6.7 版本 。

redhat本身的yum源需要注册,本文切换为Centos 6的源 。

  1. 查看并卸载本机安装的yum相关包
rpm -qa |grep yum 
结果为:
yum-plugin-security-1.1.30-30.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
PackageKit-yum-plugin-0.5.8-25.el6.x86_64
yum-rhn-plugin-0.9.1-58.el6.noarch
yum-utils-1.1.30-30.el6.noarch
yum-3.2.29-69.el6.noarch
PackageKit-yum-0.5.8-25.el6.x86_64
使用如下命令卸载:
rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)
  1. 至阿里云下载相关rpm包 https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-utils-1.1.30-40.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-updateonboot-1.1.30-40.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/createrepo-0.9.9-26.el6.noarch.rpm
  1. 安装:
    使用 rpm -ivh yum-*
    这时会报错: 参见(https://www.cnblogs.com/tingyuxuanzhuzi/p/6645480.html)
    先安装: rpm -Uvh python-urlgrabber-3.9.1-11.el6.noarch.rpm
    然后再 rpm -ivh yum-*
    成功

  2. 下载源
    使用wget下载新的 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    修改CentOS-Base.repo文件中的$releasever全部替换为版本号7.
    命令: %s/$releasever/6/g

  3. yum clean all
    yum makecache

结束

(对于7.x版本,切换源时,会出现包版本问题:
阿里云上的yum包是3.4.3-154版本的, 安装出现错误 , 后至http://rpm.pbone.net/ 上下载了 150版本安装成功。
7.x版本所需的包:
python-urlgrabber-3.10-8.el7.noarch.rpm
yum-3.4.3-150.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
yum-updateonboot-1.1.31-42.el7.noarch.rpm
yum-utils-1.1.31-42.el7.noarch.rpm

你可能感兴趣的:(redhat 6.7 切换yum源)