Remote Execution in Clusters

When commands are run on a cluster, a number of options are available to specify the nodes on which the commands can be run.

There is a <where> clause: cluster run <where>.

The clause can take:

  • role - the role of the node: application, database, webproxy

  • all - all the roles, in other words, the entire cluster

  • notme - all nodes except the one the command is run on

  • <data center name> - all nodes in the data center

  • <nodename|IP> - the hostname or IP address of the node.

For example:

  • cluster run database app start mongodb will restart the mongodb service on all database nodes.

  • cluster run all app status will display the app status of all nodes on the cluster.

  • cluster run notme system shutdown would issue the command to shut down all nodes except the one the command is run on.

Important

In a cluster, reboot and shutdown of the entire cluster should be done on each node and not with the cluster run all command.

Sometimes there are long-running processes running on a server. To display such jobs, use the cluster job list command.

Note

The cluster job list command is not available on a web proxy node.

It is also possible to re-attach to those jobs to see the output, using cluster job reconnect <pid>.