Remote access
Marcel can run commands remotely on one or more hosts, obtaining results as a combined stream of tuples. In order to run remote commands, marcel must be installed on the remote hosts.
Remote access is configured in the startup script, startup.py. For example, if you have a host named acme, you would configure remote access as follows:
acme = cluster(user='jao',
identity='/home/jao/.ssh/id_rsa',
host='acme')
-
acme = ...: The remote access definition is assigned to the variable named acme. The cluster can be accessed via this variable.
-
cluster(...): A marcel function for describing a remote host or cluster (set of hosts).
-
user='jao': The username by which the remote host will be accessed.
-
identity=...: Password-less authentication for the remote host.
-
host=...: Identifies the host. This can be a name known to DNS, an entry in /etc/hosts, or an IP address.
Once this configuration is in effect, you can run commands against the remote host, e.g.
M 0.18.3 jao@loon ~$ @acme (| ps -c apache | (p: (p.pid, p.cmdline)) |)
(acme, 631, ['/usr/sbin/apache2', '-k', 'start'])
(acme, 12383, ['/usr/sbin/apache2', '-k', 'start'])
(acme, 12384, ['/usr/sbin/apache2', '-k', 'start'])
@acme is the syntax for running a command on the remote host stored in the variable named acme. The command itself is delimited as a pipeline, (| ... |). In this case, the command runs the marcel command ps to locate commands containing apache, and then generates a (pid, command line) tuple for each. The command is sent to acme, executed there, and the results are returned, and labelled with the host that ran the command.
Remote access can also access multiple hosts at the same time. The configuration is similar to before, but instead of configuring a host, you would configure multiple hosts. For example, this configures a cluster with four nodes, lab1 ... lab4, bound to the variable lab.
lab = cluster(user='jao',
identity='/home/jao/.ssh/id_rsa',
hosts=['lab1', 'lab2', 'lab3', 'lab4'])
You can now submit a command to all the nodes comprising the lab cluster, and as before, results are labelled with the source of the tuple. Note that the tuples from the hosts may be interleaved.
M 0.18.3 jao@loon ~$ @lab (| ps -c apache | (p: (p.pid, p.cmdline)) |)
(lab4, 753, ['/usr/sbin/apache2', '-k', 'start'])
(lab4, 14156, ['/usr/sbin/apache2', '-k', 'start'])
(lab2, 907, ['/usr/sbin/apache2', '-k', 'start'])
(lab1, 631, ['/usr/sbin/apache2', '-k', 'start'])
(lab1, 12383, ['/usr/sbin/apache2', '-k', 'start'])
(lab3, 880, ['/usr/sbin/apache2', '-k', 'start'])
(lab1, 12384, ['/usr/sbin/apache2', '-k', 'start'])
(lab2, 13287, ['/usr/sbin/apache2', '-k', 'start'])
(lab2, 13288, ['/usr/sbin/apache2', '-k', 'start'])
(lab3, 12901, ['/usr/sbin/apache2', '-k', 'start'])
(lab4, 14157, ['/usr/sbin/apache2', '-k', 'start'])
(lab3, 12902, ['/usr/sbin/apache2', '-k', 'start'])