日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Scribe应用实例

發(fā)布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Scribe应用实例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

源代碼里所給的example很簡單,但大體上了模擬了其運行的過程,分三個部分。可參考里面的README文件:Configurarion(配置)、Running Scribe Server(運行服務(wù)器)、Logging messages(記錄日志)

先運行Scribe example來看看效果。

1.Example1:向已經(jīng)啟動的Server發(fā)送消息,驗證是否被記錄下來。 #創(chuàng)建日志信息存放目錄:

$mkdir /tmp/scribetest

#用example1.conf配置文件啟動Scribe服務(wù):

$scribed examples/example1.conf

#開啟另一個終端,使用scribe_cat 向scribe服務(wù)發(fā)送信息:

$echo "hello world" | ./scribe_cat test

這時你很可能會出現(xiàn)如下錯誤提示:

也就是說python導(dǎo)入模塊scribe失敗,但我們打開/usr/lib/python2.6/site-packages,發(fā)現(xiàn)里面是有scribe的模塊的,所以很可能是PYTHONPATH沒有配置正確。使用如下命令進行配置: 進入到/etc目錄,然后輸入命令gedit profile(profile文件為系統(tǒng)的每個用戶設(shè)置環(huán)境信息,當(dāng)用戶第一次登錄時,該文件被執(zhí)行),在此文件中添加如下內(nèi)容:

$export PYTHONPATH= ”/usr/lib/python2.6/site-packages”
$source /etc/profile

或 找到系統(tǒng)安裝Python的路徑(如我的是/usr/local/python2.6),將/usr/lib/python2.6/site-packages下內(nèi)容拷貝到/usr/local/lib/python2.6/site-packages下即可。 #Verify that the message got logged:

$cat /tmp/scribetest/test/test_current
#檢查scribe狀態(tài)(requires root):
$./scribe_ctrl status
#檢查scribe連接數(shù) (you should see 1 message 'received good'):
$./scribe_ctrl counters
#關(guān)閉scribe服務(wù):
$./scribe_ctrl stop

2) Example2:啟動中心服務(wù)器和客戶端服務(wù)器,然后開啟一個終端并輸入三條命令,并查看結(jié)果: 示意圖如下?

執(zhí)行如下命令:

#啟動中央服務(wù)器
$scribed example2central.conf &
#啟動客戶端服務(wù)器
$scribed example2client.conf &
$mkdir /tmp/scribetest2
$scribed examples/example2central.conf
$scribed examples/example2client.conf
$echo "test message" | ./scribe_cat -h localhost:1464 test2
$echo "this message will be ignored" | ./scribe_cat -h localhost:1464 ignore_me
$echo "123:this message will be bucketed" | ./scribe_cat -h localhost:1464 bucket_me

查看結(jié)果:

$cat /tmp/scribetest/test2/test2_current
$cat /tmp/scribetest/bucket*/bucket_me_current
./scribe_ctrl status 1463
./scribe_ctrl status 1464
./scribe_ctrl counters 1463 #查看中心服務(wù)器的統(tǒng)計數(shù)據(jù)
./scribe_ctrl counters 1464 #查看客戶端服務(wù)器的統(tǒng)計數(shù)據(jù)

當(dāng)客戶端服務(wù)器講收到的信息發(fā)送給中心服務(wù)器后,會刪除本地的存儲。 結(jié)果顯示:客戶端收到三條消息,發(fā)送了三條消息;服務(wù)器端收到三條消息,忽略了一條消息。


3) Example3:如同Example2啟動中心服務(wù)器和客戶端服務(wù)器,但本例測試的是在中心服務(wù)器突然down掉的情況下,客戶端服務(wù)器的緩沖存儲功能。

$echo "test message 1" | ./scribe_cat -h localhost:1464 test3 #發(fā)送消息1
$cat /tmp/scribetest/test3/test3_current #結(jié)果:test message 1
$./scribe_ctrl stop 1463 #down掉中心服務(wù)器
$./scribe_ctrl status 1463 #結(jié)果:Failed to get status
$echo "test message 2" | ./scribe_cat -h localhost:1464 test3 #發(fā)送消息2
$./scribe_ctrl status 1464 #結(jié)果:WARNING - Failed to connect
$echo "test message 3" | ./scribe_cat -h localhost:1464 test3 #發(fā)送消息3
$scribed examples/example2central.conf #重新啟動中心服務(wù)器
$./scribe_ctrl status 1463 #結(jié)果:ALIVE
$./scribe_ctrl status 1464 #結(jié)果:ALIVE
$cat /tmp/scribetest/test3/test3_current

#結(jié)果:

test message 1
test message 2
test message 3

全部正常接收

轉(zhuǎn)載于:https://www.cnblogs.com/oubo/archive/2011/10/28/2394610.html

總結(jié)

以上是生活随笔為你收集整理的Scribe应用实例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。