当前位置:   article > 正文

Red Hat Enterprise Linux 7 / 8 / 9 更换 Centos 源镜像_redhat.repo编辑

redhat.repo编辑

Red Hat  YUM 源是需要注册付费的,如果要使用 Red Hat 系统安装软件,需要将Red Hat 源替换为CentOS对应的源,在替换 YUM 源的过程以及所遇到的问题;如不一定要使用 Red Hat 系统,建议直接下载使用 CentOS 

当前Red Hat 版本 测试环境三台,分别为  Red Hat 7 /8 9.2 / 

  1. [root@localhost ~]# vi /etc/hosts  修改计算机名称
  2. [root@localhost ~]# nmcli general hostname xx 修改计算机名称
  3. [root@localhost ~]# cat /etc/redhat-release 查看系统版本信息

Red Hat Enterprise Linux Server release 7.9 (Maipo)

Red Hat Enterprise Linux release 8.8 (Ootpa)

Red Hat Enterprise Linux release 9.2 (Plow) 

一、Red Hat Enterprise Linux 7 更换方式:

This system is not registered with an entitlement server. You can use subscription-manager to register.

1.1  先删除系统自带的 yum 软件包

[root@redHatEnterpriseLinux7 ~]# rpm -qa |grep yum

  1. [root@redHatEnterpriseLinux7 ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
  2. [root@redHatEnterpriseLinux7 ~]# rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps

1.2 . 下载 centos7  6个相关的软件包

  1. http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
  2. http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
  3. http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
  4. http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
  5. http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
  6. http://mirrors.163.com/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm

1.3  将 rmp 6个包上传到 opt 的目录 需要注意安装顺序:

  1. ----安装顺序:
  2. rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
  3. rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm
  4. rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
  5. ----这两个要一起安装
  6. rpm -ivh yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm yum-3.4.3-168.el7.centos.noarch.rpm
  7. ----最后安装 wget
  8. [root@redHatEnterpriseLinux7 opt]# rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm

1.4 通过 wget 下载配置文件 Centos

[root@redHatEnterpriseLinux7 opt]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

1.5 修改 刚刚 wget 下载来的 CentOS-Base.repo 配置 文件 位于 /etc/yum.repos.d 目录

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-7 - Base - mirrors.aliyun.com
  14. failovermethod=priority
  15. baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
  16. http://mirrors.aliyuncs.com/centos/7/os/$basearch/
  17. http://mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
  18. gpgcheck=1
  19. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  20. #released updates
  21. [updates]
  22. name=CentOS-7 - Updates - mirrors.aliyun.com
  23. failovermethod=priority
  24. baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
  25. http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
  26. http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
  27. gpgcheck=1
  28. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  29. #additional packages that may be useful
  30. [extras]
  31. name=CentOS-7 - Extras - mirrors.aliyun.com
  32. failovermethod=priority
  33. baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
  34. http://mirrors.aliyuncs.com/centos/7/extras/$basearch/
  35. http://mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
  36. gpgcheck=1
  37. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  38. #additional packages that extend functionality of existing packages
  39. [centosplus]
  40. name=CentOS-7 - Plus - mirrors.aliyun.com
  41. failovermethod=priority
  42. baseurl=http://mirrors.aliyun.com/centos/7/centosplus/$basearch/
  43. http://mirrors.aliyuncs.com/centos/7/centosplus/$basearch/
  44. http://mirrors.cloud.aliyuncs.com/centos/7/centosplus/$basearch/
  45. gpgcheck=1
  46. enabled=0
  47. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  48. #contrib - packages by Centos Users
  49. [contrib]
  50. name=CentOS-7 - Contrib - mirrors.aliyun.com
  51. failovermethod=priority
  52. baseurl=http://mirrors.aliyun.com/centos/7/contrib/$basearch/
  53. http://mirrors.aliyuncs.com/centos/7/contrib/$basearch/
  54. http://mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/
  55. gpgcheck=1
  56. enabled=0
  57. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  1. [root@redHatEnterpriseLinux7 yum.repos.d]# vi CentOS-Base.repo
  2. [root@redHatEnterpriseLinux7 yum.repos.d]# mv CentOS-Base.repo redhat.repo
  3. [root@redHatEnterpriseLinux7 ~]# yum clean all
  4. [root@redHatEnterpriseLinux7 ~]# yum makecache

1.6  清理一下缓存 和 生成一下 缓存  yum clean all  &  yum makecache

 1.7  测试 yum 安装 yum install -y lrzsz   yum -y install vim*   和 yum update 是否安装成功

[root@redHatEnterpriseLinux7 ~]# yum repolist

二、Red Hat Enterprise Linux 8 更换方式:

2.1 在配置文件中关闭这个官方的订阅  编辑配置文件“  更改参数“ enabled = 1”到“ enabled = 0”

  1. vi /etc/yum/pluginconf.d/subscription-manager.conf
  2. [main]
  3. enabled=0

2.2 将 Red Hat  官方订阅删除

yum remove subscription-manager

2.3 red hat 8 更换 Centos 8 阿里云镜像源;

  1. 备份一下 redhat.repo 文件
  2. mv /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.bak
  3. 获取新的 CentOS-Base.repo 到 /etc/yum.repos.d/
  4. curl -o /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  5. 也可以使用 wget -O 来获取,但需要手动下在 rpm -ivh wget-1.14-18.el7_6.1.x86_64 来安装
  6. wget -O /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  7. 下载新的CentOS-Base.repo 到 /etc/yum.repos.d/ (这里用的CentOS 8.0)

2.4 更换完成之后要 进行清除缓存,生成缓存;

  1. [root@redHatEnterpriseLinux8 ~]# yum clean all
  2. [root@redHatEnterpriseLinux8 ~]# yum makecache

2.5  测试 yum 安装 yum -y install wget  &  yum install -y lrzsz   看看能否安装成功;

三、Red Hat Enterprise Linux 9 更换方式:

3.1  修改红帽的订阅管理配置文件  vi subscription-manager.conf
       把enabled的置改成0,然后保存  , 再删除 官方订阅  yum remove subscription-manager

  1. [root@RedHatEnterpriseLinux9 ~]# cd /etc/yum/pluginconf.d/
  2. [root@RedHatEnterpriseLinux9 ~]# vi subscription-manager.conf
  3. [root@RedHatEnterpriseLinux9 ~]# yum remove subscription-manager

3.2 再删除 cd /etc/yum.repos.d 目录下的 redhat.repo 文件 ,   rm -rf  redhat.repo 
      如没有 redhat.repo 这个文件了,就不用管:

3.3  使用 vi  redhat.repo 编辑一个新的配置文件:

  1. vi redhat.repo 添加如下内容:
  2. [AppStream]
  3. name=AppStream
  4. baseurl=http://mirrors.aliyun.com/almalinux/9.2/AppStream/x86_64/os/
  5. gpgcheck=0
  6. enabled=1
  7. [BaseOS]
  8. name=BaseOS
  9. baseurl=http://mirrors.aliyun.com/almalinux/9.2/BaseOS/x86_64/os/
  10. gpgcheck=0
  11. enabled=1
  12. [extras]
  13. name=extras
  14. baseurl=http://mirrors.aliyun.com/almalinux/9.2/extras/x86_64/os/
  15. gpgcheck=0
  16. enabled=1
  17. [plus]
  18. name=plus
  19. baseurl=http://mirrors.aliyun.com/almalinux/9.2/plus/x86_64/os/
  20. gpgcheck=0
  21. enabled=1
  22. [devel]
  23. name=devel
  24. baseurl=http://mirrors.aliyun.com/almalinux/9.2/devel/x86_64/os/
  25. gpgcheck=0
  26. enabled=1
  27. [NFV]
  28. name=NFV
  29. baseurl=https://mirrors.aliyun.com/almalinux/9.2/NFV/x86_64/os/
  30. gpgcheck=0
  31. enabled=1
  32. [CRB]
  33. name=CRB
  34. baseurl=https://mirrors.aliyun.com/almalinux/9.2/CRB/x86_64/os/
  35. gpgcheck=0
  36. enabled=1
  37. [HighAvailability]
  38. name=HighAvailability
  39. baseurl=https://mirrors.aliyun.com/almalinux/9.2/HighAvailability/x86_64/os/
  40. gpgcheck=0
  41. enabled=1

3.4  执行  yum clean all  &  yum makecache

  1. [root@RedHatEnterpriseLinux9 ~]# yum clean all 
  2. [root@RedHatEnterpriseLinux9 ~]# yum makecache

3.5 测试 dnf 安装 yum install wget  &  yum install lrzsz  &  yum update 看看能否安装成功; 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/149261?site
推荐阅读
相关标签
  

闽ICP备14008679号