Install Gearman daemon from source in CentOS

logo

Installing Gearman on CentOS 6.2

The latest Gearman version available in the EPEL repository is not always up to date. The latest version of Gearman at this moment is 1.1.6. So, here is the procedure to install the Latest version from source. It’s easy to install but I’ve run into some problems while installing that in an amazon EC2 large instance. So added the troubleshooting parts too.

Install Gearman’s dependencies

Use yum to install the dependencies that Gearman needs:

yum install uuid-devel libuuid libuuid-devel uuid boost-devel libevent libevent-devel

Download the latest gearmand source

Download the latest Gearman version from Launchpad. I’ve picked Gearman 1.1.6

# cd /usr/share/
# wget https://launchpad.net/gearmand/1.2/1.1.6/+download/gearmand-1.1.6.tar.gz

Untar, compile and install

Now unpack it (gearmand version 1.1.6 in this example):

# tar -xvzf gearmand-1.1.6.tar.gz

and then compile and install it:

# cd gearmand-1.1.6

# ./configure && make && make test && make install

That’s all, gearman is installed and ready to use.

Build Troubleshoot:

Unfortunately, for my case it shows couple of errors and then terminated. Here is how I resolved that.

1. While configuring, i’ve got the following error:

checking for the toolset name used by Boost for g++… configure: WARNING: could not figure out which toolset name to use for g++

checking for Boost headers version >= 1.39.0… no
configure: error: cannot find Boost headers version >= 1.39.0

Solution: The reason is either you don’t have the “boost-devel” package installed, but I had already installed it before in the first phase (yum install boost-devel). For my case, it seems that I didn’t install g++ (found in the gcc-c++ package). So Installing the gcc-c++ package fixed the issue. ref: Building Gearman 0.27 on CentOS 6

# yum install gcc-c++

2. Now it proceeds further but throws error while running “make”, while compiling the libhostile.c file:

libhostile/function.c: In function ‘print_function_cache_usage’:
libhostile/function.c:54:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
libhostile/function.c:54:3: note: use option -std=c99 or -std=gnu99 to compile your code
CC libhostile/libhostile_libhostile_la-poll.lo
make[1]: *** [libhostile/libhostile_libhostile_la-function.lo] Error 1
make[1]: *** Waiting for unfinished jobs….
libhostile/poll.c: In function ‘poll’:
libhostile/poll.c:93:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
libhostile/poll.c:93:9: note: use option -std=c99 or -std=gnu99 to compile your code
make[1]: *** [libhostile/libhostile_libhostile_la-poll.lo] Error 1
make[1]: Leaving directory `/usr/share/gearmand-1.1.6′
make: *** [all] Error 2

The solution was hard to find, but as it suggests it is failing because the -std=c99 is required. The libhostile C code requires C99. There are some bug reports for this, but forcing the CFLAGS environment variable will fix this.

Solution: Run ./configure –help, you will see a list of configurable variables.

[.. gearmand-1.1.6]# ./configure –help

Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory

I tried to specify gnu99 library,
# CFLAGS=-std=gnu99 ./configure && make && make test && make install

or you can also use c99, and it works:

# CFLAGS=-std=c99 ./configure && make && make test && make install

ref: libpq configuration on ubuntu

3. Finally I ran into the mysql.h header file missing error while in “make”:

libgearman-server/plugins/queue/mysql/queue.cc:49:19: fatal error: mysql.h: No such file or directory
compilation terminated.

Solution: The solution is simple, i had missing “mysql-devel” package. So installing it solves the problem.

# yum install mysql-devel

so now you can run the gearman as below:

# gearmand -d -u root

Next to code Gearman’s client and worker process you need to install Gearman PHP extension. It’s very easy and straightforward, to do so, please follow this link: Installing Gearman PHP extension on CentOS

Reference:
You might also look into this:
1. Installing Gearman on CentOS 6.2
2. Getting started with Gearman
3. Gearman 0.14 on CentOS 5.5 and PHP bindings

Hope that it’ll help someone.

10 comments: On Install Gearman daemon from source in CentOS

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar

About Me

MurshedVi Die hard coder, Unix server admin, Open source enthusiast, Localization guru, PHP expert, Apache-Solr ecosystem expert, Web geek. The wounded coder, determined not to stop before killing all bugs!! The samurai, bug hunter willing to create a bug free world for all humans!! Great Team player (always watch & cover the back of others). Extra Patience (to dig the root of every single bugs). Ultra Passionate (caring about the products I built). Perfectionist, Proactive, Collaborative, Good listener, Observer, Thinker, thoughtful to serve the better, best, awesome user experience for all netizens. Do you have a tech challenge? Drop a mail to khan.morshed@gmail.com

Oops! It looks like you haven't imported any lists yet. You must import at least one list to use the Easy MailChimp widget.