PDSH

July 14, 2017 | Linux Provisioning

PDSH is a an efficient, multithreaded remote shell client which executes commands on multiple remote hosts in parallel. PDSH implements dynamically loadable modules for extended functionality such as new remote shell services and remote host selection. In my humble option, PDSH has been largely superseded by Ansible, which can easily do everything PDSH can, and many more things that PDSH can’t.

Installing pdsh

PDSH package is available from the EPEL repository. To install pdsh on the admin node pulpos-admin:

# yum -y install pdsh

Let’s do a quick test:

# pdsh -w 192.168.1.[2-7] hostname
192.168.1.2: pulpo-dtn.ucsc.edu
192.168.1.4: pulpo-mds01.ucsc.edu
192.168.1.3: pulpo-mon01.ucsc.edu
192.168.1.6: pulpo-osd02.ucsc.edu
192.168.1.7: pulpo-osd03.ucsc.edu
192.168.1.5: pulpo-osd01.ucsc.edu

We can use the WCOLL environment variable to specify a filename that lists the target nodes. For example, let’s create a file ~/pdsh/hosts that lists all the hosts in the Pulpos cluster:

pulpo-admin.local
pulpo-dtn.local
pulpo-mds01.local
pulpo-mon01.local
pulpo-osd0[1-3].local

Then after setting the environment variable, we can simply run pdsh:

# export WCOLL=~/pdsh/hosts

# pdsh uptime
pulpo-admin:  15:03:51 up 3 days,  1:01,  2 users,  load average: 0.04, 0.11, 0.13
pulpo-mds01:  15:03:51 up 3 days,  1:01,  0 users,  load average: 0.00, 0.05, 0.10
pulpo-dtn:  15:03:51 up 3 days,  1:02,  0 users,  load average: 0.01, 0.09, 0.12
pulpo-mon01:  15:03:51 up 3 days,  1:01,  0 users,  load average: 0.26, 0.11, 0.12
pulpo-osd02:  15:03:51 up 3 days,  1:01,  0 users,  load average: 0.10, 0.16, 0.15
pulpo-osd01:  15:03:51 up 3 days,  1:01,  0 users,  load average: 0.02, 0.16, 0.21
pulpo-osd03:  15:03:51 up 3 days,  1:01,  0 users,  load average: 0.02, 0.11, 0.14

Note PDSH package also includes 2 other tools: pdcp & rpdcp. pdcp copies files to groups of hosts in parallel, while rpdcp (reverse pdcp) copies files from a group of hosts in parallel.

dshgroup module

The dshgroup module allows pdsh to use dsh style group files from /etc/dsh/group/ or ~/.dsh/group/. The default search path may be overridden with the DSHGROUP_PATH environment variable, a colon-separated list of directories to search.

Install dshgroup module:

# yum -y install pdsh-mod-dshgroup

Create the directory /etc/dsh/group/:

# mkdir -p /etc/dsh/group/

Create a group file (/etc/dsh/group/osd) for the OSD nodes:

pulpo-osd0[1-3].local

Test the osd group:

# pdsh -g osd uptime
pulpo-osd02:  15:27:44 up 3 days,  1:25,  0 users,  load average: 0.30, 0.11, 0.12
pulpo-osd03:  15:27:44 up 3 days,  1:25,  0 users,  load average: 0.31, 0.15, 0.15
pulpo-osd01:  15:27:44 up 3 days,  1:25,  0 users,  load average: 0.38, 0.18, 0.20