Redhat 7.x配置yum源

版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。

https://blog.csdn.net/wh211212/article/details/52936814

1、前提

由于redhat系统不再期官网注册,系统安装完成之后无法正常使用期yun源,因此更改redhat的yum源为CentOS的源

系统环境

[root@docker01 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 (Maipo)

2、删除redhat自带的yum源

[root@docker01 ~]# rpm -aq|grep yum|xargs rpm -e --nodeps
警告:/etc/yum/pluginconf.d/langpacks.conf 已另存为 /etc/yum/pluginconf.d/langpacks.conf.rpmsave

3、从阿里云下载yum相关安装包

wget http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.rpm                
wget http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm        
wget http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm 

4、rpm安装下载的yum包,按顺序执行下面命令

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm  
rpm -ivh yum-3.4.3-167.el7.centos.noarch.rpm  yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm  

5、创建文件/etc/yum.repos.d/aliyun.repo并写入

vim /etc/yum.repos.d/aliyun.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/7.8.2003/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/RPM-GPG-KEY-CentOS-7


#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/7.8.2003/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/RPM-GPG-KEY-CentOS-7


[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/7.8.2003/extras//$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.aliyun.com/centos/7.8.2003/centosplus//$basearch/
gpgcheck=1
enabled=0

6、创建aliyun前记得把redhat自带的源一走或者删除

yum clean all && yum makecache

7、测试源

yum update -y --skip-broken

能看到已经能够成功的通过yum安装相关软件包

如果报错:

wget http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/RPM-GPG-KEY-CentOS-7
rpm –import RPM-GPG-KEY-CentOS-7

你可能感兴趣的:(Redhat 7.x配置yum源)