yum源使用的幾個報錯小總結 (No module named yum)


 

服務器上的yum突然不好使用,使用yum時有如下幾個保持,解決方案如下:

1)Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge.
[root@bastion-IDC src]# yum list
......
Could not retrieve mirrorlist http://mirrorlist.repoforge.org/el6/mirrors-rpmforge error was
14: PYCURL ERROR 7 - "couldn't connect to host"
http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml: [Errno 14]
PYCURL ERROR 7 - "couldn't connect to host"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge.
Please verify its path and try again

解決辦法:(或者把/etc/yum.repos.d下的文件全部刪除,然后將能正常使用yum的同類服務器的這個目錄下的文件全部拷貝過來,然后yum clean all 和yum makecache 即可)
下載新的CentOS-Base.repo 到/etc/yum.repos.d/
[root@bastion-IDC src]# cd /etc/yum.repos.d/
其實就是將yum源更改為阿里雲的yum源,操作如下:

1)centos5.*的下載連接:
[root@bastion-IDC yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

2)centos6.*的下載連接:
[root@bastion-IDC yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

3)centos7.*的下載連接:
[root@bastion-IDC yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

然后執行以下命令:
[root@bastion-IDC yum.repos.d]# rpm -e rpmforge-release --nodeps
-------------------------------------------------------------------------------------------------------------
如果報錯:
error: package rpmforge-release is not installed

解決辦法:安裝這個源
下載地址:https://pan.baidu.com/s/1pKBtm11
提取密碼:erte
[root@bastion-IDC yum.repos.d]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
-------------------------------------------------------------------------------------------------------------

[root@bastion-IDC yum.repos.d]# yum clean all
[root@bastion-IDC yum.repos.d]# yum makecache                                   //將服務器上的軟件包信息緩存到本地,以提高搜索安裝軟件的速度
[root@bastion-IDC yum.repos.d]# yum update

最后再次使用yum就ok了
[root@bastion-IDC yum.repos.d]# yum list

2)UnicodeDecodeError: 'ascii' codec can't decode ... ordinal not in range

在使用yum部署環境的時候,出現了報錯:
UnicodeDecodeError: 'ascii' codec can't decode ... ordinal not in range
解決辦法:
[root@kvmserver ~]# ll /var/lib/rpm/*db*
-rw-r--r-- 1 root root 73728 Aug 15 14:52 /var/lib/rpm/__db.001
-rw-r--r-- 1 root root 270336 Aug 15 14:52 /var/lib/rpm/__db.002
-rw-r--r-- 1 root root 1318912 Aug 15 14:52 /var/lib/rpm/__db.003
-rw-r--r-- 1 root root 778240 Aug 15 14:52 /var/lib/rpm/__db.004
 
[root@kvmserver ~]# rm -f __db.*
[root@kvmserver ~]# yum clean all

3)Error: xz compression not available

測試服務器(centos6.5)經過一段時間的折騰,有一天在上面進行yum操作時突然出現下面的報錯:
Error: xz compression not available
最后經過一番排查,發現原因是之前安裝軟件時錯誤安裝了centos7版本的軟件,軟件版本不兼容,這才導致了yum不可用。
解決措施:
首先查看/root/install.log安裝日志,找出版本不兼容軟件,然后將其卸載就ok了。
另外:如果因為安裝epel導致此類問題,可以進行如下刪除操作:
# rm -rf /etc/yum.repos.d/epel*

4) Centos6.9 系統中python2.6下yum不能使用問題處理 (No module named yum)

測試環境下有一台Centos6.9系統的服務器, 在使用yum的時候報錯"No module named yum", 一般這個問題是由於升級python后, 新版本的python和默認的yum不匹配導致的, 只需要需改/usr/bin/yum文件的頭部信息中的python即可, 參考https://www.cnblogs.com/kevingrace/p/5709494.html  , 可是本服務執行"python -V"查看, python版本還是系統默認的2.6.6, 並沒有升級python, 可是yum使用時一直報錯:No module named yum!   則需要重新安裝python和yum才能解決這個問題: ( 如果卸載了centos6.9系統自帶的python2.6,也會導致yum使用不了, 也需要重新安裝python和yum)

1) 卸載python
[root@lvs-master ~]# rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
[root@lvs-master ~]# whereis python|xargs rm -fr

2) 卸載yum
[root@lvs-master ~]# rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
[root@lvs-master ~]# rm -rf /etc/yum.repos.d/*                                                 # 這一步可以不操作, 可以保留
[root@lvs-master ~]# whereis yum|xargs rm -fr

3) 安裝python
在任何一個鏡像站中找到你系統對應版本的python rpm包(我的是centos 6.9的64位系統,使用的鏡像是http://mirrors.163.com/centos/6/os/x86_64/Packages/
或者 http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages 下面)

[root@lvs-master ~]# mkdir /usr/local/src/python
[root@lvs-master ~]# cd /usr/local/src/python
[root@lvs-master python]# wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
 
[root@lvs-master python]# wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@lvs-master python]# wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
[root@lvs-master python]# wget  http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
[root@lvs-master python]# wget  http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
[root@lvs-master python]# wget  http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
[root@lvs-master python]# wget  http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/rpm-python-4.8.0-59.el6.x86_64.rpm

然后批量安裝這些python的rpm包 
[root@lvs-master python]# rpm -ivh python-*   rpm-python-*  --force

4) 安裝yum
[root@lvs-master python]# mkdir /usr/local/src/yum
[root@lvs-master python]# cd /usr/local/src/yum
[root@lvs-master yum]# wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
[root@lvs-master yum]# wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
[root@lvs-master yum]# wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

[root@lvs-master yum]# rpm -ivh yum-* --force

5) 測試
[root@lvs-master yum]# yum list

centos 6.9下python2.6.6 和yum的rpm安裝包 直接放在了百度網盤里, 地址為:  https://pan.baidu.com/s/1RacVshrAkHyfas651Wr6Yw
提取密碼: ttsy

5) yum使用出現問題: https://mirrors.aliyun.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
解決辦法: https://www.cnblogs.com/kevingrace/p/6252795.html


免責聲明!

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



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