﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-少年阿宾-随笔分类-httpsqs</title><link>http://www.blogjava.net/stevenjohn/category/54203.html</link><description>那些青春的岁月</description><language>zh-cn</language><lastBuildDate>Mon, 03 Mar 2014 13:34:36 GMT</lastBuildDate><pubDate>Mon, 03 Mar 2014 13:34:36 GMT</pubDate><ttl>60</ttl><item><title>httpsqs 安装使用</title><link>http://www.blogjava.net/stevenjohn/archive/2014/03/01/410485.html</link><dc:creator>abin</dc:creator><author>abin</author><pubDate>Sat, 01 Mar 2014 07:26:00 GMT</pubDate><guid>http://www.blogjava.net/stevenjohn/archive/2014/03/01/410485.html</guid><wfw:comment>http://www.blogjava.net/stevenjohn/comments/410485.html</wfw:comment><comments>http://www.blogjava.net/stevenjohn/archive/2014/03/01/410485.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/stevenjohn/comments/commentRss/410485.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/stevenjohn/services/trackbacks/410485.html</trackback:ping><description><![CDATA[<div><pre>我这里使用的是Centos6.4的环境下面测试的：<br />ulimit -SHn 65535<br />安装：libevent-2.0.12-stable.tar.gz<br /><br />wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz<br />tar zxvf libevent-2.0.12-stable.tar.gz<br />cd libevent-2.0.12-stable/<br />./configure --prefix=/usr/local/libevent-2.0.12-stable/<br />make<br />make install<br />cd ../<br /><br /><span class="Apple-style-span" style="font-family: verdana, 'courier new'; white-space: normal; "><pre>安装：tokyocabinet-1.4.47.tar.gz</pre></span>wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.47.tar.gz<br />tar zxvf tokyocabinet-1.4.47.tar.gz<br />cd tokyocabinet-1.4.47/<br />./configure --prefix=/usr/local/tokyocabinet-1.4.47/<br />#Note: In the 32-bit Linux operating system, compiler Tokyo cabinet, please use the ./configure --enable-off64 instead of ./configure to breakthrough the filesize limit of 2GB.<br />#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/<br />make<br />make install<br />cd ../<br /><br />##执行上面这个tokyocabinet-1.4.47.tar.gz软件包安装的时候，对于32bit的机器，需要使用<br /><span class="Apple-style-span" style="font-family: verdana, 'courier new'; white-space: normal; "><pre>#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/</pre></span>这个命令，此外我安装的过程中，出现了这个错误提示，提示tokyocabinet-1.4.47.tar.gz安装不成功，解决办法是，安装需要的软件包就可以了.<br /><br />错误提示一：<br /><div>configure: error: zlib.h is required<code><br /><div><pre><span style="font-family:Tahoma, Arial;">解决方法是： &nbsp;</span># yum install zlib-devel</pre></div></code></div>错误提示二：<br /><div>configure: error: bzlib.h is required</div><div><span style="font-family:Tahoma, Arial;">解决方法是： &nbsp;# </span>yum install bzip2-devel</div><br />下面进入到了正式环节，上面装的两个都是为了httpsqs的安装做的前提准备：<br /><span class="Apple-style-span" style="font-family: verdana, 'courier new'; white-space: normal; "><pre>安装：httpsqs-1.7.tar.gz</pre></span>wget http://httpsqs.googlecode.com/files/httpsqs-1.7.tar.gz<br />tar zxvf httpsqs-1.7.tar.gz<br />cd httpsqs-1.7/<br />make<br />make install<br />cd ../<br /><br />至此安装已经结束：<br /><br /><div><div><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; display: inline !important; float: none; ">[root@xoyo ~]# httpsqs -h</span></div></div><div><div><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-l &lt;ip_addr&gt; 监听的IP地址，默认值为 0.0.0.0&nbsp;</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-p &lt;num&gt; 监听的TCP端口（默认值：1218）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-x &lt;path&gt; 数据库目录，目录不存在会自动创建（例如：/opt/httpsqs/data）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-t &lt;second&gt; HTTP请求的超时时间（默认值：3）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-s &lt;second&gt; 同步内存缓冲区内容到磁盘的间隔秒数（默认值：5）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-c &lt;num&gt; 内存中缓存的最大非叶子节点数（默认值：1024）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-m &lt;size&gt; 数据库内存缓存大小，单位：MB（默认值：100）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-i &lt;file&gt; 保存进程PID到文件中（默认值：/tmp/httpsqs.pid）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-a &lt;auth&gt; 访问HTTPSQS的验证密码（例如：mypass123）</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-d 以守护进程运行</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none; ">-h 显示这个帮助</span></div></div><br /><br /><div><div>[root@localhost ~]# ulimit -SHn 65535<br />[root@localhost ~]# httpsqs -d -p 1218 -x /data0/queue -a mypass123<br />[root@localhost ~]# ps -aux | grep httpsqs<br />Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ<br />root     14378  0.0  0.0 396420   500 pts/0    S    10:44   0:00 [httpsqs: master process] /usr/bin/httpsqs -d -p 1218 -x /data0/queue -a mypass123<br />root     14379  0.0  0.0 406664   716 pts/0    Sl   10:44   0:00 [httpsqs: worker process] /usr/bin/httpsqs -d -p 1218 -x /data0/queue -a mypass123<br />root     14382  0.0  0.0   4356   756 pts/0    S+   10:44   0:00 grep httpsqs<br />1、put a queue<br />[root@localhost ~]# curl "http://192.168.59.129:1218/?name=your_queue_name&amp;opt=put&amp;data=url_encoded_text_message&amp;auth=mypass123"<br />HTTPSQS_PUT_OK<br /><br />[root@localhost ~]#</div><div><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; display: inline !important; float: none; ">如果入队列成功，返回：</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; " /><div style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px; margin-left: 5px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: #00a0c6; border-right-color: #00a0c6; border-bottom-color: #00a0c6; border-left-color: #00a0c6; background-color: #ffffff; ">HTTPSQS_PUT_OK</div><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; display: inline !important; float: none; ">　　如果入队列失败，返回：</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; " /><div style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px; margin-left: 5px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: #00a0c6; border-right-color: #00a0c6; border-bottom-color: #00a0c6; border-left-color: #00a0c6; background-color: #ffffff; ">HTTPSQS_PUT_ERROR</div><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; " /><span style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; display: inline !important; float: none; ">　　如果队列已满，返回：</span><br style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eaeff0; " /><div style="color: #000000; font-family: Tahoma, Arial; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px; margin-left: 5px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: #00a0c6; border-right-color: #00a0c6; border-bottom-color: #00a0c6; border-left-color: #00a0c6; background-color: #ffffff; ">HTTPSQS_PUT_END</div></div></div>2、get a queue<br /><div>http://192.168.59.129:1218/?name=your_queue_name&amp;opt=get&amp;auth=mypass123<br /><div><pre style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; ">url_encoded_text_message</pre></div></div>3、查看队列状态：<br /><div>http://192.168.59.129:1218/?name=your_queue_name&amp;opt=status&amp;auth=mypass123</div><div><pre style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; "><div>HTTP Simple Queue Service v1.7 <br />------------------------------<br />Queue Name: your_queue_name <br />Maximum number of queues: 1000000 <br />Put position of queue (1st lap): 5 <br />Get position of queue (1st lap): 0 <br />Number of unread queue: 5</div>4、使用json格式查看队列内容<br /><br /><div>http://192.168.59.129:1218/?name=your_queue_name&amp;opt=status_json&amp;auth=mypass123</div><div><pre style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; ">{"name":"your_queue_name","maxqueue":1000000,"putpos":5,"putlap":1,"getpos":1,"getlap":1,"unread":4}</pre></div><br /><br /></pre></div>参考文档：http://blog.s135.com/httpsqs/7/1/<br /><div>http://code.google.com/p/httpsqs/</div><br /></pre></div><img src ="http://www.blogjava.net/stevenjohn/aggbug/410485.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/stevenjohn/" target="_blank">abin</a> 2014-03-01 15:26 <a href="http://www.blogjava.net/stevenjohn/archive/2014/03/01/410485.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>