fedora-list Digest, Vol 25, Issue 127

Andrew Mather mathera at gmail.com
Tue Mar 14 00:19:10 UTC 2006


>
> Does anyone have a simple perl or shell script that will run a set of
> commands
> on a number of machines?

For example install a perl cpan module on 50 machines, listed in a file.
>
> What you're asking is not a trivial thing to do in a robust and reliable
way !

This is the sort of thing you need to do if you're managing a cluster for
example.

For my cluster, I use pdsh, which is a public-domain version of the dsh
utility that IBM ship with their CSM suite.  I've aliased it to dsh, because
I was used to that ;-)

You can get it from here:  http://www.llnl.gov/linux/pdsh/

You'll also need the genders library to define groups of machines (eg all
FC4 machines, all FC5 machines).  You can get that from here:
http://www.llnl.gov/linux/genders/

This will all take a bit of setting up, however once it's up and working,
it's a VERY powerful way to manage a heap of machines from a single node.

Once it's working, you can issue a command like: pdsh -a rpm -i somerpm.rpm
This will install somerpm.rpm on all machines, or:  pdsh -g fc4 shutdown -r
now which would reboot all the machines in the fc4 group.

It also comes with a very handy utility called dshbak.  With this, you can
run a command on any number of machines and it will collate the output,
grouping all identical outputs into one and listing the machines.

For example, pdsh -a `date` |dshbak -c would group together all machines
which return identical times.

Other than that, you'd have to set up passwordless login for ssh on every
node, list them all in a file and then use something like

for node in `cat mynodes.txt`
  do
     ssh -c $node do_something
 done

This would (probably) work, but it would be pretty fragile.

HTH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20060314/9dfb1637/attachment-0001.htm>


More information about the fedora-list mailing list