At the time of this writing
gearman job server (libgearman) 1.1.x or later (part of the 1.2 Series as described in the series and milestones is considered unstable and pecl client 1.1.x requires modules from libgearman 1.1.
Therefore the suggested installation is gearman job server 1.0.6 and pecl 1.0.3
This document describes the installation process and working samples for client, job server and workers for [Gearman] 1
Example 01_helloworld
start a client, start a worker (not necessarily in this order) and see the job get done.
Example 02_async
start a client, start a worker and see the job get done. The client script ends without waiting for the job to finish (work runs in background)
Example 03_GearmanManager
Spawn workers with [Gearman Manager] 3 (not maintained)
Example 04_Supervisord
Spawn workers with [Supervisord] 2
Example 05_graceful_restart
- Ensure that workers don't drop started but unfinished jobs.
- terminate the worker based on number of jobs completed and maximum Duration
Monitoring: Gearman Monitor web application [Gearman Monitor] 4
sudo apt-get -y install libgearman-dev libevent-dev
sudo apt-get -y install libboost-all-dev cloog-ppl
curl -L https://launchpad.net/gearmand/1.0/1.0.6/+download/gearmand-1.0.6.tar.gz > gearmand-1.0.6.tar.gz
tar xzf gearmand-1.0.6.tar.gz &&
cd gearmand-1.0.6 &&
./configure &&
make &&
sudo make install &&
cd ../ &&
rm -rf gearmand-1.0.6 &&
rm gearmand-1.0.6.tar.gz
Switch to this directory
cd setup
sudo cp init.d-gearman-job-server /etc/init.d/gearman-job-server
sudo /etc/init.d/gearman-job-server start
sudo apt-get install python-software-properties sudo add-apt-repository ppa:gearman-developers/ppa sudo apt-get update sudo apt-get install gearman-job-server gearman-tools
sudo /etc/init.d-gearman-job-server start
the problem with this approach is that Ubuntu has a very old version of gearmand 0.27 or 0.33 depending on the distribution.
sudo apt-get install gearman-job-server
start
sudo service gearman-job-server start
stop
sudo service gearman-job-server start
check status
sudo service gearman-job-server status
start
gearmand -d -L 127.0.0.1 -l /var/log/gearmand.log
stop
(echo shutdown ; sleep 0.1) | netcat 127.0.0.1 4730 -w 1
check status in processes:
lsof -i -P | grep gearmand
check status should output:
gearmand 26501 root 8u IPv4 69854 0t0 TCP *:4730 (LISTEN)
gearmand 26501 root 9u IPv6 69855 0t0 TCP *:4730 (LISTEN)
check status querying gearman's Administrative Protocol
check status
(echo status; sleep 0.1) | netcat 127.0.0.1 4730 -w 1
check workers
(echo workers; sleep 0.1) | netcat 127.0.0.1 4730 -w 1
sudo pecl uninstall gearman &&
sudo pecl install gearman-1.0.3
-
download from PECL
curl http://pecl.php.net/get/gearman > pecl-gearman.latest.tgz
NOTE: if you plan to use GearmanManager pecl gearman 0.81 is recommended instead of 1.0.2 due to a bug as described here. No need to worry about downgrading. Installing 0.8.1 will overwrite previous installation.
curl http://pecl.php.net/get/gearman-0.8.1.tgz > pecl-gearman.latest.tgz
-
install
tar xzf pecl-gearman.latest.tgz cd gearman-X.Y phpize ./configure make make install
-
add php extension
in php.ini add extension="gearman.so" or alternatively touch gearman.ini in conf.d directory adding this line:extension="gearman.so"
- validate installation
execute this php command from your environment (apache, cli, php -a) print gearman_version() . "\n";
0.33
Provides a web interface to display worker, server and queue status. Cloned from https://github.com/yugene/Gearman-Monitor
- Prerequisite pear Net_Gearman (at the time of the writing 0.2.3 alpha)
pear install Net_Gearman-0.2.3
-
git clone https://github.com/yugene/Gearman-Monitor.git
-
Modify /etc/apache2/sites-available/
<VirtualHost *:80>
ServerName gearman-monitor.local
DocumentRoot <path-to-project>/Gearman-Monitor
</VirtualHost>
- Setup Gearmonitor on Apache (modify /etc/hosts)
127.0.0.1 gearman-monitor.local
- modify _config.php with the server info
$cfgServers[$i]['address'] = '127.0.0.1:4730';
$cfgServers[$i]['name'] = 'Gearman server 1';
- Restart Apache
sudo service apache2 restart
- browse the site
monitoring/administator.php a command line monitoring tool
Gearman Manager will be tested at a later step https://github.com/brianlmoon/GearmanManager
Supervisor provides monitoring and controlling of processes on Unix-like systems Here an installation script is provided and instructions on how to manage gearman workers with Supervisord http://supervisord.org/
- http://gearman.org/index.php
- http://gearman.org/index.php?id=getting_started (official installation instructions and example)
- http://gearman.org/index.php?id=documentation (some documentation)
- http://gearman.org/docs/dev/index.html (some sample in C)
- https://launchpad.net/gearmand (source code, issues and downloads)
- https://launchpad.net/~gearman-developers/+archive/ppa installation through PPA
- http://www.perspectiverisk.com/blog/2012/02/creating-a-penetration-testing-web-server-using-gearman-supervisor-part-1-installation-basic-usage/ very thorough installation process
- http://java.dzone.com/news/gentle-introduction-gearman good read for gearman
- http://www.modernfidelity.co.uk/tech/installing-configuring-and-running-gearman-php-ubuntu installation through apt source list update ... a bit confusing on whether it works or not
- http://gearman.org/index.php?id=protocol Gearman Administrative Protocol (search for section 'Administrative Protocol')
- https://github.com/yugene/Gearman-Monitor Monitors Server, Workers and Queue
- http://supervisord.org/ Managing Gearman Processes (python application)
- https://github.com/yugene/Gearman-Monitor Managing Gearman Processes (php script)