topleft topright

Tranquil Hosting Blog

Archive for September, 2007

Yum error: unable to open database file

Wednesday, September 5th, 2007

We have seen a problem with several Cpanel Linux VPS systems recently. It pops up in several places and is related to yum, the update tool that comes with CentOS and is relied upon by Cpanel.

For example, running a basic command like “yum list” results in a Python trackback error with some ugly error message like:

File “/usr/lib/python2.4/site-packages/yum/repos.py”, line 200, in populateSack
sack.populate(repo, with, callback, cacheonly)
File “/usr/lib/python2.4/site-packages/yum/yumRepo.py”, line 91, in populate
dobj = repo.cacheHandler.getPrimary(xml, csum)
File “/usr/lib/python2.4/site-packages/yum/sqlitecache.py”, line 100, in getPrimary
return self._getbase(location, checksum, ‘primary’)
File “/usr/lib/python2.4/site-packages/yum/sqlitecache.py”, line 93, in _getbase
self.updateSqliteCache(db, parser, checksum, metadatatype)
File “/usr/lib/python2.4/site-packages/yum/sqlitecache.py”, line 382, in updateSqliteCache
cur.execute(”DELETE FROM “+table+ ” where pkgKey in %s” % delpkgs)
File “/usr/lib64/python2.4/site-packages/sqlite/main.py”, line 244, in execute
self.rs = self.con.db.execute(SQL)
_sqlite.DatabaseError: unable to open database file

Some people say its a SQLite issue, the lightweight sql-like database used by yum for the local rpm database. The error message “unable to open database file” made me think this problem was related to the rpm database files in /var/lib/rpm. I tried rebuilding the rpm database but no luck.

It turns out the problem is much simpler:

[root@host1 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 83886080 3671424 80214656 5% /
df: `(deleted) /var/tmp’: No such file or directory

Notice anything wrong? Yikes! we don’t have a working /tmp or /var/tmp directory. Apparently the problem was inadvertendly caused by some Cpanel scripts which try to help us by securing those directories, making them noexec so that attackers can’t run rogue scripts directly from the tmp directories.

The fix

Wipe out the tmp dir stuff that cpanel had setup:

/bin/umount -l /tmp
/bin/umount -l /var/tmp
/bin/rm -fv /usr/tmpDSK

Now reset it:

/scripts/securetmp –auto

Copyright © 2007, Tranquil Hosting, Inc.
Managed Dedicated Servers | Managed Virtual Private Servers | Raleigh Datacenter Colocation
Raleigh, North Carolina Premium Hosting Provider
Terms of Service