Yum broken in Amazon instance
This is an instance launched using Amazon AMI.
when I run yum with anything (search,install, etc), this is what I am getting:
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
Tried google but found nothing that could help. Tried getting the rpm package for all yum from another similar machine and force installing those packages. that also didn't help. I also tried removing the rpm db files and rebuilding the rpm database which didn't help either.
~# 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
Has anyone faced this before? Is there anything I can do to fix this problem? Thanks in advance.
Solution 1:
Seems like the RPM database is trashed or corrupt. Try the following to rebuild the database from the packages already installed on your server: rpm --rebuilddb
Also check if the database files are present in /var/lib/rpm.