[Gearman] installation of Gearman on CentOS

Source: Internet
Author: User

I. INTRODUCTION

Gearman installation in 2 steps, the 1th step is the installation of Gearmand, the 2nd step is the installation of Gearman PHP extension.

1th Step:

Two. Installation of Gearmand

1. First install the Libdrizzle

#yum Install Libdrizzle Libdrizzle-devel

2. Install Gearman (two methods 1.yum2. Source package). (version C of server)

1) Yum Installation

#rpm-IVH http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm

#yum install-y Gearmand

2) Source Package installation

#cd/opt/build/

#wget https://launchpad.net/gearmand/trunk/0.34/+download/gearmand-0.34.tar.gz

#tar ZXF gearmand-0.34.tar.gz

#cd gearmand-0.34

#./configure

#make && make Install

3. Start the Gearman service

1) Yum installation method

#/etc/init.d/gearmand start

2) Source Package installation method

#/opt/build/gearmand-0.34/sbin/gearmand-d


#gearmand-vvv-u Root

INFO starting up

INFO Listening on::: 4730 (6)

INFO Creating Wakeup Pipe

INFO Creating IO Thread Wakeup pipe

INFO Adding event for listening socket (6)

INFO Adding event for Wakeup Pipe

INFO Entering Main Event loop

Three. Gearman's PHP extension installation

1. Download extension: Http://pecl.php.net/package/gearman

wget http://pecl.php.net/get/gearman-1.1.2.tgz

Tar zxvf gearman-1 ....

CD gearman-1 ...

Phpize

./configure

Make && make install

The installation is completed shortly, and the path to the so file is displayed, such as:/usr/lib64/php/modules/

2. Add extension= "/usr/lib64/php/modules/gearman.so" at the end of PHP.ini, restart Apache, output php–info |grep "Gearman" or PHP- m or the Web output phpinfo () can see that the installation has been successful.

FAQ: Configure if you are prompted to find Php-config, specify. such as –with-php-config=/usr/local/php/bin/php-config, note to specify complete, do not write only directories.

Four. Gearman start-up and test

1.gearmand-p 4730-l 121.111.111.111--log-file=/tmp/gearmand-4730.log--pid-file=/tmp/gearmand-4730.pid-d

2.Client:

$myParams = Array ();

$myParams [' level '] = "warn";

$myParams [' content '] = "It s a test";

$client = new Gearmanclient ();

If the Gearman does not respond within 300 milliseconds, close the connection directly

$client->settimeout (300);

$client->addserver ("121.111.111.111", "4730");

$client->dobackground ("Log", Json_encode ($myParams));

3.Server

$worker = new Gearmanworker ();

$worker-Addserver ("112.111.111.111", "4730");

$worker-AddFunction ("Log", "Dolog");

while ($worker, work ());

function Dolog ($job) {

Global $logger, $logLevels, $myParams;

$myParams = NULL;


$myParams = Json_decode ($job, workload ());

$level = $myParams->level;

if (!in_array ($level, $logLevels)) $level = ' info ';


$logger-$level ($myParams->content);

}

Reference:

Http://www.cppblog.com/guojingjia2006/archive/2013/01/07/197076.html

http://www.xiaomlove.com/php Installing the Gearman extension for asynchronous step-by Tasks/

This article is from the "Programming Art" blog, so be sure to keep this source http://itsart.blog.51cto.com/1005243/1706696

[Gearman] installation of Gearman on CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.