Daiquiri and gearman

Setup Gearman and PHP

In order to use asynchronous dumping of database tables (or other services we might think of), you need to install the Gearman daemon and the PHP bindings. Usually this can be done through your distribution:

# Ubuntu 14.04, Debian 8
apt-get install gearman-job-server php5-gearman

# CentOS 6/7
yum install gearmand libgearman libgearman-devel php-pecl-gearman

Under Ubuntu 12.04 you need to build gearmand manually (see below).

Then start the daemon:

# Ubuntu 14.04
service gearman-job-server start

# Debian 8
systemctl enable gearman-job-server
systemctl start gearman-job-server

# CentOS 6
chkconfig gearmand on
service gearmand start

# CentOS 7
systemctl enable gearmand
systemctl start gearmand

Setup GearmanManager

The GearmanManager PHP library is provided with Daiquiri and started from within. However if you want, you can install your own version from https://github.com/brianlmoon/GearmanManager and adjust the Daiquiri settings accordingly.

Make sure the POSIX PHP extensions are installed. For Centos 6 you need:

yum install php-process

GearmanManager needs to set a PID, which is done as apache user from within Daiquiri. Make sure you configure query.download.queue.gearman.pid accordingly. We recommend setting it to the root directory of the download directory.

Install gearman php bindings using pecl

For older distributions you might need to install the gearman php bindings using pecl:

pecl install gearman

If you end up with a configure: error: Please install libgearman error, the pecl installer expects libgearman to be located at /usr/include/libgearman-1.0/* and not /usr/include/libgearman/. This happens when the libgearman provided by your package management system is old (< 0.21). In this case you need to *compile gearmand from source** (see below).

Install gearmand from source

First you need to install some prerequisites. In the case of Ubuntu this can be archived using:

apt-get install libboost-dev libboost-program-options-dev gperf
                libevent-dev libcloog-ppl0 uuid-dev

Then build gearmand using:

wget https://launchpad.net/gearmand/1.2/1.1.5/+download/gearmand-1.1.5.tar.gz
tar -xf gearmand-1.1.5.tar.gz
cd gearmand-1.1.5
sudo make install
touch /etc/init.d/gearmand
chmod +x /etc/init.d/gearmand

Then edit /etc/init.d/gearmand for


# Gearman server and library
# Copyright (C) 2008 Brian Aker, Eric Day
# All rights reserved.
# Use and distribution licensed under the BSD license.  See
# the COPYING file in this directory for full text.


  mkdir -p /var/run/gearmand/
  chmod g+w /var/run/gearmand/
  chgrp www-data /var/run/gearmand/

  kill `cat $PIDFILE`
  rm -f $PIDFILE

case "$1" in




    echo "Usage: $0 {start|stop|restart}"


and start the deamon using /etc/init.d/gearmand start.

After that, you can pecl install gearman and everything should work.

Be sure to add 'extension=gearman.so' to php.ini!