持久化消息队列memcacheq的安装配置

持久化消息队列memcacheq的安装配置 原文地址:http://www.ttlsa.com/archives/229
一.memcacheq介绍
特性:
1.简单易用
2.处理速度快
3.多条队列
4.并发性能好
5.与memcache的协议兼容
6.在zend framework中使用方便

memcacheq依赖于Berkeley DB和libevent。Berkeley DB用于持久化存储队列的数据,避免在memcacheq崩溃或这服务器当掉时候,不至于数据丢失。

二.安装Berkeley DB
download url: http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html
# tar zxvf db-5.2.28.tar.gz -C ../software/
# cd ../software/db-5.2.28/
# cd  build_unix/
# ../dist/configure --prefix=/usr/local/db-5.2.28
# make
# make install

三.安装libevent
# wget http://monkey.org/~provos/libevent-2.0.12-stable.tar.gz
# tar zxvf libevent-2.0.12-stable.tar.gz -C ../software/
# cd ../software/libevent-2.0.12-stable/
# ./configure --prefix=/usr/local/libevent-2.0.12
# make
# make install

四.安装memcacheq
# wget http://memcacheq.googlecode.com/files/memcacheq-0.2.0.tar.gz
# tar zxvf memcacheq-0.2.0.tar.gz -C ../software/
# cd ../software/memcacheq-0.2.0/
# ./configure --prefix=/usr/local/memcacheq-0.2.0 --with-libevent=/usr/local/libevent-2.0.12 --with-bdb=/usr/local/db-5.2.28 --enable-threads
# make
# make install

五.启动memcacheq
# chown nobody:root /memdata
# ./memcacheq -d -r -u nobody -vv -t 4 -m 64 -H /memdata -N -R > /var/log/memq.log 2>&1

-p <num>      TCP监听端口(default: 22201)
-U <num>      UDP监听端口(default: 0, off)
-s <file>     unix socket路径(不支持网络)
-a <mask>     unix socket访问掩码(default 0700)
-l <ip_addr>  监听网卡
-d            守护进程
-r            最大化核心文件限制
-u <username> 以用户身份运行(only when run as root)
-c <num>      最大并发连接数(default is 1024)
-v            详细输出 (print errors/warnings while in event loop)
-vv           更详细的输出 (also print client commands/reponses)
-i            打印许可证信息
-P <file>     PID文件
-t <num>      线程数(default 4)
--------------------BerkeleyDB Options-------------------------------
-m <num>      BerkeleyDB内存缓存大小, default is 64MB
-A <num>      底层页面大小, default is 4096, (512B ~ 64KB, power-of-two)
-H <dir>      数据库家目录, default is '/data1/memcacheq'
-L <num>      日志缓冲区大小, default is 32KB
-C <num>      多少秒checkpoint一次, 0 for disable, default is 5 minutes
-T <num>      多少秒memp_trickle一次, 0 for disable, default is 30 seconds
-S <num>      多少秒queue stats dump一次, 0 for disable, default is 30 seconds
-e <num>      达到缓存百分之多少需要刷新, default is 60%
-E <num>      一个单一的DB文件有多少页, default is 16*1024, 0 for disable
-B <num>      指定消息体的长度,单位字节, default is 1024
-D <num>      多少毫秒做一次死锁检测(deadlock detecting), 0 for disable, default is 100ms
-N            开启DB_TXN_NOSYNC获得巨大的性能改善, default is off
-R            自动删除不再需要的日志文件, default is off


六.常见错误:
./memcacheq: error while loading shared libraries: libdb-5.2.so: cannot open shared object file: No such file or directory
./memcacheq: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
解决办法:
# cd /etc/ld.so.conf.d/
# vim berkeley-db.conf
/usr/local/db-5.2.28/lib
# vim libevent.conf
/usr/local/libevent-2.0.12/lib
# ldconfig

七.测试
set <queue name> <flags> 0 <message_len>\r\n
<put your message body here>\r\n
STORED\r\n

get <queue name>\r\n
VALUE <queue name> <flags> <message_len>\r\n
<your message body will come here>\r\n
END\r\n

# telnet 127.0.0.1 22201
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set queue1 0 0 2
xu
STORED
set queue1 0 0 4
hong
STORED
set queue1 0 0 2
hu
STORED
stats queue
STAT queue1 3/0  //队列queue1中共有3条消息已取出0条
END
get queue1
VALUE queue1 0 2
xu
END
stats queue
STAT queue1 3/1  //队列queue1中共有3条消息已取出1条
END
delete queue1  //删除队列queue1
DELETED
stats queue
END

持久化消息队列memcacheq的安装配置 原文地址:http://www.ttlsa.com/archives/229

你可能感兴趣的:(oracle,mysql,ubuntu,NoSQL,memcacheq)