Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
:
mycluster-minion-0
mycluster-minion-1

Executing custom commands in multiple VM nodes (e.g., checking availability of Pythone modules in multiple VM nodes)

Because the created cluster has prepared environments allowing ssh access to all VM nodes for root account in a key-based login mode without password, the following script works via ssh remote execution in all remote VM nodes.

...

This script is available at https://github.com/astromsshin/cloud_ex/blob/main/tool_execute_commands_all_nodes.sh . The script shows a typical case of executing custom commands in all VM nodes including a master node in the cluster. Other scripts in this tip section basically follow the same way as the above script in executing specific commands. If you are not familiar with executing multiple Linux shell commands in a single command-line, see https://dev.to/0xbf/run-multiple-commands-in-one-line-with-and-linux-tips-5hgm . One example of using the above method is checking availability of Python modules in multiple VM nodes including the cluster master. The following script (https://github.com/astromsshin/cloud_ex/blob/main/tool_test_whether_python_modules_available.sh) runs a short Python script (from tqdm import tqdm; from astropy.io import fits; from sklearn import mixture; import matplotlib.pyplot as plt; import numpy) which does not cause errors when the required modules are available.

Code Block
languagebash
#!/bin/bash

CLUSTERNAME="mycluster"
MINIONLASTIND="2"

RUNCMD='echo "Checking on $(hostname)"; python3 -c "from tqdm import tqdm; from astropy.io import fits; from sklearn import mixture; import matplotlib.pyplot as plt; import numpy; print(\"SUCCESS\")"'

echo "... install on ${CLUSTERNAME}-master"
echo $RUNCMD | bash

for ind in $(seq 0 ${MINIONLASTIND})
do
  echo "... install on ${CLUSTERNAME}-minion-${ind}"
  ssh ${CLUSTERNAME}-minion-${ind} "${RUNCMD}"
done

Changing root password in multiple VM nodes

...