**百度介绍:**
---------
HTTPSQS(HTTP Simple Queue Service)是一款基于 HTTP GET/POST 协议的轻量级开源简单消息队列服务, 使用 Tokyo Cabinet 的 B+Tree Key/Value 数据库来做数据的持久化存储。
http://www.linuxidc.com/Linux/2013-12/93871.htm
http://www.07net01.com/linux/HTTPSQSdeanzhuangheshiyong_13035_1346631280.html
一、安装过程
1、下载libevent-2.0.12-stable,并编译安装
wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz
tar zxvf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable/
./configure --prefix=/usr/local/libevent-2.0.12-stable/
make
make install
2、下载tokyocabinet-1.4.47.tar.gz,并编译安装
wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.47.tar.gz
tar zxvf tokyocabinet-1.4.47.tar.gz
cd tokyocabinet-1.4.47/
./configure --prefix=/usr/local/tokyocabinet-1.4.47/
#注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可以使数据库文件突破2GB的限制。
#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/
make
make install
3、下载httpsqs-1.7.tar.gz,并编译安装
wget http://httpsqs.googlecode.com/files/httpsqs-1.7.tar.gz
tar zxvf httpsqs-1.7.tar.gz
cd httpsqs-1.7/
make
make install
二、安装过程中出现的相关问题
1、编译httpsqs时候出现event.h文件,解决方法:
yum install libevent libevent-devel
三、启动httsqs服务,并加入到/etc/rc.local中:
vim /etc/rc.local
添加如下内容:
httpsqs -d -p 1218 -x /opt/httpsqs/data
启动 httpsqs:
ulimit -SHn 65535
httpsqs -d -p 1218 -x /data0/queue
启动:
httpsqs -d -p 1218 -x /opt/httpsqs/queue
httpsqs -d -p 1219 -x /opt/httpsqs/queue2
httpsqs -d -p 1220 -x /opt/httpsqs/queue3
httpsqs -d -p 1221 -x /opt/httpsqs/queue4
http://118.192.93.18:1219/?name=queue2&opt=put&data=123
停止:
kill `cat /tmp/httpsqs.pid`
经常需要Kill多个进程,这些进程包含共同的关键字,可以用一条命令Kill掉它们。
ps aux | grep "common" | cut –c 9-15 | xargs kill –9
管道符“|”用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。下面说说用管道符联接起来的几个命令:
"ps aux" 查看所有进程的命令。这时检索出的进程将作为下一条命令grep "common"的输入。
"grep "common" 选出所有含有关键字"common"的进程。
"cut -c 9-15" 截取输入行的第9个字符到第15个字符,而这正好是进程号PID。
"xargs kill –9" 中的xargs命令是用来把前面命令的输出结果(PID)作为"kill –9"命令的参数,并执行该命令。"kill –9" 会强行杀掉指定进程。
四、测试(查看是否安装成功)
在浏览器中执行如下操作:
http://localhost:1218/?name=test&opt=put&data=测试 --向队列中添加一条数据
http://localhost:1218/?name=test&opt=status --查看队列的状态
http://localhost:1218/?name=test&opt=get --从队列中获取一条数据
相关阅读:
Fedora安装HTTPSQS所遇各种问题解决汇总 http://www.linuxidc.com/Linux/2011-04/35164.htm
Httpsqs的安装以及安装过程错误的解决方法 http://www.linuxidc.com/Linux/2011-08/39902.htm
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14
**
部署
--
**
主机:
httpsqs.linuxlearn.net
端口:
1218
访问权限
在我们所有免费主机上都可以访问。不属于我们免费主机的机器上无法访问。
**
示例:
---
**
通过HTTP方式调用,下面以Linux的curl命令为例,介绍如何操作httpsqs:
入队列(将文本消息放入队列):
curl "http://118.192.93.18:1218/?name=test&opt=put&data=testdata"
curl "http://127.0.0.1:1218/?name=test&opt=put&data=testdata"
出队列(从队列中取出文本消息):
curl "http://118.192.93.18:1218/?charset=utf-8&name=test&opt=get"
curl "http://127.0.0.1:1218/?charset=utf-8&name=test&opt=get"
查看队列状态
curl "http://118.192.93.18:1218/?name=test&opt=status"
curl "http://118.192.93.18:1218/?name=test&opt=status_json"
curl "http://127.0.0.1:1218/?name=test&opt=status_json"
查看指定队列位置点的内容
curl "http://118.192.93.18:1218/?name=test&opt=view&pos=1"
重置指定队列
curl "http://118.192.93.18:1218/?name=test&opt=reset"
httpsqs(quequ)队列部署以及简单使用
最新推荐文章于 2021-03-11 05:51:40 发布