Red Hat Enterprise Linux(RHEL)是收費的,如果不買訂閱將無法使用yum軟件倉庫,安裝軟件的時候多有不便。
解決辦法:
- 第一個辦法,最簡單,使用CentOS。
- 現在分CentOS Linux版和CentOS Stream版,簡單理解就是以前的CentOS Linux版發布根據RHEL更新的內容進行更新並修復其中可能的漏洞,比RHEL要晚,缺點是補丁更新慢,可能安全性差一點,好處是穩定性強一點。而現在的CentOS Stream版似乎成了RHEL的試驗場,新東西新想法都是先在CentOS Stream版上發布然后再到RHEL。
- 第二個辦法,注冊紅帽的開發者訂閱。
- 這個訂閱只有一年的有效期,每次到期后需要從新在系統中注冊一次才能使用。參考以下這篇文章 https://developers.redhat.com/articles/renew-your-red-hat-developer-program-subscription?source=sso#
- https://developers.redhat.com/ 注冊帳號 網頁最下面Join Red Hat Developer
- https://access.redhat.com/ 查看訂閱
subscription-manager register --username=yourusername --password=yourpassword --auto-attach 根據你的注冊帳號和密碼來注冊,注意username是你的注冊用戶名,不是注冊郵箱。
subscription-manager list --available --all 查看所有的可用訂閱以及到期時間。
- 使用紅帽的訂閱后,有一個小問題就是yum下載東西網速很慢,不穩定。但是最近也還好。
- 注冊激活后有時候使用yum會出現This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions. emm....>別理他。
- 更新訂閱subscription-manager attach --auto
- 第三個辦法,用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的源。
- 查看系統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 - 強制刪除系統yum
#強制刪除
rpm -qa|grep yum|xargs rpm -e --nodeps #再次查看,已經什么都沒有了 rpm -qa|grep yum - 在臨時目錄創建一個文件夾
#創建一個文件夾
mkdir /tmp/yumtmp#進入這個文件夾
cd /tmp/yumtmp#或者直接
mkdir /tmp/yumtmp && cd /tmp/yumtmp - 下載所需文件,使用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 - 安裝這幾個包,不太喜歡強制安裝,所以是一個個安裝的。
#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
- 下載並修改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 - yum clean all
- yum makecache
- yum repolist all
- 如果配置沒有問題會顯示下面內容,數量可能不一致。
[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
- 如果配置沒有問題會顯示下面內容,數量可能不一致。
- 查看系統yum