CentOS 3.4 to 3.5 - RPM database issue

For those of you running CentOS 3, your server probably upgraded from CentOS 3.4 to 3.5 automatically a while ago.

Unfortunately this there was an issue with this upgrade that requires a manual fix, so that future updates can be applied.

Here’s how you can tell if your server has the problem.

[root@yourserver]# yum update
rpmdb: Program version 4.2 doesn’t match environment version
error: db4 error(22) from dbenv->open: Invalid argument
error: cannot open Packages index using db3 - Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm
Traceback (most recent call last):
File “/usr/bin/yum”, line 30, in ?
yummain.main(sys.argv[1:])
File “/usr/share/yum/yummain.py”, line 163, in main
(log, errorlog, filelog, conf, cmds) = parseCmdArgs(args)
File “/usr/share/yum/yummain.py”, line 75, in parseCmdArgs
conf=yumconf(configfile=yumconffile)
File “/usr/share/yum/config.py”, line 155, in init
self.yumvar[‘releasever’] = self._getsysver()
File “/usr/share/yum/config.py”, line 285, in _getsysver
idx = ts.dbMatch(‘provides’, self.distroverpkg)
TypeError: rpmdb open failed

Here is the fix:

[root@yourserver]# rm -f /var/lib/rpm/__db*
[root@yourserver]# rpm --rebuilddb
[root@yourserver]# yum -y erase zsh
[root@yourserver]# yum -y install zsh
[root@yourserver]# yum update

Paul