gearman学习笔记
<?php
搭建描述:
. 在实际使用时应该是运行gearmand -d 的 server 一台. [要装gearmand,运行gearmand] . 处理worker的机器若干[要装gearmand 及php.so但gearmand不需要运行]. . 下达任务client若干[要装gearmand 及php.so但gearmand不需要运行]. . worker 与 client 不会直接通信,都是通过gearmand分发处理的. 上面是一个同步请求的例子,其实gearman可以异步处理,把client端里的代码 do函数 换成 doBackground函数就可以了. 第一步:安装
wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz 遇到错误 : gearman configure: error: could not find boost
yum install -y boost boost-devel
yum install -y gperf rperf-devel
yum install -y libuuid libuuid-devel tar -zxvf gearmand-1.1..tar.gz
./configure -- `configure' configures gearmand 1.1.12 to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. 见下文描述的一些有用的变量 在括号中指定选项的默认值。 Configuration:
-h, --help 显示这个帮助并退出
--help=short 特定于这个包显示选项
--help=recursive 显示所有包含包的短期帮助
-V, --version 显示版本信息并退出
-q, --quiet, --silent 不打印“检查…的消息
--cache-file=FILE 缓存中测试结果文件(禁用)
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create 不创建输出文件
--srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX] By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/gearmand]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR] Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD] Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--disable-libdrizzle Build with libdrizzle support [default=on]
--enable-dtrace Build with support for the DTRACE. [default=no]
--disable-libpq Build with libpq, ie Postgres, support [default=on]
--disable-libtokyocabinet
Build with libtokyocabinet support [default=on]
--disable-hiredis Build with hiredis support [default=on]
--enable-cyassl Enable ssl support for Gearman [default=yes]
--enable-ssl Enable ssl support for Gearman [default=no]
--disable-libmemcached Build with libmemcached support [default=on]
--enable-jobserver[=no/yes/#] default=yes
Enable up to # make jobs
yes: enable one more than CPU count --enable-debug Add debug code/turns off optimizations (yes|no)
[default=no]
--enable-assert Enable assert, this will be overridden by
--enable-debug (yes|no) [default=no] Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
--with-boost[=ARG] use Boost library from a standard location
(ARG=yes), from the specified location (ARG=<path>),
or disable it (ARG=no) [ARG=yes]
--with-boost-libdir=LIB_DIR
Force given directory for boost libraries. Note that
this will override library path detection, so use
this parameter only if default library detection
fails and you know exactly where your boost
libraries are located.
--with-boost-program-options[=special-lib]
use the program options library from boost - it is
possible to specify a certain library for the linker
e.g.
--with-boost-program-options=boost_program_options-gcc-mt-1_33_1
--with-mysql=[ARG] use MySQL client library [default=yes], optionally
specify path to mysql_config
--with-curl-prefix=PREFIX
Prefix where curl is installed (optional)
--with-curl-exec-prefix=EPREFIX
Exec prefix where curl is installed (optional)
--with-drizzled=[PATH]
absolute path to drizzled executable
--with-sqlite3=[ARG] use SQLite library [default=yes], optionally
specify the prefix for sqlite3 library
--with-postgresql=[ARG] use PostgreSQL library [default=yes], optionally
specify path to pg_config
--with-memcached=[PATH]
absolute path to memcached executable
--with-sphinx-build=[PATH]
absolute path to sphinx-build executable
--with-lcov=[PATH] absolute path to lcov executable
--with-genhtml=[PATH] absolute path to genhtml executable
--with-openssl=DIR root of the OpenSSL directory
--with-sanitize Enable sanitize flag for compiler if it supports
them [default=no] 影响安装的环境变量区 :
CC C编译器的命令
CFLAGS C编译器标志
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPP C preprocessor
CXXCPP C++ preprocessor
MYSQL_CONFIG
Full path to mysql_config program
CURL_CONFIG config script used for curl
CURL_CFLAGS CFLAGS used for curl
CURL_LIBS LIBS used for curl
LIBCURL_CPPFLAGS
C preprocessor flags for LIBCURL headers
LIBCURL_LDFLAGS
linker flags for LIBCURL libraries
DRIZZLED_BINARY
Absolute path to drizzled executable
LIBDRIZZLE_CPPFLAGS
C preprocessor flags for LIBDRIZZLE headers
LIBDRIZZLE_LDFLAGS
linker flags for LIBDRIZZLE libraries
TOKYOCABINET_CPPFLAGS
C preprocessor flags for TOKYOCABINET headers
TOKYOCABINET_LDFLAGS
linker flags for TOKYOCABINET libraries
HIREDIS_CPPFLAGS
C preprocessor flags for HIREDIS headers
HIREDIS_LDFLAGS
linker flags for HIREDIS libraries
MEMCACHED_BINARY
Absolute path to memcached executable
SPHINXBUILD Absolute path to sphinx-build executable
LCOV Absolute path to lcov executable
LCOV_GENHTML
Absolute path to genhtml executable
CYASSL_CPPFLAGS
C preprocessor flags for CYASSL headers
CYASSL_LDFLAGS
linker flags for CYASSL libraries
MCHECK_CPPFLAGS
C preprocessor flags for MCHECK headers
MCHECK_LDFLAGS
linker flags for MCHECK libraries 192.168.137.111 job 服务启动
/usr/sbin/gearmand -d --pid-file=/var/run/gearman/gearmand.pid --user=gearman --daemon --log-file=/var/log/gearman-job-server/gearman.log --listen=127.0.0.1 [root@www gearmand]# /usr/local/gearmand/sbin/gearmand -h Allowed options: Allowed options: General options:
-b [ --backlog ] arg (=) Number of backlog connections for listen.
-d [ --daemon ] Daemon,detach and run in the background. --exceptions Enable protocol exceptions by default.
-f [ --file-descriptors ] arg Number of file descriptors to allow for the process (total connections will be slightly less).
Default is max allowed for user. -h [ --help ] Print this help menu.
-j [ --job-retries ] arg (=) Number of attempts to run the job before the job server removes it.
This is helpful to ensure a bad job does not crash all available workers. Default is no limit. 192.168.137.222
[root@www php]# cat worderOne.php
<?php
$worker=new GearmanWorker();
$worker->addServer("192.168.137.111",); //连接到Job server 上
$worker->addFunction("reverse","my_reverse_function");
while ($worker->work()); function my_reverse_function($job)
{
return strrev($job->workload())." worker---1--";
} 192.168.137.222
[root@www php]# cat worderTwo.php
<?php
$worker=new GearmanWorker();
$worker->addServer("192.168.137.111",); //连接到Job server 上
$worker->addFunction("reverse","my_reverse_function");
while ($worker->work()); function my_reverse_function($job)
{
return strrev($job->workload())." worker---2--Two";
} 192.168.137.111
[root@www php]# cat client.php
<?php
$client=new GearmanClient();
$client->addServer("192.168.137.111",); //连接到Job server上 echo $client->doNormal("reverse","Hello World!"); openresty 版本
https://github.com/zhhchen/lua-resty-gearman
gearman学习笔记的更多相关文章
- gearman学习笔记1
1.简介 gearman是一个分布式开发框架,适合处理一些必须处理但是不影响主流程的操作,比如保存日志.发送邮件.缩略图片等.最早是基于perl语言的,2008年发布的时候改为C++语言开 ...
- 【Gearman学习笔记】分布式处理入门
1.首先,确保你已经安装了gearmand环境并且语言绑定(language binding)已经生效. 2.涉及到的各个部分: ServerThe server, gearmand, will co ...
- js学习笔记:webpack基础入门(一)
之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...
- PHP-自定义模板-学习笔记
1. 开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2. 整体架构图 ...
- PHP-会员登录与注册例子解析-学习笔记
1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...
- 2014年暑假c#学习笔记目录
2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...
- JAVA GUI编程学习笔记目录
2014年暑假JAVA GUI编程学习笔记目录 1.JAVA之GUI编程概述 2.JAVA之GUI编程布局 3.JAVA之GUI编程Frame窗口 4.JAVA之GUI编程事件监听机制 5.JAVA之 ...
- seaJs学习笔记2 – seaJs组建库的使用
原文地址:seaJs学习笔记2 – seaJs组建库的使用 我觉得学习新东西并不是会使用它就够了的,会使用仅仅代表你看懂了,理解了,二不代表你深入了,彻悟了它的精髓. 所以不断的学习将是源源不断. 最 ...
- CSS学习笔记
CSS学习笔记 2016年12月15日整理 CSS基础 Chapter1 在console输入escape("宋体") ENTER 就会出现unicode编码 显示"%u ...
随机推荐
- 生成Word/ATU报表提示 font family not found
1.先从你本机 C:\Windows\Fonts 拷贝或者网络上下载你想要安装的字体文件(*.ttf文件)到 /usr/share/fonts/chinese/TrueType 目录下(如果系统中没有 ...
- iframe 同域下父子页面的通信
//共同引用的JS文件 common.js ; (function (window, $) { $(function ($) { window.trip = window.trip || {}; wi ...
- FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑
FFmpeg_Tutorial FFmpeg工具和sdk库的使用demo 一.使用FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑 1.基本介绍 对于每一个从事音视频技术开发的工程师,想必没 ...
- Elasticsearch零停机时间更新索引配置或迁移索引
本文介绍Elasticsearch零宕机时间更新索引配置映射内容的方法,包括字段类型.分词器.分片数等.方法原理就是,利用别名机制,给索引配置别名,所有应用程序都通过别名访问索引.重建索引,通过索引原 ...
- 读书笔记--C陷阱与缺陷(四)
第四章 1. 连接器 C语言的一个重要思想就是分别编译:若干个源程序可在不同的时候单独进行编译,恰当的时候整合到一起. 连接器一般与C编译器分离,其输入是一组目标模块(编译后的模块)和库文件,输出是一 ...
- SQL SERVER 比较两个数据库中表和字段的差异
在开发过程中线上的数据库表字段和本地数据库表字段是存在的,也许我们在本地数据库中所增加的表字段都会有记录到SQL文件中,但当增加的表及字段名称较多时总会出现漏网之鱼,发布真是版本的时候回出现很多很多的 ...
- 函数fgets和fputs、fread和fwrite用法小结(转)
字符串读写函数fgets和fputs: 1.fgets()函数:原型char *fgets(char *s, int n, FILE *stream);从流中读取n-1(n默认1024)个字符之前,如 ...
- 利用Octopress在github pages上搭建个人博客
利用Octopress在github pages上搭建个人博客 SEP 29TH, 2013 在GitHub Pages上用Octopress搭建博客,需要安装ruby环境.git环境等.本人在Fed ...
- HTML5元素2
用于分组的元素 元素 说明 类型 HTML5与其他的变化 blockquote 表示引自他处的大段内容 流 无变化 dd 用在dl元素之中,表示定义 无 无变化 div 一个没有任何既定语义的通用元素 ...
- pyspider 在ubuntu上安装失败怎么搞?
pyspider 是一个非常不错的爬虫框架,在ubuntu上安装时报错误: 很明显pycurl的问题,pycurl没安装成功 pycurl 安装错误解决办法: sudo apt-get install ...