參考文章http://gearman.org/getting-started/,進行以下操作。
1.更新
sudo apt-get update
下載gearmand-1.1.16.tar.gz ,地址: https://github.com/gearman/gearmand/releases
tar zxvf gearmand-1.1.16.tar.gz
cd gearmand-1.1.16/
./configure
configure: error: could not find boost
sudo apt-get install libboost-dev
接着重新執行:./configure
configure: error: Could not find a version of the library!
sudo apt-get install libboost-all-dev
接着重新執行:./configure
configure: error: could not find gperf
sudo apt-get install gperf*
接着重新執行:./configure
configure: error: Unable to find libevent
sudo apt-get install libevent-dev
接着重新執行:./configure
configure: error: Unable to find libuuid
安裝libuuid
這裏不能通過 sudo apt-get install 來安裝了,找不到,通過下面方式安裝
wget http://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz
sudo tar zxvf libuuid-1.0.3.tar.gz
cd libuuid-1.0.3/
./configure
sudo make
sudo make install
接下來繼續上面的gearmand-1.1.16安裝
./configure
sudo make
sudo make install
這裏要等一段時間。。
//------------------------------------------------------------
沒有錯誤,繼續
gearman
第一次運行會看到以下提示:
gearman: error while loading shared libraries: libgearman.so.8: cannot open shared object file: No such file or directory
(這表示系統不知道libgearman.so.8 放在哪個目錄下。 要在/etc/ld.so.conf中加入libgearman.so.8所在的目錄。 檢查了下,文件所在目錄爲/usr/local/lib。 因此出現這個問題的原因是libgearman.so.8剛生成,沒有加入到ld.so.cache中,所以這時需要重新運行一下 /sbin/ldconfig( ldconfig命令的作用):)
sudo /sbin/ldconfig
此時再執行 gearman 則已安裝成功!
安裝完Job Server之後,用gearmand –d命令啓動
gearmand -d
第一次運行會看到以下提示:
gearmand: Could not open log file "/usr/local/var/log/gearmand.log", from "/home/wangyulu/下載/gearmand-1.1.12", switching to stderr. (No such file or directory)
在提示的目錄下創建好/log/gearmand.log文件,再次執行上述命令,就正常啓動了job server。
sudo gearmand -d
到這裏就已經完全ok了
//------------------------------------------------------------
安裝PHP Gearman擴展
wget http://pecl.php.net/get/gearman-1.1.2.tgz
sudo tar zxvf gearman-1.1.2.tgz
cd gearman-1.1.2/
sudo phpize
sudo ./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install
sudo echo "extension=gearman.so" >> /usr/local/php/etc/php.ini (注意這裏php.ini位置)
sudo /usr/local/apache/bin/apachectl restart
這時查看php_info時就應該看到 gearman擴展了
php --info |grep gearman
Calabash+Gearman實現多手機同步測試機制 http://www.linuxidc.com/Linux/2015-01/111587.htm
分佈式的任務分發框架-Gearman http://www.linuxidc.com/Linux/2015-01/111385.htm
使用supervisor監控Gearman任務的例子見:http://www.linuxidc.com/Linux/2015-01/111384.htm
通過Gearman實現MySQL到Redis的數據同步(異步複製) http://www.linuxidc.com/Linux/2015-01/111380.htm
本文永久更新鏈接地址:http://www.linuxidc.com/Linux/2016-03/129348.htm