scribe就不用介绍了,网上很多资料,下面文档很方便ubuntu+scribe安装,希望对大家有帮助。scribe只负责接收消息,日志分析程序还需要自己写。
1.安装依赖包
apt-get install ruby-dev libevent-dev python-dev libevent-dev\ libboost-dev libboost-filesystem-dev collectd-dev bison flex\ automake autoconf ant libssl-dev git-core
另外还需安装 libtool 工具 不然安装 scribe会出错
2.编译安装thrift
http://thrift.apache.org/download/ wget http://www.apache.org/dist/thrift/0.7.0/thrift-0.7.0.tar.gz tar xvzf thrift-0.7.0.tar.gz cd thrift-0.7.0 ./configure make make install cd contrib/fb303 ./bootstrap.sh make make install vi /etc/ld.so.conf #增加下面一行 /usr/local/lib 执行: ldconfig
3.安装scribe
git clone http://github.com/facebook/scribe.git cd scribe ./bootstrap.sh make make install
4.配置scribe
使用默认配置文件,在scribe源目录下
cd scribe/examples
5.scribe管理
cd scribe/examples 启动 scribed example1.conf 停止scribe ./scribe_ctrl stop 查看状态 ./scribe_ctrl status 统计 ./scribe_ctrl counters
7.测试
ubuntu下python的库文件需要移动到新目录,才能用
mv /usr/lib/python2.6/site-packages/* /usr/lib/python2.6/dist-packages/ cd scribe/examples echo "11"|./scribe_cat test cat /tmp/scribetest/test/test_current 输出11,说明OK
注:
服务器端需要以上7个步骤,也就是集中管理日志的那台服务器
客户端,只需要安装thrift即可,必装
thrift 安装
thrift目录
find thrift/ -name "*.thrift"
find scribe/ -name "*.thrift"
请找到fb303.thrift和scribe.thift,放到相同的目录下,修改scribe.thrift中包含fb303的路径为当前路径。然后执行
#thrift -r --gen php scribe.thrift
会在当前目录下生成gen-php的文件夹,你所需要的php框架文件都在这个文件夹下。再 在 thrift目录 cp -R thrift-0.8.0/lib/php/src/* 下所有文件拷贝到gen-php目录下即可组成所需框架
如果你需要生成c++,java,python,ruby甚至erlang, haskball,就将命令行中的php替换为这些单词。
测试 gen-php目录 重命名为 thrift目录
新建一个php文件
<?php
$GLOBALS['THRIFT_ROOT'] = './thrift';
include_once $GLOBALS['THRIFT_ROOT'] . '/scribe/scribe.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';
$msg1['category'] = 'Test';
$msg1['message'] = "a,b,c,d,e,f,g";
$entry1 = new LogEntry($msg1);
$messages = array($entry1);
$socket = new TSocket('localhost', 1463, true);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport, false, false);
$scribe_client = new scribeClient($protocol, $protocol);
$transport->open();
$scribe_client->Log($messages);
$transport->close();
?>
完成!
原文地址 http://www.gaojinbo.com/ubuntu%E4%B8%8B%E5%AE%89%E8%A3%85scribe.html