rhel7更换centos7的yum源

2019-07-28  本文已影响0人  爱你忘了爱我自己

一、解决wget无法解析DNS问题

解决方法:

1. 进入/etc/resolv.conf

2.修改或增加内容:

    nameserver 8.8.8.8

二、卸载redhat7自带的yum组件

    # rpm -qa|grep yum

    yum-utils-1.1.31-24.el7.noarch

    yum-langpacks-0.4.2-3.el7.noarch

    yum-metadata-parser-1.1.4-10.el7.x86_64

    yum-rhn-plugin-2.0.1-4.el7.noarch

    PackageKit-yum-0.8.9-11.el7.x86_64

    yum-3.4.3-118.el7.noarch

    卸载以下组件:

    # rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps

    # rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps

    # rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps

    # rpm -e yum-3.4.3-118.el7.noarch --nodeps

    # rpm -qa|grep yum|xargs rpm -e --nodeps

三、下载安装包

    mkdir /home/linuxprobe/testyum

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-langpacks-0.4.2-7.el7.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-35.el7.x86_64.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm

    wget -P /home/linuxprobe/testyum http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-35.el7.x86_64.rpm

四、安装软件包

包之间有关联关系,按顺序安装

    cd /home/linuxprobe/testyum

    rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm

    rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

    rpm -qa | grep python-urlgrabber | xargs rpm -e --nodeps(卸载之前安装过的python-urlgrabber)

    rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm

    rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps(升级rpm至4.11.3-35)

    rpm -Uvh rpm-libs-4.11.3-35.el7.x86_64.rpm --nodeps

    rpm -Uvh rpm-python-4.11.3-35.el7.x86_64.rpm --nodeps

    rpm -Uvh rpm-build-libs-4.11.3-35.el7.x86_64.rpm  --nodeps

    rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

    rpm -ivh yum-utils-1.1.31-50.el7.noarch.rpm

    rpm -ivh yum-langpacks-0.4.2-7.el7.noarch.rpm

    rpm -ivh yum-rhn-plugin-2.0.1-10.el7.noarch.rpm

    rpm -qa | grep redhat-release-server | xargs rpm -e --nodeps

    或(rpm -e redhat-release-server-7.0-1.el7.x86_64 --nodeps)

五、创建repo配置文件

    vim /etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever - Updates

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

注:$releasever 替换成相应的版本号(7)

        $basearch 替换成想要的系统位数(x86_64)

        gpgcheck=1

        enabled=1

        将RPM-GPG-KEY-CentOS-7文件拷贝到/etc/pki/rpm-gpg/目录下

六、清除缓存

    yum clean all

    yum makecache

    yum update

全部文档每步都经过实践检测。至此大功靠成,希望对学习中的朋友们有所帮助。

此文档在形成中也参考了大量网友的文章,在此不一一列出名字了,一并感谢!

上一篇下一篇

猜你喜欢

热点阅读