Gearman and GearmanManager build on CentOS 7.0

Gearman: provides a generic application framework to farm out work to other machines or processes that are better suited to do the work.
GearmanManager : aim[s] is to make running workers more of an operational task and less of a development task.

Gearman is useful when you want to run PHP scripts asynchronously e.g. to build a batch processing cluster or farm out slow running tasks such as email sending which should not block the view being rendered. The GearmanManager addon is not essential but does make the worker code simpler and provides a framework for managing the scripts. Here is my build process:

Gearman


	# Install the reccomended packages http://gearman.info/build/fedora.html (and a couple of others which are required but they forget to include)
	yum install gcc gcc-c++ make bison flex autoconf libtool memcached libevent libevent-devel uuidd libuuid-devel  boost boost-devel libcurl-dev libcurl curl gperf mysql-devel
	# Download the latest files and extract them
	cd /home/admin/Downloads/
	wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
	tar -zxvf gearmand-1.1.12.tar.gz
	cd gearmand-1.1.12
			
	./configure
	make
	make install
	
	# Start the deamon
	mkdir -p /usr/local/var/log/
	gearmand --verbose DEBUG -d
	
	# Check there are no errors
	tail /usr/local/var/log/gearmand.log
	# DEBUG XXX [     2 ] Entering thread event loop -> libgearman-server/gearmand_thread.cc:463
	
	# Install the PHP pear package
	yum install install php-devel php-pear
	pecl install gearman
	
	nano /etc/php.ini
	# Fill in the date.timezone to your location (if you haven't already)
	date.timezone = Europe/London
	# Add line in "Dynamic Extensions" section
	extension=gearman.so
	
	# Restart apache (if thats what you are using)
	systemctl restart apache

GearmanManager


	yum install git-core
	cd /home/admin/Downloads/
	git clone https://github.com/brianlmoon/GearmanManager.git /home/admin/Downloads/gearman-manager
	/home/admin/Downloads/gearman-manager/install/install.sh
	#> Chose 1) pecl
	#> Install ok!  Run /etc/init.d/gearman-manager to start and stop
	#> Worker scripts can be installed in /etc/gearman-manager/workers, configuration can be edited in /etc/gearman-manager/config.ini
	
	# Edit the manager script
	nano /etc/init.d/gearman-manager
	# set the prefix flag to nothing (had an error where it got a random one)
	# -vvv logs starting / stopping of workers which makes debugging much easier
	PARAMS="-c ${CONFIGDIR}/config.ini -vvv -p ''"
	# The user is up to you, personally I prefer using the apache one so file permissions etc. set up for the webserver work for gearman
	GEARMANUSER="apache"
	
	# Start the manager
	/etc/init.d/gearman-manager start
	
	# check for any errors
	tail /var/log/gearman-manager.log
	#> Date  PID   Type   Message
	#> [xxx] 26441 PROC   User set to apache
	#> [xxx] 26441 INFO   Loading workers in /etc/gearman-manager/workers
	#> [xxx] 26441 INFO   No workers found

Errors

For those searching for error strings, here are some I came across and their solutions


	./configure
	#> configure: error: could not find gperf
	yum install gperf
	# ----------------------------------------
	make
	#> libgearman-server/plugins/queue/mysql/queue.cc:49:19: fatal error: mysql.h: No such file or directory
	yum install mysql-devel
	# ----------------------------------------
	make (gearman)
	#> /usr/bin/ld: cannot find -lssl
	#> /usr/bin/ld: cannot find -lcrypto
	#> collect2: error: ld returned 1 exit status
	#> make[1]: *** [gearmand/hostile_gearmand] Error 1
	#> make[1]: Leaving directory `/home/admin/Downloads/gearmand-1.1.12'
	#> make: *** [all] Error 2
	yum install openssl-devel
	# ----------------------------------------
	gearmand -d
	# gearmand: Could not open log file "/usr/local/var/log/gearmand.log"
	mkdir -p /usr/local/var/log/
	# ----------------------------------------
	/etc/init.d/gearman-manager start
	# ERROR: The function posix_kill was not found. Please ensure POSIX functions are installed
	yum install php-process
	# ----------------------------------------
	/etc/init.d/gearman-manager start
	# Starting gearman-manager: ERROR: User (gearmand) not found.
	useradd gearmand
	# ----------------------------------------
	/etc/init.d/gearman-manager restart
	# PHP Warning:  unlink(/var/run/gearman/manager.pid): Permission denied in /usr/local/share/gearman-manager/GearmanManager.php on line 345
	chown -R gearmand:gearmand /var/run/gearman/
	# ----------------------------------------
	pecl install gearman
	# if using a very new version of php e.g. 5.5
	# PHP Warning:  PHP Startup: gearman: Unable to initialize module
	# Module compiled with module API=20090626
	# PHP    compiled with module API=20121212
	# These options need to match
	# in Unknown on line 0
	pecl install --force gearman

Load Comments...