vROPs How to execute a command on multiple cluster nodes from Master

If you would like to run a command remotely from the master node on all/only data/only remote collector nodes here is how you can do this.

On the master create a SSH key.

localhost:~ # ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
ca:1a:a3:40:c1:5b:bb:e5:6f:b7:55:4c:bc:ce:b2:11 [MD5] root@localhost
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|.           .    |
| o .         o   |
|  + .       o .  |
| o . .  S  E +   |
|.   +. .    =    |
|.  .o.o    + o   |
| . . +.. .. +    |
|  . . ......     |
+--[MD5]----------+

Copy the public key to all nodes.

localhost:~ # ssh-copy-id -i /root/.ssh/id_rsa.pub root@DATA-NODE

Now you have to created 3 files containing the following hosts (FQDN or IP) in /root.

datanodes.lst – contains only the data nodes and the master itself
rcnodes.lst – contains only the RC nodes
allnodes.lst – contains all nodes including master

vi allnodes.lst
master.internal.xmsoft.de
node01.internal.xmsoft.de
node02.internal.xmsoft.de
node03.internal.xmsoft.de
rc01.internal.xmsoft.de

So if you would like to execute a command on all node you can run the following command.

for i in `cat /root/allnodes.lst`; do echo $i;ssh $i 'free -m'; done

Example:

localhost:~ # for i in `cat /root/allnodes.lst`; do echo $i;ssh $i 'free -m';echo ""; done
master.internal.xmsoft.de
             total       used       free     shared    buffers     cached
Mem:         48267      47812        454          0         38       9547
-/+ buffers/cache:      38226      10040
Swap:        23999          0      23999

node01.internal.xmsoft.de
             total       used       free     shared    buffers     cached
Mem:         48267      47680        587          0         52      10031
-/+ buffers/cache:      37595      10671
Swap:        23999          0      23999

node02.internal.xmsoft.de
             total       used       free     shared    buffers     cached
Mem:         48267      47122       1145          0         38       9009
-/+ buffers/cache:      38074      10192
Swap:        23999          0      23999
node03.internal.xmsoft.de
             total       used       free     shared    buffers     cached
Mem:         48267      47961        306          0         58      11403
-/+ buffers/cache:      36499      11768
Swap:        23999          0      23999

rc01.internal.xmsoft.de
             total       used       free     shared    buffers     cached
Mem:         48267      47983        283          0         67      12307
-/+ buffers/cache:      35608      12658
Swap:        23999          0      23999

You can replace “free -m” with any other linux command.