前言
RHEL的YUM源需要注冊用戶才能更新使用,由於CentOS和RHEL基本沒有區別,並且CentOS已經被REHL收購。所以將RHEL的YUM源替換為CentOS即可。
[root@NISEC-6601 yum]# yum clean all
bash: yum: 未找到命令...
無法使用YUM源的問題如下:
[root@localhost ~]# yum repolist
已加載插件:product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repolist: 0
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# yum install ntp
已加載插件:product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
解決方法:
# 清除原有RHEL的YUM及相關軟件包
rpm -qa|grep yum|xargs rpm -e --nodeps
rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps
# 軟件包下載地址
# https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
# http://mirrors.163.com/centos/7/os/x86_64/Packages/
下載centos7的相關軟件包
http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
上傳軟件包到rhel7.3系統里
安裝軟件包
注:yum-plugin-fastestmirror和yum兩個rpm要一起安裝,不能拆開。
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm yum-3.4.3-168.el7.centos.noarch.rpm #會出現問題1
錯誤:依賴檢測失敗:
rpm >= 0:4.11.3-22 被 yum-3.4.3-158.el7.centos.noarch 需要
問題1
錯誤:依賴檢測失敗:
rpm >= 0:4.11.3-22 被 yum-3.4.3-158.el7.centos.noarch 需要
yum >= 3.0 被 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch 需要
解決:,升級rpm,上一步已經下載了,直接升級
rpm -Uvh rpm-4.11.3-45.el7.x86_64.rpm --nodeps
下載配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
把文件中所有$releasever改為7,$basearch保持不變
然后將此配置文件上傳並復制到/etc/yum.repos.d/路徑下,刪除redhat.repo文件
1、$releasever
$releasever的值,當前系統的發行版本。是指大版本7
2、$basearch
$basearch的值,系統硬件架構(CPU指令集)
查看命令:arch,結果是x86_64
刪除/var/cache/yum/下的x86_64目錄
清理yum緩存: yum clean all
將服務器軟件包信息緩存至本地,提高搜索安裝效率:yum makecache
測試:
能搜索到軟件包信息,說明配置完成:
yum search vim
執行yum repolist查看,如果顯示出repo倉庫列表,並顯示軟件包數量則OK。(或者使用yum makecache):
yum repolist
使用yum安裝軟件包測試:
yum -y install vim