工程师计划 linux Red hat7替换centos7的Yum源

Red hat7替换centos7的Yum源

RedHat Yum源是收费的,没有成功注册RedHat的机器无法正常使用Yum源,而CentOS Yum源是免费的,国内网易、阿里的Yum源,稳定可靠,并且ReHat和Centos是一家,它俩基本没有什么区别,所以将rethat yum源改为centos的yum源。

一、卸载RedHat原有的Yum源
查看原有的yum源
rpm -qa |grep yum

卸载
rpm -qa|grep yum|xargs rpm -e –nodeps(不检查依赖,直接删除rpm包)

二、下载Centos Yum源
网址
由于各个网站实际yum源版本经常更新,所以建议直接去网站下载,不要直接复制网上的命令类似于:
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm,这个你只会连接不上
阿里云:https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
下载的包
注意:包名后缀可能因为版本不同而不同
python-urlgrabber-3.10-10.el7.noarch.rpm
yum-3.4.3-167.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
yum-updateonboot-1.1.31-53.el7.noarch.rpm
yum-utils-1.1.31-53.el7.noarch.rpm
rpm-4.11.3-43.el7.x86_64.rpm
安装
由于这几个包互相有依赖性,所以统一直接安装
rpm -ivh –force *.rpm

出现以下结果为安装成功

警告:python-urlgrabber-3.10-10.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中… ################################# [100%] 正在升级/安装…
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 14%]

2:rpm-4.11.3-43.el7 ################################# [ 29%]

3:python-urlgrabber-3.10-10.el7 ################################# [ 43%]

4:yum-plugin-fastestmirror-1.1.31-5################################# [ 57%]

5:yum-3.4.3-167.el7.centos ################################# [ 71%]

6:yum-updateonboot-1.1.31-53.el7 ################################# [ 86%]

7:yum-utils-1.1.31-53.el7 ################################# [100%]

 

三、配置repo
下载新的repo文件
地址http://mirrors.aliyun.com/repo/
选择下载对应的repo文件
Centos-7.repo
到对应目录下
cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
redhat.repo

将原repo文件移出,把下载好的文件放到该位置
该文件内容为
# 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-$releasever – Base – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates] name=CentOS-$releasever – Updates – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras] name=CentOS-$releasever – Extras – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus] name=CentOS-$releasever – Plus – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib – packages by Centos Users
[contrib] name=CentOS-$releasever – Contrib – mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

替换内容
用密令行的方式把$releasever替换为7,具体操作是按下ESC键然后:就可以打下替换的命令%s/&releasever/7/g
:%s/$releasever/7/g
1
四、重构
yum clean all
yum makecache
yum update
————————————————
版权声明:本文为CSDN博主「山河君」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_42956179/article/details/109618774

本文来自网络,不代表本网站立场,转载请注明出处。http://loadingok.com/2138.html
© 2021 京ICP备2021027871号-1
联系我们

联系我们

18513870113

在线咨询: QQ交谈

邮箱: 1140136143@qq.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部