安装ubuntu10.04 下 安装 scribe thrift

来源:互联网 发布:日本的电视直播软件 编辑:程序博客网 时间:2024/04/29 03:03

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.gztar xvzf thrift-0.7.0.tar.gzcd thrift-0.7.0./configuremakemake installcd contrib/fb303./bootstrap.shmakemake installvi /etc/ld.so.conf#增加下面一行/usr/local/lib执行:ldconfig

3.安装scribe

git clone http://github.com/facebook/scribe.gitcd scribe./bootstrap.shmakemake 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/examplesecho "11"|./scribe_cat testcat /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

原创粉丝点击