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