Jump to content

rpm database crash


javabiz
 Share

Recommended Posts

I entered this on the software discussion as well, but in hopes that I could get more gurus involved--I'm entering it here too!

 

To begin with, I found a url with exactly the same problem I'm having with a tentative solution as far as Red Hat. Now I need to figure out if there's anything I can do with urpmi to get me out of my current predicament. Here's the scenario from the url and the Red Hat solution based on rpm

 

http://www.daylate.com/blog/archives/2003_02.html

 

Below is the jist of what it says:

 

RPM Database Crash

 

It was an interesting weekend. I planned on updating the RPM packages on the system over the weekend using Red-Carpet. However, it indicated there weren't any packages to update, which I knew was wrong. I did some checking and it appeared that my RPM database was corrupted. The solution to that seemed to be running rpm --rebuilddb. That rebuilds the database from the header files stored on the computer. Well...do you know what happens if your headers are also corrupted? You end up with a database of RPM's significantly smaller than you had before.

 

Fortunately for me RedHat outputs to a log file (/var/log/rpmpkgs) the current packages installed. After rebuilding my database I compared it with the log file. The rebuilt database was about 1/5 the size. What this means is my rebuilt database was missing 4/5 of the RPM's I had installed on my system. Everythings was still installed and ran fine but I knew I'd run into dependency problems and such if I ever wanted to update my packages or install a new package. So...basically I was left with the task of rebuilding my entire RPM database. Which, according to the rpmpkgs log file was around 800 packages. WHAT A MESS. However, after a few hours I came up with a pretty slick way to do it. I wrote a simple bash script to read through the rpmpkgs log file, download the package from the RedHat distribution and then add it to the database. Here's the script I used:

 

#!/bin/bash

exec < rpmpkgs.1

exec > zoutput.txt

 

while read line

do

wget ftp://ftp.rpmfind.net/linux/redhat/8.0/en...RPMS/$line

rpm -iv --nodeps --justdb --noscripts --force --notriggers $line

done

 

I used the rpmfind website instead of ftp.redhat.com cause it seemed to have more bandwidth. Anyway, I let this run over night. Then wrote another script to determine which packages it couldn't find. Basically it was just a script to figure out which files it couldn't find. I stored these in a file called znotfound.txt. Then I used that file as my input file (instead of rpmpkgs.1) and used the same script to scan the Red-Carpet cache of packages I had on my system (I installed all packages in the Red-Carpet cache first). Anyway, here's the script (basically just as simple as the previous):

 

#!/bin/bash

exec < znotfound.txt

exec > znotfound2.txt

 

while read line

do

if ! test -e $line

then

echo $line

fi

done

 

Basically all this does is check to see if the RPM file exists. After running these scripts I was left with 5 packages that were sill missing. NOT BAD! I can handle installing 5 packages manually, 800 is another thing. After all was said and done I ran rpm -Va to verify the packages installed. Everything looked good. No missing dependencies or conflicts. I think I'll start adding the RPM database directory (/var/lib/rpms) to my backup script.

 

ADDENDUM: I still haven't been able to figure out what caused the corruption in the first place, which has me concerned. We did have a couple power outages recently which sent the machine down hard so maybe that had something to do with it. I dunno...all the more reason to get a server I can colocate at a data center. Unfortunately I can't seem to find a colocation price that is as cheap as just hooking it up to my DSL line .

--------------------------------------------------------So back to my problem:

Does anyone out there know of a way to get Mandrake's rpm database back without having to do the script diddies above? Does the urpmi do essentially the same thing--and if so--what's the command to get my database back. I have the same problem as the person above--but with Mandrake and not Red Hat. For those who say--just change the ftp sites--that probably won't work.

Is there a simpler way than above to get the same results?

All gurus welcome!

 

This post has been edited by javabiz on Mar 10 2004, 02:27 AMrestoration.

Edited by javabiz
Link to comment
Share on other sites

urpmi is the command line version of the Mandrake tools. A corruption as described is possibly caused by having a system that was not updated with the new tools, including urpmi.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...