gearmand 持久化队列

1、使用yum安装libdrizzle

sudo yum install libdrizzle libdrizzle-devel

2、安装gearman0.14

wget --no-check-certificate https://launchpad.net/gearmand/trunk/0.14/+download/gearmand-0.14.tar.gz
tar xzvf gearmand-0.14.tar.gz
cd gearmand-0.14
./configure --disable-libmemcached --disable-libsqlite3
Configuration summary for gearmand version 0.14
 
   * Installation prefix:       /usr/local
   * System type:               unknown-linux-gnu
   * Host CPU:                  x86_64
   * C Compiler:                gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)
   * Assertions enabled:        yes
   * Debug enabled:             no
   * Warnings as failure:       no
   * Building with libsqlite3   no
   * Building with libdrizzle   yes
   * Building with libmemcached no
   * Building with libpq        no
   * Building with tokyocabinet no

3、在mysql中为gearman添加用户以及数据库

create database gearmand;
create table `gearman_queue` (
`unique_key` varchar(64) NOT NULL,
`function_name` varchar(255) NOT NULL,
`priority` int(11) NOT NULL,
`data` LONGBLOB NOT NULL,
`when_to_run` INT, PRIMARY KEY  (`unique_key`)
);
CREATE USER 'wb-liqiu'@'%';
GRANT USAGE ON * . * TO  'wb-liqiu'@'%' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS  `gearmand` ;
grant insert,update,delete,create,select on gearmand.* to 'wb-liqiu';

4、注意mysql没有密码

5、启动程序

/usr/local/sbin/gearmand -d -p 4730 -q libdrizzle --libdrizzle-mysql --libdrizzle-host=vkvm160141.sqa.cm6 --libdrizzle-port=3306 --libdrizzle-user='wb-liqiu' --libdrizzle-db=gearmand --libdrizzle-table=gearman_queue -vvv

 INFO Initializing libdrizzle module
[wb-liqiu@vkvm160132.sqa.cm6 ~]$  INFO libdrizzle module using table 'gearmand.gearman_queue'
 INFO Starting up
 INFO Listening on 0.0.0.0:4730 (7)
ERROR Failed to listen on :::4730
 INFO Creating wakeup pipe
 INFO Creating IO thread wakeup pipe
 INFO libdrizzle replay start
 INFO Adding event for listening socket (7)
 INFO Adding event for wakeup pipe
 INFO Entering main event loop
 INFO Accepted connection from 10.235.160.137:10307
 INFO [   0]  10.235.160.137:10307 Connected


gearman启动程序
gearman-server.sh
#! /bin/sh
#
# gearman conf
#
GM_USER=root
GM_PORT=4730
 
#
# mysql conf
#
MY_HOST=127.0.0.1
MY_PORT=3306
MY_USER=gearmand
MY_DB=gearmand
MY_TABLE=queue
 
/usr/local/sbin/gearmand -d -u $GM_USER -p $GM_PORT -q libdrizzle \
--libdrizzle-mysql --libdrizzle-host=$MY_HOST \
--libdrizzle-port=$MY_PORT --libdrizzle-user=$MY_USER \
--libdrizzle-db=$MY_DB --libdrizzle-table=$MY_TABLE \

* 特别要注意drizzle的路径和boost升级

摘自:http://wiki.hourui.de/linux/centos/gearmand

 

*特别提醒,使用sqlite更加简单方便 gearmand -q libsqlite3 --libsqlite3-db=main --libsqlite3-table=gearman_queue -d -vvv

6、搞定

posted @ 2012-11-12 12:31  李秋  阅读(543)  评论(0编辑  收藏  举报