Scribe

除此之外本文还收集了网络上的很多资料,加入了自己的一些解决方法,由于没有集中记录,有些地方若出现了相同,还请见谅,感谢原著作者。

更新依赖库
yum -y install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel libxml2 libxml2-devel byacc libevent
否则在安装Thrift时会出现无法make的情况。

cd  /tmp/deps
tar xzvf m4-1.4.15.tar.gz
cd m4-1.4.15/
./configure --prefix=/usr/local/services/m4
make
make install
export PATH=/usr/local/services/m4/bin/:$PATH

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz
cd  /tmp/deps
cd autoconf-2.68/
./configure --prefix=/usr/local/services/autoconf/
make
make install
export PATH=/usr/local/services/autoconf/bin/:$PATH

wgetftp://mirrors.kernel.org/gnu/automake/automake-1.11.1.tar.gz
cd  /tmp/deps
tar xzvf automake-1.11.1.tar.gz
cd automake-1.11.1/
./configure --prefix=/usr/local/services/automake/
make
make install

wget http://johntech-resource.googlecode.com/files/boost_1_44_0.tar.bz2
cd  /tmp/deps
cd boost_1_44_0/
./bootstrap.sh --with-python=/usr/local/services/python/lib/python2.7 --with-python=2.7.2 --with-icu=/usr/local/lib/icu --prefix=/usr/local/services/boost
./bjam --prefix=/usr/local/services/boost install
echo "/usr/local/services/boost/lib" >> /etc/ld.so.conf
echo "/usr/local/services/boost/include" >> /etc/ld.so.conf
ldconfig

wgethttp://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz
cd  /tmp/deps
tar xzvf  
cd libtool-2.4/
./configure --prefix=/usr/local/services/libtool
make install
export PATH=/usr/local/services/libtool/bin/:$PATH

 wgethttps://dist.apache.org/repos/dist/release/thrift/0.8.0/thrift-0.8.0.tar.gz
