yum 报错处理

有时候,我们可能进行一些非正常操作,导致服务器上的 yum 命令无法正常使用,现在,总结一下常见 yum 报错

1、如下图的报错

图片.png

出现该错误,看似莫名其妙,但是别急,解决办法还是有的。

解决方案:

该错误是rpm数据库损坏引起的,既然是rpm数据库损坏,那我们重建rpm数据库不就OK了。

[root@yum-depot ~]# cd /var/lib/rpm
[root@yum-depot rpm]# ll
总用量 88996
-rw-r--r--. 1 root root  2215936 12月 19 09:59 Basenames
-rw-r--r--. 1 root root    8192 12月 19 09:59 Conflictname
-rw-r--r--  1 root root   286720 12月 19 10:56 __db.001
-rw-r--r--  1 root root   90112 12月 19 10:56 __db.002
-rw-r--r--  1 root root  1318912 12月 19 10:56 __db.003
-rw-r--r--. 1 root root   610304 12月 19 09:59 Dirnames
-rw-r--r--. 1 root root   16384 12月 19 09:59 Group
-rw-r--r--. 1 root root   16384 12月 19 09:59 Installtid
-rw-r--r--. 1 root root   32768 12月 19 09:59 Name
-rw-r--r--. 1 root root   16384 12月 18 19:17 Obsoletename
-rw-r--r--. 1 root root  84570112 12月 19 09:59 Packages
-rw-r--r--. 1 root root  1814528 12月 19 09:59 Providename
-rw-r--r--. 1 root root   163840 12月 19 09:59 Requirename
-rw-r--r--. 1 root root   49152 12月 19 09:59 Sha1header
-rw-r--r--. 1 root root   36864 12月 19 09:59 Sigmd5
-rw-r--r--. 1 root root    8192 12月 18 19:17 Triggername
[root@yum-depot rpm]# rm -rf __db.00*
[root@yum-depot rpm]# rpm --rebuilddb
[root@yum-depot rpm]# yum clean all
[root@yum-depot rpm]# yum makecache

2、如下图类似的报错

图片.png

出现该报错的原因是我们对系统自带的 python 进行升级导致的,我们知道,yum 工具是由python语言写成的,所以,我们在进行系统升级的时候,如果升级了python,就会出现这个问题,那么如何解决呢?

解决方案:

卸载我们升级后的 python 和 yum

扫描二维码关注公众号,回复: 4563407 查看本文章

从Centos源镜像包中拷贝 python 和 rpm 包,然后在强制安装,安装完后可解决。

3、yum安装一些软件包时报错“Error: xz compression not available”

解决办法:

[root@yum-depot ~]# rm -fr /var/cache/yum/x86_64/6/epel/
[root@yum-depot ~]# rm -rf /etc/yum.repos.d/epel*
重新安装epel源和base源
[root@yum-depot ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@yum-depot ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@yum-depot ~]# yum repolist



猜你喜欢

转载自blog.51cto.com/4746316/2332708