Red Hat7配置163YUM源

背景\需求

  • RedHat 7自带的yum源需要付费注册,未注册情况下会报错误.
  • RedHat 7成功注册后,用yum repolist all检查源数目为0。这时候需要将RedHat 7自带的yum源 替换成CentOS 7免费源。

实现步骤

  • 检查Red Hat 7包含哪些初始的yum包。
    rpm -qa |grep yum

  • 删除系统中原有的YUM源
rpm -qa|grep yum|xargs rpm -e --nodeps
  • 打开163的镜像网址:http://mirrors.163.com/centos/,并查看当前最新支持的Centos版本。
  • 下载163镜像站中CentOS 7下的 yum相关包,下载地址:http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/ 
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

  • 为避免依赖问题,建议执行一下命令,从而实现一次性安装下载的三个软件包。
     rpm -ivh yum-*

  • 执行如下命令查看是否成功安装。
rpm -qa |grep yum

  • 在/etc/yum.repos.d/目录下备份系统自带的源地址文件
mv /etc/yum.repos.d/rhel-source.repo(原始文件) /etc/yum.repos.d/rhel-source.repo.backup
http://mirrors.163.com/.help/CentOS7-Base-163.repo
  • 将下载的CentOS7-Base-163.repo文件中的 $releasever 全部修改为目标版本7.6.1810(具体版本号请参考网址http://mirrors.163.com/centos/),替换后文件如下所示:
# 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-7.6.1810 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.6.1810&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7.6.1810/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7.6.1810 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.6.1810&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7.6.1810/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.6.1810 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.6.1810&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7.6.1810/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.6.1810 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7.6.1810/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  • 清理之前的YUM缓存。
yum clean all
  • 重新生成YUM缓存。
yum makecache

  • 检查源是否已经更新。
yum repolist all

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值