Find the answer to your Linux question:
Results 1 to 6 of 6
Lets say I have a Red hat server, and I want to make a copy of it. The most obvious way to do this would be to make a clone. ...
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    13

    RPM query - New server

    Lets say I have a Red hat server, and I want to make a copy of it. The most obvious way to do this would be to make a clone. If we assume I can't do this, and I want to be able to build the server from scratch, and bring it up to the same level, then what would be the best way to achieve this?

    I know you can do a rpm -qa to find out a list of rpms. My problem is though that over time rpms will have been installed, or maybe even removed. It seems very time consuming to get a list and to manually find all the rpms. The redhat network lists which software is installed, but there is no way to download all of the rpms at once.

    I suppose this is a task ideally addressed by the red hat satellite service but sadly I don't have this option. A local yum repository would be good, but of course I would need a way to find all the rpms i need. I don't understand why you can't just select rpms and download them all from the rhn.

    Just wondered if anyone had any ideas.

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,099
    You could save the list of rpm names from the existing box:
    Code:
    rpm -qa --queryformat "%{NAME}\n" |sort|uniq|tee sorted_uniq_rpmlist | xargs echo > sorted_uniq_oneline_rpmlist
    This will give you two files:
    sorted_uniq_rpmlist and sorted_uniq_oneline_rpmlist

    The list is sorted for better diffing against the package list of the second system
    and it is uniq´ed to filter out possible double names because of arch (i386 and x86_64).

    You can then use sorted_uniq_oneline_rpmlist to install the same packages on the second machine.
    Code:
    yum install `cat sorted_uniq_oneline_rpmlist`
    Probably yum will bark as the list of argument can get very long.
    In that case a loop might help:
    Code:
    for PACKAGE in `cat sorted_uniq_oneline_rpmlist`; do yum install $PACKAGE; done
    Of course, the second machine needs access to rhn (aka it needs a valid subscription) to be able to use yum.

    After either of the two yum installs finished, you can run on the second machine
    Code:
    rpm -qa --queryformat "%{NAME}\n" |sort|uniq > sorted_uniq_rpmlist-2
    Do a diff of sorted_uniq_rpmlist and sorted_uniq_rpmlist-2 to verify, that the second machine has now the same packages.

    This procedure should give you an installation with the same packages.
    You must always face the curtain with a bow.

  3. #3
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,099
    One more thing:
    This will only work for RPMs that can be installed via yum, aka: that are in reachable and configured repositories.

    On a default install of a subscriped redhat this is the rhn only, but one could imagine additional repositories.

    All manual installed RPMs that you might have, will have to be manually installed on the second machine as well.
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    Nov 2009
    Posts
    13
    Thank you for that, it's very helpful

    I was just wondering though, if you could modify that so it only shows the rpms installed after a particular date? Is there a way to do this?

  5. #5
    Just Joined!
    Join Date
    Nov 2009
    Posts
    13
    Just one more question. I've noticed that the packages listed, do not state the version number. Is there a way to state this? On this particular server I am working on it has a lot of old packages, so don't want to be installing the latest ones.

  6. #6
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,099
    Sure there is.
    Search the man page of rpm for QUERYFMT
    and modify the example I have given earlier
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...