關於linux下安裝yum(安裝失敗遇到的坑)


This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
沒有已啟用的源。
執行 “yum repolist all” 查看您擁有的源。
您可以用 yum-config-manager --enable <源名> 來啟用源
1.檢查是否安裝yum包。查看RHEL是否安裝了yum,若是安裝了,那么又有哪些yum包:

#rpm -qa |grep yum
2 刪除redhat自帶的yum包

#rpm -qa|grep yum|xargs rpm -e --nodeps(不檢查依賴,直接刪除rpm包)
#rpm -qa |grep yum (查詢確認)
3、 去http://mirrors.163.com/centos/7/os/x86_64/Packages/下載如下文件
下載:

yum-3.4.3-163.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
python-inotify-0.9.4-4.el7.noarch.rpm
4、創建yumFile文件夾

mkdir yumFile
5、將下載的4個文件上傳至yumFile文件夾下

rpm -ivh python-inotify-0.9.4-4.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm
6、安裝是出現以下錯誤:

root@jxw-xmsb-web1 yumFile]# rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
警告:yum-3.4.3-163.el7.centos.noarch.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
錯誤:依賴檢測失敗:
python-urlgrabber >= 3.10-8 被 yum-3.4.3-163.el7.centos.noarch 需要
rpm >= 0:4.11.3-22 被 yum-3.4.3-163.el7.centos.noarch 需要
7、則運行:

rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm --force --nodeps yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
8、修改來源文件

(1)進入到系統yum源的目錄下:

#cd /etc/yum.repos.d
(2)下載yum源:
進入:http://mirrors.163.com/.help/centos.html里面有下載對應版本repo文件, 放入/etc/yum.repos.d/(操作前請做好相應備份)

(3)修改CentOS6-Base-163.repo文件
#CentOS-Base.repo

#The mirror system uses the connecting IP address of the client and the
#update status of each mirror to pick mirrors that are updated to and
#geographically close to the client. You should use this for CentOS updates
#unless you are manually picking other mirrors.

#If the mirrorlist= does not work for you, as a fall back you can try the
#remarked out baseurl= line instead.

[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=KaTeX parse error: Expected 'EOF', got '&' at position 11: releasever&̲arch=basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=KaTeX parse error: Expected 'EOF', got '&' at position 11: releasever&̲arch=basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=KaTeX parse error: Expected 'EOF', got '&' at position 11: releasever&̲arch=basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
9、這其中會有一個巨坑,如果是從網站上下載下來的CentOS7-Base-163.repo,一定要記得將文件中的信息替換上面我的。還有一種錯誤困擾了我幾個小時,就是在/etc/yum.repos.d路徑下,除了有CentOS7-Base-163.repo文件和CentOS-Base.repo文件其余文件一律刪除,就OK了。
10、運行makecache 生成緩存

yum makecache
11、運行yum clean all(等同於 yum cleanheaders ; yum cleanpackages);

yum clean all
12、更新YUM文件

yum update
13、是否安裝成功
yum install dhcp -y
提示安裝,就說明可以了。
以上文章參考了https://www.cnblogs.com/chenyuanbo/p/11637016.html的文章,並在其中加入了自己遇到坑,與如何解決的。
————————————————
版權聲明:本文為CSDN博主「莀逸」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_42390329/article/details/107733749


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM