今天一台机器在yum安装东西时突然中断,然后再次安装时提示以下错误:
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 375, in user_main
errcode = main(args)
File “/usr/share/yum-cli/yummain.py”, line 281, in main
return_code = base.doTransaction()
File “/usr/share/yum-cli/cli.py”, line 817, in doTransaction
resultobject = self.runTransaction(cb=cb)
File “/usr/lib/python2.7/site-packages/yum/__init__.py”, line 1834, in runTransaction
lastdbv = self.history.last()
File “/usr/lib/python2.7/site-packages/yum/history.py”, line 1271, in last
ret = self.old([], 1, complete_transactions_only)
File “/usr/lib/python2.7/site-packages/yum/history.py”, line 1220, in old
executeSQL(cur, sql, params)
File “/usr/lib/python2.7/site-packages/yum/sqlutils.py”, line 166, in executeSQLQmark
return cursor.execute(query)
sqlite3.OperationalError: database is locked
解决方法:
1、依次执行
cd /var/lib/rpm/
rm -i __db.*
yum clean all
yum history new
2、再次尝试yum,提示
错误:db5 错误(-30973) 来自 dbenv->open:BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
错误:无法使用 db5 – (-30973) 打开 Packages 索引
错误:无法从 /var/lib/rpm 打开软件包数据库
CRITICAL:yum.main:Error: rpmdb open failed
3、重建db
rpm –rebuilddb
最后问题解决。