这是使用 Amazon AMI 启动的实例。
当我运行 yum 进行任何操作(搜索、安装等)时,我得到的结果如下:
yum search yum
error: bad option 'archcolor' at (null):93
Loaded plugins: fastestmirror, priorities, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.us-east-1.amazonaws.com
error: dbiOpen: dbapi 1 not available
error: cannot open Packages database in /var/lib/rpm
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in <module>
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 355, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 174, in main
result, resultmsgs = base.doCommands()
File "/usr/share/yum-cli/cli.py", line 569, in doCommands
return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
File "/usr/share/yum-cli/yumcommands.py", line 1682, in doCommand
return base.search(extcmds)
File "/usr/share/yum-cli/cli.py", line 1436, in search
for (po, keys, matched_value) in matching:
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 3139, in searchGenerator
lowered=True)
File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 1274, in searchPrimaryFieldsMultipleStrings
for hdr, idx in self._get_packages():
File "/usr/lib/python2.6/site-packages/yum/rpmsack.py", line 1301, in _get_packages
mi = ts.dbMatch(*args, **kwds)
File "/usr/lib/python2.6/site-packages/rpmUtils/transaction.py", line 58, in dbMatch
mi = self.ts.dbMatch(*args, **kwds)
_rpm.error: rpmdb open failed
尝试过谷歌,但没有找到任何有用的方法。尝试从另一台类似的机器获取所有 yum 的 rpm 包并强制安装这些包。这也没有帮助。我还尝试删除 rpm db 文件并重建 rpm 数据库,但也没有帮助。
~# cat /etc/issue
Amazon Linux AMI release 2011.09
Kernel \r on an \m
~# uname -a
Linux ip-10-0-2-98 2.6.35.14-97.44.amzn1.x86_64 #1 SMP Mon Oct 24 16:03:08 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
有人遇到过这种情况吗?我能做些什么来解决这个问题?提前谢谢。
答案1
似乎 RPM 数据库已损坏或损坏。请尝试以下操作从服务器上已安装的软件包重建数据库:rpm --rebuilddb
还要检查数据库文件是否存在于 /var/lib/rpm 中。