How to set up a grid of computers using the Mac OS X desktop version.
Any machine can be an agent. Configure the agent using the Sharing Pane of System Preferences. See Managing Xgrid Agents.
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.
Command line:
$ xgridctl
Start the controller:
$ ssh [email protected]
$ sudo xgridctl c start
Turn off an agent:
$ ssh [email protected]
$ sudo xgridctl a stop
More options:
$ sudo xgridctl
usage: xgridctl [controller|agent] status|start|stop|restart
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.
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
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
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
What is copied back to the client?
- The stdout stream
- The stderr stream
- The working dir
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
...
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
Xgrid: http://www.apple.com/science/hardware/gridcomputing.html
Tutorials: http://macresearch.org/the_xgrid_tutorials
Wiki/Docs/FAQ/etc: http://tengrid.com