Sunday, August 4, 2013

Installing pdsh to issue commands to a group of nodes in parallel in CentOS

1. What is pdsh? Pdsh is a high-performance, parallel remote shell utility. It uses a sliding window of threads to execute remote commands, conserving socket resources while allowing some connections to timeout if needed. It was originally written as a replacement for IBM's DSH on clusters at LLNL. More information can be found at PDSH Web site

2. Setup EPEL yum repository on CentOS 6. For more information, see Repository of CentOS 6 and Scientific Linux 6  

3. Do a yum install
# yum install pdsh
To confirm installation
# which pdsh

4. Configure user environment for PDSH
# vim /etc/profile.d
Edit the following:
# setup pdsh for cluster users
export PDSH_RCMD_TYPE='ssh'
export WCOLL='/etc/pdsh/machines'

5. Put the host name of the Compute Nodes
# vim /etc/pdsh/machines/

node1
node2
node3
.......
.......

6. Make sure the nodes have their SSH-Key Exchange. For more information, see Auto SSH Login without Password 7. Do Install Step 1 to Step 3 on ALL the client nodes.


B. USING PDSH Run the command ( pdsh [options]... command )

1. To target all the nodes found at /etc/pdsh/machinefile. Assuming the files are transferred already. Do note that the parallel copy comes with the pdsh utilities
# pdsh -a "rpm -Uvh /root/htop-1.0.2-1.el6.rf.x86_64.rpm"

2. To target specific nodes, you may want to consider using the -x command
# pdsh -x host1,host2 "rpm -Uvh /root/htop-1.0.2-1.el6.rf.x86_64.rpm"
References
  1. Install and setup pdsh on IBM Platform Cluster Manager
  2. PDSH Project Site
  3. PDSH Download Site (Sourceforge)

2 comments:

Anthony Affee said...

FYI, for hosts to be included its not -x switch, its -w:

pdsh-2.27 on Centos 5 machine:

# To Target all nodes in /etc/pdsh/machine file:
pdsh -a "date"

# To Target specific nodes in /etc/pdsh/machine file:
pdsh -w bvcacher1,bvcacher2 "date"

Anthony Affee said...

FYI, for hosts to be included its not -x switch, its -w:

pdsh-2.27 on Centos 5 machine:

# To Target all nodes in /etc/pdsh/machine file:
pdsh -a "date"

# To Target specific nodes in /etc/pdsh/machine file:
pdsh -w bvcacher1,bvcacher2 "date"