Pdsh

From Leo's Notes
Revision as of 22:23, 23 January 2023 by Leo (talk | contribs) (Created page with "The pdsh command is a parallel version of the dsh (Distributed Shell). It is used to run commands on multiple remote hosts in parallel and supports a number of remote shell programs including SSH. == Cheat sheet == {| class="wikitable" !Action !Command |- |Run a command on all hosts |<code>pdsh -a uptime</code> |- |Run a command on a set of hosts by hostname Or by a specific gender (ie. attribute), see below. |<code>pdsh -w node[0-10] uptime</code><code>pdsh -w cpus=8 u...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 23 January 2023, at 22:23.

The pdsh command is a parallel version of the dsh (Distributed Shell). It is used to run commands on multiple remote hosts in parallel and supports a number of remote shell programs including SSH.

Cheat sheet

Action Command
Run a command on all hosts pdsh -a uptime
Run a command on a set of hosts by hostname

Or by a specific gender (ie. attribute), see below.

pdsh -w node[0-10] uptimepdsh -w cpus=8 uptime
Collect the OS version on all hosts and group it pdsh -a cat /etc/redhat-release | dshbak -c

Configuration

Genders file

The genders file can be used to give attributes to nodes in a cluster. It can be thought of as groups that can be used as a target when running pdsh commands.

The genders file is usually located at /etc/genders. Each line can contain one or more hosts and attributes are given as a comma delimited list. Here is an example genders file:

ca-controller management
ca-login cluster-a,login
ca[001-168] cluster-a,cpus=4
cb-login cluster-b,login
cb[091-320] cluster-b,cpus=8

Using this example, you can target:

  • Only the control node with pdsh -w management
  • Only cluster A nodes with pdsh -w cluster-a
  • Only nodes with 8 CPUs with pdsh -w cpus=8