声明:本文主要内容摘自张宴的博客http://blog.s135.com/httpsqs/
一、下载&编译&安装
注意:若在ubuntu下make和make install前别忘了加上sudo
详细步骤:
1、安装libevent
wget http://httpsqs.googlecode.com/files/libevent-1.4.13-stable.tar.gz
tar zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable/
./configure --prefix=/usr
make
make install
cd ../
2、安装键值数据库TokyoCabinet
wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.41.tar.gz
tar zxvf tokyocabinet-1.4.41.tar.gz
cd tokyocabinet-1.4.41/
./configure
#注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可以使数据库文件突破2GB的限制。
#./configure --enable-off64
make
make install
cd ../
/sbin/ldconfig
3、安装队列服务程序HTTPSQS
wget http://httpsqs.googlecode.com/files/httpsqs-1.1.tar.gz
tar zxvf httpsqs-1.1.tar.gz
cd httpsqs-1.1/
make
make install
cd ../
说明:安装TC进行configure时,可能会缺少libbz2包,需要先安装
sudo apt-get install checkinstall build-essential libbz2-dev (ubuntu下)
二、相关准备说明
查看队列服务程序帮助:
httpsqs -h
-l <ip_addr> 监听的IP地址,默认值为 0.0.0.0
-p <num> 监听的TCP端口(默认值:1218)
-x <path> 数据库目录,目录不存在会自动创建(例如:/opt/httpsqs/data)
-t <second> HTTP请求的超时时间(默认值:1)
-d 以守护进程运行
-h 显示这个帮助
使用范例:
httpsqs -d -p 1218 -x /data0/search/queue
终止进程:
请使用命令“killall httpsqs”、“pkill httpsqs”和“kill httpsqs的进程ID”来停止httpsqs。
三、使用说明
注意:无需apache等httpd服务,使用curl和浏览器即可
若shell尚未安装curl,则需sudo apt-get install curl(ubuntu下)
curl方式测试范例:
1、入队列:
【GET方式】curl "http://host:port/?name=your_queue_name&opt=put&data=经过URL编码的文本消息"
【POST方式】curl -d "经过URL编码的文本消息" "http://host:port/?name=your_queue_name&opt=put"
2、出队列
curl "http://host:port/?charset=utf-8&name=your_queue_name&opt=get"
3、查看队列状态
curl "http://host:port/?name=your_queue_name&opt=status"
4、。。。。。。
四、详细信息请参考