欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何在Red Hat 7系统中设置Yum仓库(无需过度官方化)

最编程 2024-07-19 17:29:38
...

版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。 https://blog.****.net/wh211212/article/details/52936814

1、前提

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

#系统环境

root@linuxprobe[06:22:13]:~$cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.2 (Maipo)

2、删除redhat自带的yum源

rpm -aq|grep yum|xargs rpm -e --nodeps

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

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

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

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm  yum-plugin-fastestmirror-1.1.31-34.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.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

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

yum clean all && yum makecache

7、测试源

yum update -y --skip-broken

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

如果报错:

wget http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64/RPM-GPG-KEY-CentOS-7

rpm –import RPM-GPG-KEY-CentOS-7