聲明:本文主要內容摘自張宴的部落格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、。。。。。。
四、詳細資料請參考
1、http://blog.s135.com/httpsqs/3/1/
作者部落格
2、http://code.google.com/p/httpsqs/
項目地址