时间:2020.06.30
环境:RedHat 7.3
目的:替换RedHat yum源为Centos yum源
说明:RHEL7.3 替换为Centos7的源
作者:Zhong QQ交流群:121160124 欢迎加入!
在VMware安装了一台RedHat 7.3的服务器进行测试 配置好IP、网关等之后确认能ping通外网 然而在执行yum update或者使用yum命令安装软件时提示以下的信息
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management.
You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
提示需要注册才能使用 注册听说是收费的 而我只是想要验证RedHat的一个功能 基本就不会再用 网上找了好些教程大多都是卸载自带的yum 去下载Centos的yum包再进行安装配置云云 测试之后根本行不通 而且也比较难还原原有的配置 经常同事一个大神的指点和网友的提示 找到了一条简单的路径实现替换RedHat yum源的问题 以下是步骤
备份系统自带的yum源文件
mv /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.backup
下载阿里云的源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
修改repo源文件
sed -i "s/\$releasever/7/g" /etc/yum.repos.d/CentOS-Base.repo # 系统发行版本替换
sed -i "s/\$basearch/x86_64/g" /etc/yum.repos.d/CentOS-Base.repo # 系统硬件架构号替换
运行 yum makecache 生成缓存
yum makecache
接下来就能正常使用了!
Note:
1.在阿里云关于配置centos源的文档中提到以下的提示:
非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。用户也可自行修改相关配置: eg:
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
但在本例中是不适用的 应该是指非阿里云ECS的centos系统
2.如果上面的方案不可用,可尝试做如下的修改:
sed -i "s/http/https/g" /etc/yum.repos.d/CentOS-Base.repo
详细情况以实际的系统提示和场景为准!!!
交流群:121160124