Httpsqs
HTTPSQS 具有以下特征:
● 非常简单,基于 HTTP GET/POST 协议。PHP、Java、Perl、Shell、Python、Ruby等支持HTTP协议的编程语言均可调用。
● 非常快速,入队列、出队列速度超过10000次/秒。
● 高并发,支持上万的并发连接,C10K不成问题。
● 支持多队列。
● 单个队列支持的最大队列数量高达10亿条。
● 低内存消耗,海量数据存储,存储几十GB的数据只需不到100MB的物理内存缓冲区。
● 可以在不停止服务的情况下便捷地修改单个队列的最大队列数量。
● 可以实时查看队列状态(入队列位置、出队列位置、未读队列数量、最大队列数量)。
● 可以查看指定队列ID(队列点)的内容,包括未出、已出的队列内容。
● 查看队列内容时,支持多字符集编码。
● 源代码不超过800行,适合二次开发
Httpsqs 安装过程
VMware7
CentOs5.4
http://vault.centos.org/5.4/isos/i386/CentOS-5.4-i386-bin-DVD.torrent
安装 httpsqs
ulimit -SHn 65535
1、wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gztar 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
cd ../
:
2、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-off代替./configure,可以使数据库文件突破2GB的。
#./configure --enable-off --prefix=/usr/local/tokyocabinet-1.4.47/
make
make install
cd ../
这个步骤的时候缺少bzip2-1.0.6.tar.gz
3、http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz安装开始;
$wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
$tar -xvzf bzip2-1.0.6.tar.gz
$cd bzip2-1.0.6.
$make
$ make install
4、同时还缺少bzlib
http://www.winimage.com/zLibDll/zlib-1.2.5.tar.gz安装开始;
$wget http://www.winimage.com/zLibDll/zlib-1.2.5.tar.gz
$tar -xvzf zlib-1.2.5.tar.gz
$cd zlib-1.2.5.
$./configure
$make
$sudo make instal
继续第2步骤
3、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
cd ../
但是在httpsqs –h
报:
error while loading shared libraries:
/usr/local/tokyocabinet-1.4.47/lib/libtokyocabinet.so.9: cannot restore segment prot after reloc: Permission denied
从HTTPSQS目录中找到这个文件,并向/usr/lib/做了这个文件的软链接。
Cd
ln -s /usr/local/tokyocabinet-1.4.47/lib/libtokyocabinet.so.9
/usr/lib/libtokyocabinet.so.9
做了软连接 还是报错
error while loading shared libraries:
/usr/local/tokyocabinet-1.4.47/lib/libtokyocabinet.so.9: cannot restore segment prot after reloc: Permission denied
解决办法
#vi /etc/sysconfig/selinux file
修改SELINUX=disabled
重启
再来一次
httpsqs -h
--------------------------------------------------------------------------------------------------
HTTP Simple Queue Service - httpsqs v1.7 (April 14, 2011)
Author:ZhangYan(http://blog.s135.com),E-mail:************
This is free software, and you are welcome to modify and redistribute it under the New BSD License
-l -p -x -t -s -c -m -i -a -d run as a daemon -h print this help and exit Use command \"killall httpsqso stop httpsqs. Please note that don't use the command \"pkill -9 httpsqs\" and \"kill -9 PID of httpsqs\"! Please visit \"http://code.google.com/p/httpsqs\" for more help information. 安装成功!! 参考网址:http://blog.s135.com/httpsqs/ 参数设置: Httpsqs –h -l -p -x -t -s -c -m -i -a -d 以守护进程运行 -h 显示这个帮助 关闭:killall httpsqs 启动:httpsqs -d -l 192.168.3.159 -a kevin -p 1218 -x /data0/goods 以put方式插入队列: 在浏览器中输入: http://192.168.3.159:1218/?charset=utf-8&name=q&opt=put&data=21321321&auth=kevin 显示HTTPSQS_PUT_OK 说明插入队列成功 从对象中取出文本消息 在浏览器输入: 92.168.3.159:1218/?charset=utf-8&name=q&opt=get&auth=Kevin 显示:21321321 正好和插入时候的数据是一样的,说明获取成功 查看队列状态 http://192.168.3.159:1218/?charset=utf-8&name=q&opt=status&auth=kevin 显示: HTTP Simple Queue Service v1.7 ------------------------------ Queue Name: q Maximum number of queues: 1000000 Put position of queue (1st lap): 12 Get position of queue (1st lap): 12 Number of unread queue: 0 注意: 如果“队列写入点值”大于“最大队列数量值”,将重置“队列写入点”为1,即又从1开始存储新的队列内容,覆盖原来队列位置点的内容 查看队列时候以json格式返回 http://192.168.3.159:1218/?charset=utf-8&name=q&opt=status_json&auth=kevin {\"name\":\"q\1,\"unread\":0} 查看指定队列位置点的内容 http://192.168.3.159:1218/?charset=utf-8&name=q&opt=view&pos=7&auth=kevin 重置指定队列 http://192.168.3.159:1218/?charset=utf-8&name=q&opt=reset&auth=kevin 返回HTTPSQS_RESET_OK成功 更改指定队列的最大队列数量 http://92.168.3.159:1218/?name=q&opt=maxqueue&num=1000000000&auth=kevin (8)、不停止服务的情况下,修改定时刷新内存缓冲区内容到磁盘的间隔时间: 从HTTPSQS 1.3版本开始支持此功能。 默认间隔时间:5秒 或 httpsqs -s HTTP GET 协议(以curl命令为例): curl \"http://host:port/?name=your_queue_name&opt=synctime&num=10&auth=mypass123\" num >=1 and <= 1000000000 如果修改间隔时间成功,则返回: HTTPSQS_SYNCTIME_OK 如果 num 不在 1 ~ 1000000000 之间,本操作将被取消,然后返回给客户端以下信息: HTTPSQS_SYNCTIME_CANCEL (9)、密码校验失败: 从HTTPSQS 1.5版本开始支持此功能。 如果密码校验失败(/?auth=xxx),将返回以下信息: HTTPSQS_AUTH_FAILED (10)、全局错误: 如果发生全局错误(即指令、参数错误等),将返回以下信息: HTTPSQS_ERROR HTTPSQS同一个进程,支持多队列。 启动一个进程httpsqs -d -p 1218 -x /usr/local/project/httpsqs/即可。 http://x.x.x.x:1218/?name=q1&opt=put http://x.x.x.x:1218/?name=q2&opt=put 就是两个不同的队列。 1) 永久性生效,重启后不会复原 2) 开启: chkconfig iptables on 3) 关闭: chkconfig iptables off 4) 2) 即时生效,重启后复原 5) 开启: service iptables start 6) 关闭: service iptables stop 7) 需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。 8) 在开启了防火墙时,做如下设置,开启相关端口, 9) 修改/etc/sysconfig/iptables 文件,添加以下内容: 10) -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 11) -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEP 查看httpsqs进程:ps -ef | grep httpsqs | grep -v grep 查看是否被监听netstat –tanl Auth:ajun Date:2011-8-03 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- hzar.cn 版权所有 赣ICP备2024042791号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务