How to Resolve “Warning: RPMDB altered outside of yum” Error in RHEL Systems


2 views

When working with RHEL 6 systems managed through RHN Satellite, you might encounter this warning after failed updates:

Warning: RPMDB altered outside of yum.

This typically occurs when package database changes happen through non-yum methods while yum thinks it has exclusive control over the RPM database.

The warning appears in several situations:

  • Manual RPM package installation/removal using rpm -i or rpm -e
  • Direct database manipulation through rpm --rebuilddb
  • Simultaneous yum operations from different sessions
  • RHN Satellite operations interfering with local yum

To clear the warning and restore database consistency:

# Clean yum cache
yum clean all

# Rebuild RPM database
rpm --rebuilddb

# Verify database integrity
rpm -qa | wc -l
yum check

For systems managed through RHN Satellite:

# Configure yum to wait for lock release
echo "metadata_lock_wait = 300" >> /etc/yum.conf

# Set proper Satellite synchronization
rhn_check -vv

Create a monitoring script to detect database inconsistencies:

#!/bin/bash
# Check for yum/RPMDB inconsistencies
if [[ $(yum check 2>&1 | grep -c "altered outside") -gt 0 ]]; then
    logger "YUM RPMDB inconsistency detected"
    rpm --rebuilddb
    yum clean all
fi

For persistent issues, examine the RPM database directly:

# Dump current package list
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" | sort > current_pkgs.txt

# Compare with yum's view
yum list installed | awk '{print $1}' | sort > yum_pkgs.txt
diff -u current_pkgs.txt yum_pkgs.txt

Ensure proper synchronization between Satellite and local systems:

# Force Satellite sync
rhn-profile-sync

# Clear Satellite-related caches
rm -rf /var/cache/rhn/*
rm -rf /var/spool/up2date/*

When you see the "RPMDB altered outside of yum" warning in RHEL 6, it means the RPM database has been modified by tools other than yum (like direct rpm commands or other package managers). This commonly happens when:

  • Manual rpm installations/updates were performed
  • RHN Satellite operations were interrupted
  • Other package managers like up2date were used

First, check the current state of your RPM database:

rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort > installed_packages.txt
ls -lh /var/lib/rpm/__db*

Look for these indicators of problems:

-rw-r--r--. 1 root root  72M Mar 10 09:45 /var/lib/rpm/Packages
-rw-r--r--. 1 root root 128K Mar 10 09:45 /var/lib/rpm/__db.001
-rw-r--r--. 1 root root 256K Mar 10 09:45 /var/lib/rpm/__db.002
-rw-r--r--. 1 root root 20K Mar 10 09:45 /var/lib/rpm/__db.003

Here are the step-by-step solutions:

Option 1: Rebuild the RPM Database

First try rebuilding the RPM database:

cd /var/lib/rpm
rm -f __db*
rpm --rebuilddb

Option 2: Clean Yum Cache

If the warning persists, clean yum's cache:

yum clean all
yum makecache

Option 3: Force Yum to Check Packages

For thorough verification:

yum check
package-cleanup --problems
package-cleanup --dupes

To avoid this warning in RHN Satellite-managed systems:

  • Always use yum or Satellite for package management
  • Avoid direct rpm -i commands
  • Ensure Satellite operations complete fully
  • Regularly check system consistency:
#!/bin/bash
# Weekly system check script
yum check > /var/log/yum_check.log
package-cleanup --problems >> /var/log/yum_check.log

If the issue persists after standard fixes:

strace -f -o yum_debug.log yum check
rpm -Va > rpm_verify.log

Analyze these logs for:

  • Missing files
  • Changed configurations
  • Permission issues