yum源使用的几个报错小总结 (例如: python2.6.6 下yum不能使用: No module named yum)

 

服务器上的yum忽然很差使用,使用yum时有以下几个保持,解决方案以下:html

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 againnode

解决办法:(或者把/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源,操做以下:python

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

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.repobash

而后执行如下命令:
[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
-------------------------------------------------------------------------------------------------------------curl

[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便可, 参考http://www.javashuo.com/article/p-tcafpcah-hb.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"
解决办法: http://www.javashuo.com/article/p-eobwkxju-be.html

相关文章
相关标签/搜索