0

I am in a strange situation. I have a web server machine with CentOS release 6.6 (Final) installed with nginx, mysql, ISPConfig and Webmin which is working smoothly. Recently I noticed when using phpMyAdmin that a message was popping up saying that there is a newer version of phpMyAdmin. Webmin did not report any updates available, so I run "yum update" receiving many errors like:

YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. $releasever is not a valid release or hasnt been released yet/

After trying some configuration and did a "yum clean all", restarting the server, I am able to run yum again, but now yum database seems like it has been erased or something. When I run "yum list installed" I get absolutely nothing! When I run "yum update" I get "No Packages marked for Update". All repos are enabled. All the packages are installed, but now yum db has nothing inside. For example when I run "yum install phpMyAdmin" I get:

Installing:
 phpMyAdmin                    noarch   4.3.7-1.el6.remi      remi  4.5 M
Installing for dependencies:
 MAKEDEV                       x86_64   3.24-6.el6            base  89 k
 apr                           x86_64   1.3.9-5.el6_2         base  123 k
 apr-util                      x86_64   1.3.9-3.el6_0.1       base  87 k
 apr-util-ldap                 x86_64   1.3.9-3.el6_0.1       base  15 k
 audit-libs                    x86_64   2.3.7-5.el6           base  71 k
 basesystem                    noarch   10.0-4.el6            base  4.7 k
 bash                          x86_64   4.1.2-29.el6          base  907 k
 binutils                      x86_64   2.20.51.0.2-5.42.el6  base  2.8 M
......
Transaction Summary
===========================
Install     158 Package(s)

Total download size: 98 M
Installed size: 346 M
Is this ok [y/N]:

which means everything yum has installed so far is now wiped out from the yum db but is still installed.

Is there a way to restore yum database or to make yum detect which packages the server has installed?

1

2 Answers 2

0

I had a similar situation before. What I did:

  1. Make a list of all files on the filesystem.
  2. Download the SQLite DBs of the yum repos from which I had files.
  3. Create a script that queries the SQLite DBs for which package provides each file and reinstall the packages.

Not really the fastest solution. If it was not a critical system, I would have rebuilt it.

1
  • I could not find the SQLite DBs, but it was not the yum db that was corrupted, but the whole RPM database. You gave me an idea on how I could collect and rebuild the RPM database, thank you. Please see my answer. Can't up vote your answer, not enough rep. Feb 11, 2015 at 10:22
0

It appears the problem was a totally destroyed RPM database. What I did is that I used all the original RPMs to just update the db without installing anything.

You can find the list of installed packages in the files /root/install.log or /var/log/yum.log* if you have yum log installed. If you don't have log files, then you can collect all the installed packages from yum database directory structure with this PHP script yumdb_scan.php.

I wish I had all my RPMs cached, but I finally manage to find everything by searching on RPM search sites. I also created another script to download everything I have installed and was on the base OS repository. Then I collected all the RPM packages, did a verification that I had all of them and create another script that it uses rpm -Uvh --nodeps --justdb {$pckg} to update RPM db for every installed package without altering any system files.

All done well and now I can finally use yum to install new packages and update old ones using repos.

So my steps were:

  1. Search system for installed RPMs and create a file listing them all.
  2. Collect all the RPMs you have installed on system with matching versions for all.
  3. Use rpm -Uvh --nodeps --justdb <package-path> to put RPM record to RPM database without installing any files.

Not the answer you're looking for? Browse other questions tagged .