Linux部分-替换yum源(针对执行yum出现未注册的情况)

我们安装好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.5版本的

③依此进入到os/x86_64/Packages中

④Ctrl+F搜索yum-->找到下面几个-->点击鼠标右键-->复制链接地址

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

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

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

⑤在终端中通过wget指令下载(确保联网,可通过ping一下百度服务器看看联网没,Crtl+c终止命令)

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

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

wget http://mirrors.163.com/centos/7.5.1804/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.5.1804:

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

%s/$releasever/7.5.1804/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.5.1804 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7.5.1804/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7.5.1804 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7.5.1804/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.5.1804 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7.5.1804/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.5.1804 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7.5.1804/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

猜你喜欢

转载自blog.csdn.net/otmqixi/article/details/81564515
今日推荐