...a parallel shell allowing you to run the same command on many machines.
All serious Linux administrators have a tool,
or few,
they use to run commands in mass as it simply isn't practical to ssh
into a bunch of machines. Even for those of us who regularly work only a
small number of machines,
it is no fun either. There are many tools out there from free utilities to expensive
COTS solutions as well as plenty of
RYO specials. My favorite is
pdsh.
The
intention of this blog posting is to jump-start anyone who could
benefit from learning how to use it. First, you need to get pdsh
installed on your machine; not on all of them, just the server you want
to invoke the commands from. For CentOS/RHEL, you can just run
yum install pdsh
to get the bits. Once you have that, you'll want a text file with a
list of servers you want to run the commands again such as this example.
n2.hdp22.ha
n3.hdp22.ha
n4.hdp22.ha
n5.hdp22.ha
|
Then the magic is as simple as the following.
pdsh -R ssh -w ^cluster.txt "<command>"
|
For an example, what if I wanted to check the current time on a bunch of machines. I could accomplish that easily enough.
[root@n1 ~]
n3: Fri Jan 9 16:51:48 EST 2015
n4: Fri Jan 9 16:51:50 EST 2015
n2: Fri Jan 9 16:51:48 EST 2015
n5: Fri Jan 9 16:51:48 EST 2015
[root@n1 ~]
|
If this was your intro into command blaster utilities, I
hope it helps. If you do this stuff all day, please add a comment with
the tool(s) you use.
No comments:
Post a Comment