Redhat 7自带的yum源需要付费注册,未注册情况下会报如下错误,且用yum repolist all检查源数目为0。这时候需要将RedHat 7自带的yum源 替换成CentOS 7免费源
解决方法一:
一,使用网易163开源镜像站 http://mirrors.163.com/ #1,查看原有yum包 rpm -qa|gerp yum #2,卸载yum包 rpm -qa|grep yum|xargs rpm -e --nodeps rpm -qa|grep yum #3,创建下载路径,下载centos7.5 yum包 mkdir /tmp/pkg && cd /tmp/pkg wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm #4,安装下载好的rpm包 rpm -ivh yum-* rpm -qa|grep yum #5,替换原有源 cd /etc/yum.repos.d/ && rm -rfv * #6,下载163源 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo #7,将下载好的文件中的 $releasever 全部修改为目标版本 7.5.1804 #为防止出错,以下为改好版本 [base] name=CentOS-7.5.1804 - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/7.5.1804/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-7.5.1804 - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7.5.1804/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-7.5.1804 - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/7.5.1804/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-7.5.1804 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7.5.1804/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #8,更新 yum clean all && yum makecache #9,查看是否更新成功 yum repolist all
方法二:思路一样,此处只提供重要命令
1,删除自带yum包 rpm -aq|grep yum|xargs rpm -e --nodeps 2,下载阿里云rpm包 wget http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm wget http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm 3,安装下载好的rpm包 rpm -ivh yum-* 4,配置阿里云源文件 vim /etc/yum.repos.d/aliyun.repo [base] name=CentOS-$releasever - Base baseurl=http://mirrors.aliyun.com/centos/7.2.1511/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=http://mirrors.aliyun.com/centos/7.2.1511/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/RPM-GPG-KEY-CentOS-7 [extras] name=CentOS-$releasever - Extras baseurl=http://mirrors.aliyun.com/centos/7.2.1511/extras//$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/RPM-GPG-KEY-CentOS-7 [centosplus] name=CentOS-$releasever - Plus baseurl=http://mirrors.aliyun.com/centos/7.2.1511/centosplus//$basearch/ gpgcheck=1 enabled=0 5,更新 yum clean all && yum makecache
补充:
阿里云 centos 的yum源 1,切记先做好备份 2,下载 CentOS 6 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo CentOS 7 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo