Redhat更换yum源

Redhat更换yum源

RHEL的YUM源需要注册用户才能更新使用说白了就是要收费了,由于CentOS和RHEL基本没有区别,并且CentOS已经被REHL收购。所以将RHEL的YUM源替换为CentOS即可

[redhat@root ~]$ cat /etc/redhat-release   查看对应的版本号
Red Hat Enterprise Linux Server release 7.6 (Maipo)
[redhat@root ~]$ rpm -qa |grep yum    查看安装的yum源
yum-utils-1.1.31-54.el7_8.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
yum-3.4.3-168.el7.centos.noarch
[redhat@root ~]$ rpm -qa|grep yum|xargs rpm -e --nodeps  #强行卸载所以yum源
[redhat@root ~]$ rpm -qa|grep yum                        #再次查看为空
下载需要依赖的文件
[redhat@root ~]$ 
 wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.8.0-59.el6.x86_64.rpm
 
[下面五个需要下载]
rpm-4.11.3-45.el7.x86_64.rpm
python-urlgrabber-3.10-10.el7.noarch.rpm
yum-3.4.3-168.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
​
[注意] wget如果不能使用可以在下面镜像站下载导入安装(上述版本可能不同)
网易源:http://mirrors.163.com/centos/7/os/x86_64/Packages/
阿里云源:http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
[转载] https://www.cnblogs.com/ice-image/p/10422580.html
安装
[redhat@root ~]$ rpm -ivh --force rpm-4.11.3-45.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm python-urlgrabber-3.10-10.el7.noarch.rpm yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm  --force  
[强制安装]--force   不加--force可能出现报错,需要强制安装

在这里插入图片描述

配置对应的yum源
网易:http://mirrors.163.com/.help/CentOS7-Base-163.repo
阿里云:http://mirrors.aliyun.com/repo/Centos-7.repo
下载之后将其移动(拷贝)到对应的位置
[redhat@root ~]$  mv CentOS7-Base-163.repo /etc/yum.repos.d/
[redhat@root ~]$ vi /etc/yum.repos.d/CentOS7-Base-163.repo
      %s/$releasever/7/g     #使用vi编辑器进行全局替换 
[注意]:$releasever在CentOS中可以自动解析为对应版本,但是redhat不支持自动解析,需要手动替换
备份原yum文件
[redhat@root ~]$ cd /etc/yum.repos.d/
mv redhat.repo redhat.repo.bak

在这里插入图片描述

关闭订阅插件提示
[redhat@root ~]$ vi /etc/yum.conf
    plugins=0
[redhat@root ~]$ vim /etc/yum/pluginconf.d/subscription-manager.conf
    [main]
    enabled=0 #将它禁用掉
[说明]:
1.当没有禁用plugins的情况下,这里的值为1时,每次yum调用的时候,都会生成或者更新redhat.repo文件
2.这个Subscription Manager订阅管理器,它会一直去重写或者更新/etc/yum.repos.d/redhat.repo文件。

[转载]:https://www.cnblogs.com/5201351/p/13875423.html

此时已经完成yum的替换
[redhat@root ~]$ yum clean all      #清空 yum 缓存,使其设置生效
[redhat@root ~]$ yum makecache      #加载服务器软件包缓存信息,提高搜索安装软件的速度
[redhat@root ~]$ yum install vim    #下载vim编辑器测试是否替换成功
  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
是的,Red Hat 可以更换 Yum 源。您可以根据自己的需要选择合适的 Yum 源。 以下是更换 Red Hat Yum 源的一般步骤: 1. 打开终端并以 root 用户身份登录您的 Red Hat 系统。 2. 备份原始的 Yum 源配置文件,以防需要恢复: ``` cp /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.bak ``` 3. 使用文本编辑器(如 vi 或 nano)打开 `/etc/yum.repos.d/redhat.repo` 文件: ``` vi /etc/yum.repos.d/redhat.repo ``` 4. 在文件中找到 `[base]`、`[updates]`、`[extras]` 和 `[optional]` 等节,并将其注释或删除。 5. 添加新的 Yum 源配置,可以根据您的需求选择合适的源。比如,可以添加阿里云的 Yum 源: ``` [aliyum-base] name=Aliyun Base baseurl=http://mirrors.aliyun.com/redhat/rhel/$releasever/$basearch/os/ enabled=1 gpgcheck=0 [aliyum-update] name=Aliyun Update baseurl=http://mirrors.aliyun.com/redhat/rhel/$releasever/$basearch/updates/ enabled=1 gpgcheck=0 [aliyum-extras] name=Aliyun Extras baseurl=http://mirrors.aliyun.com/redhat/rhel/$releasever/$basearch/extras/ enabled=1 gpgcheck=0 [aliyum-optional] name=Aliyun Optional baseurl=http://mirrors.aliyun.com/redhat/rhel/$releasever/$basearch/optional/ enabled=1 gpgcheck=0 ``` 6. 保存并关闭文件。 7. 清除 Yum 缓存: ``` yum clean all ``` 8. 现在您可以使用新的 Yum 源进行软件包安装和更新。 请注意,更换 Yum 源可能会对系统产生影响,请确保选择可靠和适合您的需求的源,并在更换前备份原始配置文件以便需要时进行恢复。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值