MemcacheQ 是基于 MemcacheDB 的消息队列服务器。
一.memcacheq介绍
复制代码代码如下:
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) 六.常见错误:
复制代码代码如下:
./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>
(责任编辑:IT)<put your message body here> STORED get <queue name> VALUE <queue name> <flags> <message_len> <your message body will come here> END # 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 |