Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells, Featured

Matching Installed RPMs on Two Systems

Submitted by on January 6, 2014 – 10:02 pm

The basic problem is this: you have server “A” with a bunch of packages – let’s say PHP-related stuff – installed you need for you application. You need to get the same application working on server “B”, which is not an exact copy of server “A” and is missing some of the packages.

Mixing and matching RPMs by hand is a tedious and error-prone process. Here’s a basic, semi-automated process for getting through this task. Keep in mind that these commands need to be executed as root. Also, server “A” and server “B” need to be running the same (or very similar) Linux flavor and version.

On server “A” generate a list of installed packages – we use PHP* packages in this example – and save it to a file:

rpm -qa | grep ^php | sed 's/-[0-9]/@/g' | awk -F'@' '{print $1}' | sort -u > /tmp/rpm_list.txt

The result will look something like this:
php
php-cli
php-common
php-gd
php-ldap
php-mbstring
php-mcrypt
phpmyadmin
php-mysql
php-pdo
php-pear
php-pear-Auth-SASL
php-pear-Net-SMTP
php-pear-Net-Socket
php-snmp
php-xml

Now copy this file to server “B” and try to install every package in the list (in this example we use CentOS and yum):
for i in `cat /tmp/list` ; do yum -y install $i ; done

This will install whatever is not already installed and available from the repositories. It is important to make sure server “B” has the same or equivalent repositories as server “B”. Also, make sure you have plenty of disk space available.

If you have passwordless SSH from server “A” to server “B” and passwordless “sudo su – root”, you can do the whole thing in one line:

rpm -qa | grep ^php | sed 's/-[0-9]/@/g' | awk -F'@' '{print $1}' | sort -u > /tmp/list ; scp -p /tmp/list server_b:/tmp/list ; ssh -qt server_b 'cat /tmp/list | while read i ; do sudo su - root -c "yum -y install $i" ; done'

 

Print Friendly, PDF & Email

Leave a Reply