HTTPSQS(HTTP Simple Queue Service)是一款基於 HTTP GET/POST 協議的輕量級開源簡單消息隊列服務,使用 Tokyo Cabinet 的 B+Tree Key/Value 數據庫來作數據的持久化存儲。數據庫
1.安裝libevent-2.0.12-stable.tar.gz
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
cd ../vim
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,可tcp
以使數據庫文件突破2GB的限制。
#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/
make
make install
cd ../
當執行第二步驟的會出錯,是因爲缺乏zlib和bzip2
安裝zlib和bzip2 注意 是有順序的:
1) zlib安裝:
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前,修改Makefilegoogle
CC=gcc -fPICspa
CFLAGS=-O3 -fPIC -D_LARGEFILE64_SOURCE=1
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
記得make前或者configure前,先進行make clean,或者將以前指定的目錄prefix參數中的內容所有rm掉,比較完全和暴力
】操作系統
make
sudo make instal
2) bzip2安裝:
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.6prototype
【同上,修改Makefile,rest
# To assist in cross-compiling
CC=gcc -fPIC
AR=ar
RANLIB=ranlib
LDFLAGS=code
BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-Wall -Winline -O2 -fPIC -g $(BIGFILES)
】
make
make instal
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
cd ../
4.測試
若是安裝成功 執行httpsqs –h 會出現
------------------------------------------------------------------------------------------------
--
HTTP Simple Queue Service - httpsqs v1.7 (April 14, 2011)
........................
5.設置
存儲目錄
#mkdir /usr/local/httpsqs_queue
mkdir /home/bf
vi /home/bf/httpsqs.sh
內容以下:
#! /bin/sh
ulimit -SHn 65535
啓動方法
帶密碼
# /usr/bin/httpsqs -d -p 1218 -t 10 -c 10000 -m 512 -x /usr/local/httpsqs_queue -a pwd123
無密碼
# /usr/bin/httpsqs -d -p 1218 -t 10 -c 10000 -m 512 -x /usr/local/httpsqs_queue
幹掉的方法
# killall httpsqs
注意須要打開防火牆端口
vim /etc/sysconfig/iptables
添加下面一行,打開防火牆1218端口:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1218 -j ACCEPT
重啓防火牆
#/etc/init.d/iptables restart
6.使用
寫隊列
http://192.168.2.103:1218/?name=your_queue_name&opt=put&data=TEXT&auth=pwd123
讀隊列
http://192.168.2.103:1218/?charset=utf-8&name=your_queue_name&opt=get&auth=pwd123
寫隊列無密碼
http://192.168.2.103:1218/?name=your_queue_name&opt=put&data=TEXT
讀隊列無密碼
http://192.168.2.103:1218/?charset=utf-8&name=your_queue_name&opt=get