为了修复 RPM 数据库,我运行了rpm --rebuild
.之后,我找不到任何使用的包rpm -qa
,并且yum
不起作用,如下日志所示。
[root@local03 ~]# yum
Traceback (most recent call last): File "/usr/bin/yum", line 29, in yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 294, in user_main errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 115, in main base.getOptionsConfig(args)
File "/usr/share/yum-cli/cli.py", line 228, in getOptionsConfig self.conf
File "/usr/lib/python2.6/site-packages/yum/init.py", line 910, in conf = property(fget=lambda self: self._getConfig(),
File "/usr/lib/python2.6/site-packages/yum/init.py", line 299, in _getConfig startupconf = config.readStartupConfig(fn, root)
File "/usr/lib/python2.6/site-packages/yum/config.py", line 892, in readStartupConfig startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.6/site-packages/yum/config.py", line 1043, in _getsysver hdr = idx.next() StopIteration
[root@local03 ~]# rpm -aq | grep bash
[root@local03 ~]#
答案1
尝试一下,我用它在 centos 中重建 rpm 数据库,也应该适用于 rhel:
rm -f /var/lib/rpm/__*
rpm --rebuilddb