读书人

scribe装配记录

发布时间: 2012-09-23 10:28:11 作者: rapoo

scribe安装记录
折腾了快2天,终于装上了,内流满面

scribe安装较复杂,官网无详细安装手册,所以自己装成功了还是记录下吧~

1.系统版本:基于CentOS-6.3-x86_64

2.gcc
安装版本为4.4.6 官方要求>=3.3.5,但低于4会有各种问题
g++ 如果g++的结果是no input files表示已安装,不是则安装:

[Wed Nov  9 10:35:52 2011] "STATUS: configuring" 
[Wed Nov 9 10:35:52 2011] "got configuration data from file <conf/example1.conf>"
[Wed Nov 9 10:35:52 2011] "CATEGORY : default"
[Wed Nov 9 10:35:52 2011] "Creating default store"
[Wed Nov 9 10:35:52 2011] "configured <1> stores"
[Wed Nov 9 10:35:52 2011] "STATUS: "
[Wed Nov 9 10:35:52 2011] "STATUS: ALIVE"
[Wed Nov 9 10:35:52 2011] "Starting scribe server on port 1463"
Thrift: Wed Nov 9 10:35:52 2011 libevent 1.4.13-stable method epoll

3、验证scribe能正常工作

examples文件夹下有Readme,按照这个操作就行,简单来说

先启动scribe:

scribe安装路径/bin/scribed -c scribe解压路径/examples/example1.conf

出现提示信息:

[Wed Dec 21 17:12:01 2011] "STATUS: STARTING"

[Wed Dec 21 17:12:01 2011] "STATUS: configuring"

[Wed Dec 21 17:12:01 2011] "got configuration data from file <conf/example1.conf>"

[Wed Dec 21 17:12:01 2011] "CATEGORY : default"

[Wed Dec 21 17:12:01 2011] "Creating default store"

[Wed Dec 21 17:12:01 2011] "configured <1> stores"

[Wed Dec 21 17:12:01 2011] "STATUS: "

[Wed Dec 21 17:12:01 2011] "STATUS: ALIVE"

[Wed Dec 21 17:12:01 2011] "Starting scribe server on port 1463"

然后在examples目录下,发个数据给scribe

echo "hello world" | ./scribe_cat test

发现scribe出现提示信息:


[Wed Dec 21 17:14:30 2011] "[test] Creating new category store from model default"

[Wed Dec 21 17:14:30 2011] "store thread starting"

[Wed Dec 21 17:14:30 2011] "[test] Opened file </tmp/scribetest/test/test_00000> for writing"

[Wed Dec 21 17:14:30 2011] "[test] Opened file </tmp/test/test_00000> for writing"

[Wed Dec 21 17:14:30 2011] "[test] Changing state from <DISCONNECTED> to <SENDING_BUFFER>"

[Wed Dec 21 17:14:30 2011] "[test] read <0> entries of <0> bytes from file </tmp/test/test_00000>"

[Wed Dec 21 17:14:30 2011] "[test] No more buffer files to send, switching to streaming mode"

[Wed Dec 21 17:14:30 2011] "[test] Changing state from <SENDING_BUFFER> to <STREAMING>"


查看log

cat /tmp/scribetest/test/test_00000

出现:

hello world

表示安装成功。


4、用rb验证scribe能正常工作(这一步并不是必须的。3验证成功后scribe就已经正常工作了。)

cd /usr/local/scribe

mkdir testapp

cd testapp

/usr/local/bin/thrift -o . -I /usr/local/share/ --gen rb /opt/apps_install/scribe/facebook-scribe-6600084/if/scribe.thrift
/usr/local/bin/thrift -o . -I /usr/local/share/ --gen rb /usr/local/share/fb303/if/fb303.thrift

mv get_rb scribe

此时/usr/local/scribe/testapp/scribe下有6个文件

-rw-r--r-- 1 root root 15879 Nov 9 10:17 facebook_service.rb
-rw-r--r-- 1 root root 140 Nov 9 10:17 fb303_constants.rb
-rw-r--r-- 1 root root 414 Nov 9 10:17 fb303_types.rb
-rw-r--r-- 1 root root 141 Nov 9 10:17 scribe_constants.rb
-rw-r--r-- 1 root root 1943 Nov 9 10:17 scribe.rb
-rw-r--r-- 1 root root 643 Nov 9 10:17 scribe_types.rb


然后再testapp中新建一个test.rb文件,内容是

#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/scribe')
require 'scribe'

begin
socket = Thrift::Socket.new('localhost', 1463)
transport = Thrift::FramedTransport.new(socket)
protocol = Thrift::BinaryProtocol.new(transport, false)
client = Scribe::Client.new(protocol)
transport.open()
log_entry = LogEntry.new(:category => 'test', :message => 'This is a test message')
client.Log([log_entry])
transport.close()
rescue Thrift::Exception => tx
print 'Thrift::Exception: ', tx.message, "\n"
end
修改test.rb的执行权限,chmod +x test.rb
执行test.rb,./test.rb
scribe出现提示信息:
[Wed Nov 9 10:35:58 2011] "[test] Creating new category store from model default"
[Wed Nov 9 10:35:58 2011] "store thread starting"
[Wed Nov 9 10:35:58 2011] "[test] Opened file </tmp/scribetest/test/test_00000> for writing"
[Wed Nov 9 10:35:58 2011] "[test] Opened file </tmp/test/test_00000> for writing"
[Wed Nov 9 10:35:58 2011] "[test] Changing state from <DISCONNECTED> to <SENDING_BUFFER>"
[Wed Nov 9 10:35:58 2011] "[test] read <0> entries of <0> bytes from file </tmp/test/test_00000>"
[Wed Nov 9 10:35:58 2011] "[test] No more buffer files to send, switching to streaming mode"
[Wed Nov 9 10:35:58 2011] "[test] Changing state from <SENDING_BUFFER> to <STREAMING>"

查看/tmp/scribetest/test/test_00000,它的内容是:
This is a test message
表示scribe工作正常啦~~


对这位博主表示无与伦比的感谢:
http://abentotoro.blog.sohu.com/190515962.html


读书人网 >开源软件

热点推荐