今天对服务器进行 yum update
软件升级出现了错误:
# yum update
...
--> Finished Dependency Resolution
Error: Package: curl-7.29.0-35.el7.centos.x86_64 (@CentOS)
Requires: libcurl = 7.29.0-35.el7.centos
Removing: libcurl-7.29.0-35.el7.centos.x86_64 (@CentOS)
libcurl = 7.29.0-35.el7.centos
Updated By: libcurl-7.29.0-42.el7.x86_64 (base)
libcurl = 7.29.0-42.el7
You could try using --skip-broken to work around the problem
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
curl-7.50.3-1.el7.centos.x86_64 is a duplicate with curl-7.29.0-35.el7.centos.x86_64
libiconv-1.14-1.el7.centos.x86_64 has missing requires of libcharset.so.1()(64bit)
libiconv-1.14-1.el7.centos.x86_64 has missing requires of libiconv.so.2()(64bit)
其实这个问题出现蛮奇怪的,因为此前升级安装都是顺利完成,没有出现中断的情况,而且是每一台服务器都出现了这个问题,查了下资料,可以这么解决:
① 安装 yum-utils
yum install yum-utils -y
② 执行 package-cleanup 清理
# package-cleanup --cleandupes
Loaded plugins: fastestmirror
--> Running transaction check
---> Package curl.x86_64 0:7.29.0-35.el7.centos will be erased
--> Finished Dependency Resolution
.....
很显然这个错误是存在的,清理后我们继续 update,这一次顺利升级完成了。
细心的你可能已经发现,不是还有个 libiconv 库缺失的错误吗?是的,但是我们在执行清理后错误就没有了,不需要再做处理。
如果要单独处理 has missing requires of libcharset.so.1()(64bit) 错误,可以这样:
# rpm -Uvh https://forensics.cert.org/cert-forensics-tools-release-el7.rpm && yum --enablerepo=forensics install libiconv
好了,我们来检查一下:
# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
......
Error unpacking rpm package python-urllib3-1.10.2-3.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
python-urllib3-1.10.2-2.el7_1.noarch was supposed to be removed but is not!
......
吐血,看下什么错误:
# package-cleanup --problems
Loaded plugins: fastestmirror
No Problems Found
好吧,这不叫 problems,查了下,发现之前通过 pip
安装过 urllib3,那我们先卸载它:
# pip uninstall urllib3
再次升级:
# yum update
...
Package python-urllib3.noarch 0:1.10.2-2.el7_1 will be updated
...
Complete!
这次顺利升级成功!
拓展:使用 yum-utils
来维护 yum 并提高其性能
① 查看软件是从哪个源安装的
# find-repos-of-install vnstat
Loaded plugins: fastestmirror
vnstat-1.15-2.el7.x86_64 from repo epel
② 删除重复或无用的内核(包括其他源安装):
# package-cleanup --cleandupes
# package-cleanup --oldkernels
③ 查看源中所有软件的依赖:
# repo-graph --repoid=updates | less
参考文章:
1、《如何安装和使用’yum-utils’来维护Yum并提高其性能》