RedHat7.9未注册无法使用yum解决办法

Red Hat Enterprise Linux(RHEL)是收费的,如果不买订阅将无法使用yum软件仓库,安装软件的时候多有不便。

解决办法:

  1. 第一个办法,最简单,使用CentOS。
    1. 现在分CentOS Linux版和CentOS Stream版,简单理解就是以前的CentOS Linux版发布根据RHEL更新的内容进行更新并修复其中可能的漏洞,比RHEL要晚,缺点是补丁更新慢,可能安全性差一点,好处是稳定性强一点。而现在的CentOS Stream版似乎成了RHEL的试验场,新东西新想法都是先在CentOS Stream版上发布然后再到RHEL。
  2. 第二个办法,注册红帽的开发者订阅。
    1. 这个订阅只有一年的有效期,每次到期后需要从新在系统中注册一次才能使用。参考以下这篇文章   https://developers.redhat.com/articles/renew-your-red-hat-developer-program-subscription?source=sso#
    2. https://developers.redhat.com/      注册帐号         网页最下面Join Red Hat Developer
    3. https://access.redhat.com/       查看订阅
    4. subscription-manager register --username=yourusername --password=yourpassword --auto-attach    根据你的注册帐号和密码来注册,注意username是你的注册用户名,不是注册邮箱
    5. subscription-manager list --available --all  查看所有的可用订阅以及到期时间。
    6. 使用红帽的订阅后,有一个小问题就是yum下载东西网速很慢,不稳定。但是最近也还好。
    7. 注册激活后有时候使用yum会出现This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions. emm....>别理他。
    8. 更新订阅subscription-manager attach --auto
  3. 第三个办法,用CentOS 的yum替换RHEL的yum。首先不能使用第二个办法注册之后再去换yum源,会有很奇怪的错误。其次,即使替换成功每次也是显示This system is not registered with an entitlement server. You can use subscription-manager to register.
    也就是系统没有注册。还有就是CentOS8已经停止支持了,现在的CentOS7到24年,所以替换的时候注意版本选择。没试过可以不可以用CentOS7替换RHEL8的源。
    1. 查看系统yum
      rpm -qa | gerp yum
      #显示
      #  PackageKit-yum-1.1.10-2.el7.x86_64
      # yum-rhn-plugin-2.0.1-10.el7.noarch
      # yum-metadata-parser-1.1.4-10.el7.x86_64
      # yum-3.4.3-168.el7.noarch
      # yum-langpacks-0.4.2-7.el7.noarch
      # yum-utils-1.1.31-54.el7_8.noarc
    2. 强制删除系统yum
      #强制删除
      rpm -qa|grep yum|xargs rpm -e --nodeps #再次查看,已经什么都没有了 rpm -qa|grep yum

    3. 在临时目录创建一个文件夹
      #创建一个文件夹
      mkdir /tmp/yumtmp
      #进入这个文件夹
      cd /tmp/yumtmp
      #或者直接
      mkdir /tmp/yumtmp && cd /tmp/yumtmp
    4. 下载所需文件,使用wget或者上传到系统中
      #1,创建一个文件用于wget下载
      touch down.txt
      #2,编辑文件加入下载路径(换行分隔),根据系统版本,现在是7.9。使用163镜像,具体是7.9.2009。要去http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages中查看安装包的最新版本,以最新版本下载。
      http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
      http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
      
      http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
      http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
      http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
      http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
      #3,下载 wget -i down.txt
    5. 安装这几个包,不太喜欢强制安装,所以是一个个安装的。
      #1
      rpm -ivh http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
      #2
      rpm -ivh  http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
      #3
      rpm -ivh http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
      #4这两个要同时安装
      rpm -ivh http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm  http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
      #5
      rpm -ivh http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
    6. 下载并修改CentOS7-Base-163.repo文件
      #1下载文件
      wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
      #2把这个文件CentOS7-Base-163.repo放入/etc/yum.repos.d中
      cp CentOS7-Base-163.repo /etc/yum.repos.d
      #3备份源redhat.repo 也可以重命名redhat.repo
      cd /etc/yum.repos.d
      mv redhat.repo redhat.repo.backup
      #4替换文件中所有 $releasever 为7.9.2009
      vi CentOS7-Base-163.repo
      #5查找并替换 直接复制这个命令
      :%s/$releasever/7.9.2009/g
      #6保存退出
      :wq
    7. yum clean all
    8. yum makecache
    9. yum repolist all
      1. 如果配置没有问题会显示下面内容,数量可能不一致。
        [root@localhost yum.repos.d]# yum repolist all
        Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

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

        Loading mirror speeds from cached hostfile
        repo id                                               repo name                                                                status
        base/x86_64                                           CentOS-7.9.2009 - Base - 163.com                                         enabled: 10,072
        centosplus/x86_64                                     CentOS-7.9.2009 - Plus - 163.com                                         disabled
        extras/x86_64                                         CentOS-7.9.2009 - Extras - 163.com                                       enabled:    509
        updates/x86_64                                        CentOS-7.9.2009 - Updates - 163.com                                      enabled:  3,572
        repolist: 14,153

         

posted @ 2022-03-16 23:11  一只大猫呢  阅读(5217)  评论(0编辑  收藏  举报