Gearman 非同步任務軟體安裝與例項

2021-07-14 06:59:56 字數 2739 閱讀 6760

sudo apt install gperf

sudo apt install libboost-program

-options

-dev

sudo apt install libevent-dev

sudo apt install uuid-dev

sudo yum install gperf       // hash 函式庫

sudo yum install boost-devel

sudo yum install libevent libevent-devel

sudo yum install libuuid-devel

1.安裝boost

如果不安裝boost的話,是安裝不上gearmand和gearman的.

如沒有問題,在/etc/profile裡的最下方加入:

export cppflags=-i/usr/local/boost/include

export ldflags=-l/usr/local/boost/lib

儲存退出後執行

source /etc/profile

好了,boost就安裝成功了.

wget 

tar zxvf gearmand…

cd gearmand …

//如果手動安裝的boost那麼就執行這句,否則執行下一句

sudo ./configure --prefix=/usr/local/gearmand --

with

-boost

=/usr/local/boost

sudo ./configure --prefix=/usr/local/gearmand

sudo make && make install

wget 

tar zxvf gearman-

1….cd gearman-

1 …phpize

./configure --

with

-php

-config

=/usr/local/php/bin/php-config

make && make install

我們在安裝gearman的時候,已經有libgearman了,但是在編譯擴充套件的時候,卻用額外安裝的lib,在執行的時候,難免出現效能方面的問題

./configure --prefix=/opt --

with

-php

-config

=/usr/local/php/bin/php-config

--with

-gearman

=/usr/local/gearmand

/usr/local/gearman/sbin/gearmand -d

nohup php myworker.php >/dev/null 2>&1 &

could not open log file "/usr/local/var/log/gearmand.log", from "/usr/sbin",

switching to stderr. (no such file or directory)

mkdir -p /usr/local/var/log

/ cd /usr/local/var/log

/ touch gearmand.

log

<?php

// producer

$client= new gearmanclient();

//$client->addservers('192.168.1.131:4730,192.168.2.249:4730,192.168.2.250:4730');

$client->addserver('192.168.1.131',4730);

print

$client->do("title", "all the world's a stage");

print

"\n";

<?php

$worker= new gearmanworker();

$worker->addservers('192.168.1.131:4730,192.168.2.249:4730,192.168.2.250:4730');

$worker->addserver('192.168.1.131',4730);

$worker->addfunction("title", "title_function");

while ($worker->work());

//consumer

function

title_function

($job)

任務排程程式 Gearman

gearman是乙個分發任務的程式框架,可以用在各種場合,與hadoop 相 比,gearman更偏向於任務分發功能。它的 任務分布非常 簡單,簡單得可以只需要用指令碼即可完成。gearman最初用於livejournal的resize功能,由於resize需要消耗大量計算資 源,因此需要排程到後端...

PHP實現非同步處理利器 Gearman

通常,多語言多系統之間的整合是個大問題,一般來說,人們多半會採用webservice的方式來處理此類整合問題,但不管採用何種風格的webservice,如rpc風格,或者rest風格,其本身都有一定的複雜性。相比之下,gearman也能實現類似的作用,而且更簡單易用。乙個gearman請求的處理過程...

Gearman安裝及使用

基礎安裝包 yum install vim wget gcc gcc c make dos2unix gperf libevent libevent devel zlib devel bzip2 devel openssl devel ncurses devel boost boost devel ...