您好,欢迎访问一九零五行业门户网

Ubuntu gearman 搭建 - wangyulu

近阶段一直在查看项目里所使用到的一些技术点,发现了gearman,于是就动手搞了下环境,下面是来自百度百科关于gearman的介绍:
gearman是一个用来把工作委派给其他机器、分布式的调用更适合做某项工作的机器、并发的做某项工作在多个调用间做负载均衡、或用来在调用其它语言的函数的系统。
可用于sso 分发连接,但有弊端就是占用系统资源较多,例如cpu、内存。
1.更新
sudo apt-get update
wgethttps://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
tarzxvf gearmand-1.1.12.tar.gz
cdgearmand-1.1.12/
./configure
configure:error: could not find boost
sudoapt-get install libboost-dev
接着重新执行:./configure
configure:error: could not find a version of the library!
sudoapt-get install libboost-all-dev
接着重新执行:./configure
configure:error: could not find gperf
sudoapt-get install gperf*
接着重新执行:./configure
configure:error: unable to find libevent
sudoapt-get install libevent-dev
接着重新执行:./configure
configure:error: unable to find libuuid
安装libuuid
这里不能通过sudoapt-get install 来安装了,找不到,通过下面方式安装
wgethttp://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz
sudotar zxvf libuuid-1.0.3.tar.gz
cdlibuuid-1.0.3/
./configure
没有错误的情况下继续
sudomake
sudomake install
接下来继续上面的安装
./configure
sudomake && make install
这里要等一段时间。。
根据上图运行结果来看并没安装成功,继续往下
sudomake clean (清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。)
重新安装
./configure
sudomake
sudomake install
貌似没有错误,继续
gearman
第一次运行会看到以下提示:
gearman:error while loading shared libraries: libgearman.so.8: cannot openshared 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则已安装成功!
安装完jobserver之后,用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文件,再次执行上述命令,就正常启动了jobserver。
sudogearmand -d
到这里就已经完全ok了
安装phpgearman扩展
wgethttp://pecl.php.net/get/gearman-1.1.2.tgz
sudotar zxvf gearman-1.1.2.tgz
cdgearman-1.1.2/
sudophpize (这里可能会提示没有此命令,执行sudoapt-get install php5-dev 安装)
sudo./configure
sudomake
sudomake install
sudoecho extension=gearman.so >>/etc/php5/apache2/php.ini (注意这里php.ini位置)
sudo/etc/init.d/apache2 restart
这时查看php_info时就应该看到gearman扩展了
代码完成:
https://gist.github.com/andreaspag/6242671/archive/a66d18d191b880c1f8210deb612eb51b185f0892.zip
解压后把里面的文件复制到相应目录即可,如我是在用netbeans开发,我会把它放在 
/usr/local/netbeans-8.1/php/phpstubs/phpruntime 这个目录里;
以下是安装job server时的部分截图
php gearman 扩展
其它类似信息

推荐信息