Create a gist now

Instantly share code, notes, and snippets.

@fspaolo /xgrid.md
Last active Aug 9, 2017

What would you like to do?

Grid computing with Apple's Xgrid

How to set up a grid of computers using the Mac OS X desktop version.

The Xgrid agent (worker)

Any machine can be an agent. Configure the agent using the Sharing Pane of System Preferences. See Managing Xgrid Agents.

The Xgrid controller (master)

Configuration is straightforward on Mac OS X Server. However, on the desktop version use the XgridLite open source software to:

  • Turn on and off the built-in Xgrid controller with a single click
  • Set passwords for client and agent authentication
  • Reset the controller to default settings

See Managing an Xgrid Controller.

The Xgrid Daemon Control Interface

Command line:

$ xgridctl

Start the controller:

$ ssh username@remote.controller.edu
$ sudo xgridctl c start

Turn off an agent:

$ ssh username@remote.agent.edu
$ sudo xgridctl a stop

More options:

$ sudo xgridctl
usage: xgridctl [controller|agent] status|start|stop|restart

The Xgrid Admin tool

Provides a summary of the activity of the grid. This software is part of Mac OS X Server. Download it for free from Apple's website.

A hack for Snow Leopard

To have read/write permission on the agents in /Volumes we need kerberos. But it is only available on Mac OS X Server. Instead... one can simply change the configuration files:

$ sudo cp /usr/share/sandbox/xgridagentd_task_nobody.sb /usr/share/sandbox/xgridagentd_task_nobody.sb.bak
$ sudo cp /usr/share/sandbox/xgridagentd_task_somebody.sb /usr/share/sandbox/xgridagentd_task_nobody.sb 

The xgrid command-line client (user)

Set the environmental variables (or add these to your .bashrc):

$ export XGRID_CONTROLLER_HOSTNAME=hostname
$ export XGRID_CONTROLLER_PASSWORD=password

Client submit jobs to the controller:

$ xgrid -job submit /usr/bin/python -O test.py

{jobIdentifier = 231; }

Client queries the results:

$ xgrid -job results -id 231 

Agent jobs

What is copied to the agents?

  • The Command (if relative path): /tmp/xgagent.GSI0Z6o4/bin/sh
  • The Working dir (if relative path): /tmp/xgagent.bUDiNL4g

Client results

What is copied back to the client?

  • The stdout stream
  • The stderr stream
  • The working dir

Submitting multiple jobs

For single task jobs, simply let the controller managing the jobs:

$ xgrid -job submit /usr/bin/python test1.py
$ xgrid -job submit /usr/bin/python test2.py
$ xgrid -job submit /usr/bin/python test3.py
...

Running batch jobs

For multiple task jobs, you can use the following scripts to create and send batch files to the controller, and to retrive the results:

Notice that the xgrid command line tool does not support "globbing" multiple files as argument (e.g. *.ext). For that purpose I wrote the above scripts.

To generate and submit a batch file with jobs that call a program prog with command line argument arg on several files:

$ python xg-batch.py -s -j jobname -c "/path/to/prog -a arg" /path/to/files/*.ext

To retrieve the results by passing the ID files (generated by xg-batch.py):

$ python xg-result.py file1.id file2.id file3.id ... 

Or by passing the directory containing those files:

$ python xg-result.py /path/to/directory

More info

Xgrid: http://www.apple.com/science/hardware/gridcomputing.html
Tutorials: http://macresearch.org/the_xgrid_tutorials
Wiki/Docs/FAQ/etc: http://tengrid.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment