替换系统自带yum源(针对执行yum出现未注册的情况)

文章转载自:https://blog.csdn.net/otmqixi/article/details/81564515
我们安装好RHEL的Linux后,执行yum命令安装软件,如果是未注册的肯定会出现This system is not registered with an entitlement server. You can use subscription-manager to register. 类似这样的问题
具体如下图:
在这里插入图片描述
这是因为红帽的企业版Linux系统RHEL是收费的,必须要注册才可正常使用。

这时我们就得想办法了。替换掉原版的yum,安装一个免费的yum源–>CentOS(CentOS已经被红帽收购,且跟RHEL系统没多大区别,最主要还是可以免费使用)

我们将RHEL7的yum源更换为CentOS7的!

具体流程:

1.检查并删除原有的yum源
2.下载安装CentOS的yum相关软件包
3.配置repo文件
1.检查并删除原有的yum源

检查yum源:rpm -qa | grep yum
在这里插入图片描述
删除原有的yum源: rpm -qa|grep yum|xargs rpm -e --nodeps

2.下载安装CentOS的yum源

网上找的这几个可以下载的网站

阿里云网络源地址:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

网易163网络源地址:http://mirrors.163.com/

CentOS网络源地址:http://centos.ustc.edu.cn/centos/

我这里用了网易的。

①点击centos进入
在这里插入图片描述
②找到7.6版本的(这个版本号不固定,随时间变化而变化,一般点最新版本)
在这里插入图片描述
③依此进入到os/x86_64/Packages中

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
④Ctrl+F搜索yum–>找到下面几个–>点击鼠标右键–>复制链接地址

http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm

http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rp

http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
在这里插入图片描述
在这里插入图片描述
⑤在终端中通过wget指令下载(确保联网,可通过ping一下百度服务器看看联网没,Crtl+c终止命令)
在这里插入图片描述
注意:如果ping 百度没有反应也不能说明没连上网,可以敲命令: curl http://www.baidu.com 试试,如果能打印出网页的原文件来,也说明连上网了。如下图:
在这里插入图片描述

wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm

wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://mirrors.163.com/centos/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

⑥为了防止几个包安装时有互相依赖,使用 rpm -ivh yum-* 命令一次性安装三个包
在这里插入图片描述

⑦使用第一条命令检查yum是否安装成功:rpm -qa |grep yum
在这里插入图片描述

3.配置repo文件(关键!前面的能不能起作用就看这一步了)

①在/etc目录下重命名备份原来的repo:mv yum.repos.d yum.repos.d.backup
在这里插入图片描述

②建一个新的yum.repos.d目录(确保在/etc目录下)
在这里插入图片描述

③下载一个CentOS的repo(我们可以在网易镜像站的centos使用帮助中下载学习)

在这里插入图片描述
在这里插入图片描述

和下载软件包一样下载CentOS7的repo
在这里插入图片描述

通过 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 下载
在这里插入图片描述

④通过vim打开并编辑repo

打开如下样子
在这里插入图片描述

将所有的$releasever全部替换成版本号–>7.6.1810:

shift+: 编辑 输入下面的指令

%s/$releasever/7.6.1810/g

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=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=os baseurl…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=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=updates ba…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=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=extras bas…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
wq保存退出

⑥根据使用说明文档,我们要清除缓存

yum clean all ##清理缓存
在这里插入图片描述

yum makecache ##重新生成缓存

在这里插入图片描述

这一步可能还会出现未注册的提示,我们不用在意

⑦使用yum repolist all查看是否成功
在这里插入图片描述

⑧安装一个mysql试试
在这里插入图片描述

参考:
https://blog.csdn.net/qq_32368213/article/details/80446688

https://blog.csdn.net/feng_zhiyu/article/details/80464336

作者:学编程的鹿
来源:CSDN
原文:https://blog.csdn.net/otmqixi/article/details/81564515
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值