26
Jul/09
0

Command execution in Linux clusters with parallel ssh

Paralell ssh is an application written in python which enables parallel execution of shell commands via ssh on multiple machines or copy files to multiple machines with scp. It is handy to manage clusters and manage repitiative tasks on multiple servers.

In Ubuntu the installation is made easily with apt:

apt-get install parallel-ssh

To use parallel ssh each node must allow and use keybased authentication.

To execute a command on multiple nods a file containing the address to each node first needs to be created. Verify that each host’s key is added to known keys and that is possible to connect without entering a password. Then  simply enter:

parallel-ssh -h hostlist.txt -o outputdir "uptime"

This will execute the uptime command on each server in hostlist.txt and the output of each command is writen in a file with the same name as the hostname entered in hostlist.txt in the directory outputdir.

Simple and minimizes repetative tasks when manageing nodes in a cluster.

Cluster SSH is a similar application which “[...] controls a number of xterm windows via a single graphical console window to allow commands to be interactively run on multiple servers over an ssh connection”. If the management node is running *nix with a graphical environment it may be a good alternative.

Filed under: Linux