cd  /tmp/deps
tar xzvf thrift-0.8.0.tar.gz
cd thrift-0.8.0/
export PY_PREFIX=/usr/local/services/python/
./configure --prefix=/usr/local/services/thrift --with-csharp=no --with-java=no --with-erlang=no --with-perl=no --with-php=no --with-ruby=no --with-boost=/usr/local/services/boost/
make
make install
echo "/usr/local/services/thrift/lib" >> /etc/ld.so.conf
ldconfig
(thrift目录下)
cd contrib/fb303/
./bootstrap.sh
./configure --prefix=/usr/local/services/fb303 --with-boost=/usr/local/services/boost/ --with-thriftpath=/usr/local/services/thrift/
make
make install
(编译出错的话 ,解决方法:

I solved the problem:
1. edit src/Makefile , change CXXFLAGS = -Wall -O3  to CXXFLAGS = -Wall -O3 -fpermissive
2. edit /usr/local/include/thrift/transport/TSocket.h  add #include
    修改之后不要运行./bootstrap.sh
3./configure --prefix=/usr/local/services/fb303 --with-boost=/usr/local/services/boost/ --with-thriftpath=/usr/local/services/thrift/
cd  /tmp/deps
tar xzvf facebook-scribe-2ee14d3.tar.gz
cd facebook-scribe-2ee14d3/
./bootstrap.sh --prefix=/usr/local/services/scribe --with-thriftpath=/usr/local/services/thrift/ --with-fb303path=/usr/local/services/fb303/ --with-boost=/usr/local/services/boost/
make
make install

安装后使用
/usr/local/services/scribe/bin/scribed -c /deps/facebook-scribe-63e4824/examples/example1.conf
命令启动scribe,成功则显示


后台启动
nohup /usr/local/services/scribe/bin/scribed -c /deps/facebook-scribe-63e4824/examples/example1.conf


然后在examples目录下,发个数据给scribe :  echo "hello world test" | ./scribe_cat test
发现scribe出现提示信息:出现no module named thrift.thrif,则需在lib/python下运行python setup.py install.    


若出现


则安装正确



如果出现ImportError: No module named scribe 表示模块路径错误,找到scibe在Python下的路径


修改/etc/profile
添加
export PYTHONPATH=/usr/local/services/python/lib/python2.4/site-packages

服务器端需要以上7个步骤,也就是集中管理日志的那台服务器

在example目录下  运行./scribe_ctrl 的子命令:】

status – 如果服务器运行正常则返回'ALIVE'

version – 返回当前Scribe服务器的版本、

alive – 返回服务器运行时间

stop – 停止Scribe服务器

reload – 重新加载Scribe配置文件

counters – 返回下列统计信息 (如果非零):

received good: 返回Scribe服务器启动后接收到的信息数

received bad: 接收到的非法信息数

sent:发送到另一台Scribe服务器的信息数

denied for queue size: 因信息队列满被禁止的请求数

denied for rate: 由于速度限制而被禁止的请求数

retries: 缓冲储存重试发送一批消息的次数

requeue: Scribe发送消息到一个Store的次数 (如果must_succeed 启用).

lost: 没有记录的消息的数量。(推荐配置: 使用Buffer Stores 避免信息丢失)

received blank category: 接收到的没有信息类别的信息数量


服务端配置example1.conf:                                                        
port=1463                                     
max_msg_per_second=2000000
check_interval=3

# DEFAULT

category=default
type=buffer

target_write_size=20480
max_write_interval=1
buffer_send_rate=2
retry_interval=30
retry_interval_range=10

type=file
fs_type=std
file_path=/tmp/scribetest/feixiang
base_filename=thisisoverwritten
max_size=1000000
add_newlines=1

type=file
fs_type=std
file_path=/tmp/feixiang
base_filename=thisisoverwritten
max_size=3000000
客户端配置example1.conf:
port=1463
max_msg_per_second=2000000
check_interval=3

# DEFAULT
category=default
type=buffer

target_write_size=20480
max_write_interval=1
buffer_send_rate=1
retry_interval=30
retry_interval_range=10

type=network
remote_host=192.168.10.241
remote_port=1463

type=file
fs_type=std
file_path=/tmp/scribetest2
base_filename=log


作为客户端的配置,primary是type=network,即向remote_host发送log,如果发送不成功,就采用secondary的配置,暂时写入本地文件 

客户端192.168.10.242安装好后,启动客户端服务器,启动中央服务器,客户端使用命令
echo "192.168.10.241" | ./scribe_cat -h 192.168.10.241:1463 log
发送至服务端192.168.10.241的设定文档下log/log_00000中

如果不加指定的路径:
echo "Thks" | ./scribe_cat log
客户端的配置,分以下情况:
1.开了客户端服务:会将记录先保存在本地,再启动中央服务端,文件会自动写入192.168.10.241,同时本地记录删除。
2.同时打开客户端和服务端,会经过客户端的跳转,将记录push至服务端,本地文件也不会保存。



客户端PHP接口配置:

配置php接口,需要拷贝thrift/lib/php/src下的 protocol(目录)transport(目录) autoload.php Thrift.php
并找到fb303.thrift和scribe.thrift,放到相同的目录下,修改scribe.thrift中包含fb303的路径为当前路径,然后执行
thrift -r --gen php scribe.thrift
用来生成接口,会在当前目录下生成gen-php的文件夹,所需要的php框架文件都在这个文件夹下。
把你的gen-php mv 成closer或者其他你喜欢的名字,然后进入closer目录,会发现有fb303和scribe两个目录。
protocol(目录)transport(目录) protocol(目录)transport(目录) autoload.phpThrift.php 都复制进closer目录,
建立packages目录,将本来生成的scribe和fb303目录复制进入packages目录。
完整的:


然后vi一个文件,内容如下: vim test.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'] = 'Log2';
$msg1['message'] = "a,b,c,d,e,f,g";
$entry1 = new LogEntry($msg1);
$messages = array($entry1);

$socket = new TSocket('192.168.10.241', 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();
?>

查看是否接收到:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值