Description of problem: after install RHEL3 and update all of the patches, rpm -qa not working as root and user. Steps to Reproduce: 1.#rpm -qa rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8 error: cannot open Packages index using db3 - Invalid argument (22) error: cannot open Packages database in /var/lib/rpm no packages 2. #cd /var/lib/rpm #rm -f /var/lib/rpm/__db* #rpm -vv --rebuilddb D: rebuilding database /var/lib/rpm into /var/lib/rpmrebuilddb.15334 D: creating directory /var/lib/rpmrebuilddb.15334 D: opening old database with dbapi 3 D: opening db environment /var/lib/rpm/Packages create:cdb:mpool D: opening db index /var/lib/rpm/Packages rdonly mode=0x0 rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8 D: closed db index /var/lib/rpm/Packages D: closed db environment /var/lib/rpm/Packages error: cannot open Packages index D: removing directory /var/lib/rpmrebuilddb.15334 3.#cd /var/lib/rpm # rm -f __db.00* # /usr/lib/rpm/rpmdb_verify Packages no error message at this time then I did #rpm -qa I got: rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8 error: cannot open Packages index using db3 - Invalid argument (22) error: cannot open Packages database in /var/lib/rpm no packages 4. then try to convert the db into right format cd /var/lib/rpm mv Packages Packages-ORIG ***db_dump-4.1.25 Packages-ORIG | db_load-4.0.14 Packages the real command on my machine as for the correct version is #/usr/lib/rpm/rpmdb_dump Packages-ORIG | /usr/bin/db_load Packages no error message at this step. then # rpm -vv --rebuilddb D: rebuilding database /var/lib/rpm into /var/lib/rpmrebuilddb.2851 D: creating directory /var/lib/rpmrebuilddb.2851 D: opening old database with dbapi 3 D: opening db environment /var/lib/rpm/Packages create:cdb:mpool D: opening db index /var/lib/rpm/Packages rdonly mode=0x0 rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8 D: closed db index /var/lib/rpm/Packages D: closed db environment /var/lib/rpm/Packages error: cannot open Packages index D: removing directory /var/lib/rpmrebuilddb.2851 Additional info: I have also tried the opposite way to convert it, same result. Any idea how to fix it? Thanks!!
What version of rpm? Your steps are basically sound, db-4.1.25 is backward compatible with db-4.0.14, but db-4.0.14 is not forward compatible with db-4.1.25. You might look at /usr/lib/rpm/rpmdb_loadcvt, that's a script that does essentially what you have done manually. There are also copies (or should be) of all db4 utilities that are linked against the same version of Berkeley DB that rpm is. For example, there's rpmdb_dump, rpmdb_load, etc. Running file(1) against the database files in /var/lib/rpm will display version information. Packages is the most important. If you get that converted to a version that rpm can read, the other indices will be recreated with --rebuilddb -vv. change from NEEDINFO -> ASSIGNED if you need help sorting out.
Jeff, Thanks for he quick response. I tried /usr/lib/rpm/rpmdb_loadcvt, as you recommended, no error at this step, it showed "converting to db-4.1.25 compatible format" .... "Done" then I did "rpm --rebuilddb" it still gave me the same error message as I mentioned as above. what could it be the trouble? Helen
What version of rpm please?
rpm version is 4.1 by running rpm --version
by running rpmdb --version, it shows rpm version 4.2.1 ??
Hmmm, 4.1 != 4.2.1, something is odd. Digging ... Could you try rpmdb --rebuilddb -vv please? That should have db-4.1.25 inside which is backwards compat.
Ha!! very smart! it works this time. appreciate it very much. just confusing in different version of RH... have a wonderful night. Helen
Oops, rpmdb --rebuilddb -vv worked fine, but when I use rpm -qa, it gave error message again like "cannot open Package index using db3, cannot open packages database in /var/lib/rpm"
Jeff, I noticed that in RHEL the command for query is /usr/bin/rpmquery ( pointing to /usr/lib/rpm/rpmq) with options similar to rpm -qa, this command is working fine, so I am wondering that in RHEL3 something about rpm changed so the general rpm command under /bin is no longer being used for the same purpose? Helen
Hmmm, /bin/rpm is from wrong version. For all modes but install/upgrade/erase, /bin/rpm is just a front-end, invoking (after a little digging) helpers located in /usr/lib/rpm that look like, say, rpmv for verify mode, rpmk for signature checking, etc, etc. /bin/rpm seems damaged somehow, I don't think from RHEL3. Try /usr/lib/rpm/rpmv -V rpm to see what is broken or missing. I suspect that /bin/rpm will show up as modified. Is that the case?
Jeff, I agree with you, but when I check /bin/rpm and all the rpm commands under /usr/lib/rpm/, they are all showing the same modification time as Jan 8 at 21:47 group# ls -al /bin/rpm -rwxr-xr-x 1 rpm rpm 79388 Jan 8 21:47 /bin/rpm* group# group# ls -al /usr/lib/rpm/rpm* -rwxr-xr-x 1 rpm rpm 713 Jan 8 21:47 /usr/lib/rpm/rpm2cpio.sh* -rwxr-xr-x 1 rpm rpm 19656 Jan 8 21:47 /usr/lib/rpm/rpmb* -rwxr-xr-x 1 rpm rpm 12264 Jan 8 21:47 /usr/lib/rpm/rpmcache* -rwxr-xr-x 1 rpm rpm 10432 Jan 8 21:47 /usr/lib/rpm/rpmd* -rwxr-xr-x 1 rpm rpm 104 Jan 8 21:47 /usr/lib/rpm/rpm.daily* -rwxr-xr-x 1 rpm rpm 7052 Jan 8 21:47 /usr/lib/rpm/rpmdb_deadlock* -rwxr-xr-x 1 rpm rpm 11100 Jan 8 21:47 /usr/lib/rpm/rpmdb_dump* -rwxr-xr-x 1 rpm rpm 18040 Jan 8 21:47 /usr/lib/rpm/rpmdb_load* -rwxr-xr-x 1 rpm rpm 1467 Jan 8 21:47 /usr/lib/rpm/rpmdb_loadcvt* -rwxr-xr-x 1 rpm rpm 24852 Jan 8 21:47 /usr/lib/rpm/rpmdb_stat* -rwxr-xr-x 1 rpm rpm 39788 Jan 8 21:47 /usr/lib/rpm/rpmdb_svc* -rwxr-xr-x 1 rpm rpm 7320 Jan 8 21:47 /usr/lib/rpm/rpmdb_verify* -rwxr-xr-x 1 rpm rpm 5912 Jan 8 21:47 /usr/lib/rpm/rpmdeps* lrwxr-xr-x 1 rpm rpm 4 Jan 30 19:39 /usr/lib/rpm/rpme -> rpmi* -rwxr-xr-x 1 rpm rpm 8848 Jan 8 21:47 /usr/lib/rpm/rpmfile* -rwxr-xr-x 1 rpm rpm 1951224 Jan 8 21:47 /usr/lib/rpm/rpmi* -rwxr-xr-x 1 rpm rpm 11792 Jan 8 21:47 /usr/lib/rpm/rpmk* -rwxr-xr-x 1 rpm rpm 61 Jan 8 21:47 /usr/lib/rpm/rpm.log* -rw-r--r-- 1 rpm rpm 20872 Jan 8 21:47 /usr/lib/rpm/rpmpopt-4.2.1 -rwxr-xr-x 1 rpm rpm 11136 Jan 8 21:47 /usr/lib/rpm/rpmq* -rw-r--r-- 1 rpm rpm 10596 Jan 8 21:47 /usr/lib/rpm/rpmrc lrwxr-xr-x 1 rpm rpm 4 Jan 30 19:49 /usr/lib/rpm/rpmt -> rpmb* lrwxr-xr-x 1 rpm rpm 4 Jan 30 19:39 /usr/lib/rpm/rpmu -> rpmi* lrwxr-xr-x 1 rpm rpm 4 Jan 30 19:39 /usr/lib/rpm/rpmv -> rpmq* -rwxr-xr-x 1 rpm rpm 319 Jan 8 21:47 /usr/lib/rpm/rpm.xinetd* running the command rpmv -V rpm did not show anything. group# /usr/lib/rpm/rpmv -V rpm group# shall I reinstall rpm package at this point or simply get a good version of rpm executable and copy it under /bin? Hele
reinstall with --force should fix. if /bin/rpm fails to install, then try /usr/lib/rpm/rpmi with same args. if /usr/lib/rpm/rpmi fails to install, then you will need to install manually using rpm2cpio. There's rpm2cpio man page, but the commands will be something like mkdir -p /var/tmp/xxx rpm2cpio /path/to/rpm-4*.rpm | cpio -dim find . -type d -exec chmod 755 {} \; tar cf - . | (cd /; tar xvf -)
Jeff, the problem is fixed finally by your instructions. thank you very much for all of the help. with all of these solutions, I hope I won;t have any rpm problem anymore :)) have a good day. Helen