SlideShare ist ein Scribd-Unternehmen logo
1 von 37
刘中兵 sohu-tpc
lzbbox@hotmail.com
 大型系统=多台服务器,监控体系=分布式
汇报+统一处理
 Facebook每天log上百亿条信息(每秒log上
百万条)
 Scribe不依赖中心服务器,中心服务器不可
用时log在本地,当中心服务器可用后又会
同步到中心服务器
 Scribe本身由C++实现, RPC通信为Python
实现(基于Thrift)
 1.Thrift简介
 2.Scribe简介
 3.安装Thrift+Scribe
 4.简单演示样例
 5.部署for log4j
 Facebook的Thrift:基于C++,开源,跨语
言C++、C#、Erlang、Java、Perl、PHP、
Python、Ruby、HTML、XSD、Smalltalk、
Cocoa、OCaml、Haskell
 Google的Protocol Buffers:基于C++,开源,
基于C++, Java, Python
 Baidu使用的ICE基于C++,开源
 Renren使用ACE基于C++(比ICE底层)
Facebook与Google比较:http://stuartsierra.com/2008/07/10/thrift-vs-protocol-buffers
Thrift传
输
通
信
协
议
服
务
端
代
码
客
户
端
代
码
Java
C++
Python
Erlang
Java
C++
Python
Erlang
 bool true, false
 byte 8位的有符号整数
 i16 16位的有符号整数
 i32 32位的有符号整数
 i64 64位的有符号整数
 double 64位的浮点数
 string UTF-8编码的字符串
 binary 字符数组
 struct 结构体
 list<type> 有序的元素列表,类似于STL的vector
 set<type> 无序的不重复元素集,类似于STL的set
 map<type1,type2> key-value型的映射,类似于STL的map
 exception 是一个继承于本地语言的exception基类
 service 服务。包含多个函数接口(纯虚函数)
 定义数据类型
 struct User {
 1: i32 uid,
 2: string name
 }
 定义服务接口
 service UserService {
 void store(1: User user),
 User retrieve(1: i32 uid)
 }
 导出命令
 thrift –r –gen py service.thrift
 可导出语言配置
 cocoa(Cocoa)、cpp(C++)、csharp(C#)、
erl(Erlang)、hs(Haskell)、html(HTML)、
java(Java)、ocaml(OCaml)、perl(Perl)、
php(PHP)、py(Python)、rb(Ruby)、st(Smalltalk)、
xsd(XSD)
Central
Server
Client
Client
Local
Server
Local
Server
 enum ResultCode
 {
 OK,
 TRY_LATER
 }
 struct LogEntry
 {
 1: string category,
 2: string message
 }
 service scribe extends fb303.FacebookService
 {
 ResultCode Log(1: list<LogEntry> messages);
 }
 启动Scribe Server:
 scribed config.conf
 停止Scribe Server:
 scribe_ctrl stop 11810
 监控Scribe Server:
 scribe_ctrl {command} 11810
▪ status – ALIVE表示运行
▪ version – 版本
▪ alive – 服务器启动时的时间(s)
▪ reload – 重载配置文件
▪ counters – 统计项
▪ received good, received bad, sent, denied for queue size, denied for rate, retries,
requeue, lost, received blank category
 配置项:
 port: 端口,默认0
 max_msg_per_second: 默认100,000
 max_queue_size: 默认5,000,000 bytes
 check_interval: 检查每个store间隔,默认5s
 new_thread_per_category: 默认yes,为每一个catagory创建一个新
的线程
 num_thrift_server_threads: 收取消息的监听线程数,默认1
 例如:
 port=1463
 max_msg_per_second=2000000
 max_queue_size=10000000
 check_interval=3
 file – 写入文件local or nfs.
 network – 发送到Scribe Server
 buffer – 主从存储,primary and a secondary
store
 bucket – 按照消息头分类hash存储
 null – 忽略
 thriftfile – 类似于file的ThriftTFileTransport
 multi – 同时写多个
参考:http://wiki.github.com/facebook/scribe/scribe-configuration
autoconf-2.60
automake-1.10.1
libtool-2.2.6b
zlib-1.2.5
libevent-2.0.4
python-2.6.5
boost-1.36.0(依赖python)
erlang-R13B01
thrift-0.2.0(依赖automake/libtool/python/erlang)
scribe-2.2(依赖libevent/python/boost/thrift)
scribe
thriftboost
python erlang
zlib
libevent
libtoolautomake
autoconf
安装包参见:192.168.0.1:/opt/soft
 autoconf-2.60(ftp://ftp.gnu.org/gnu)
 ./configure
 make
 make install
 autoconf --version
 automake-1.10.1(ftp://ftp.gnu.org/gnu)
 ./configure
 make
 make install
 automake --version
 libtool-2.2.6b(ftp://ftp.gnu.org/gnu)
 ./configure
 make
 make install
 libtool --version
 zlib-1.2.5(http://www.zlib.net/)
 ./configure
 make
 make install
 ll /usr/local/include
 libevent-2.0.4(http://monkey.org/~provos/libevent/)
 ./configure
 make
 make install
 ll /usr/local/lib/
 python-2.6.5(http://python.org/)
 ./configure
 make(稍长时间,忽略Tcl/Tk错误)
 make install
 python –V, ctrl+D退出
 输出库路径:import sys, print sys.path
 boost-1.36.0(http://www.boost.org/)
 ./configure --prefix=/usr/local/boost_1_36_0 --
without-icu
 make install(较长时间)
 ll /usr/local/boost_1_36_0/
 erlang-R13B01(http://erlang.org/)
 ./configure
 make (较长时间)
 make install
 erl, ctrl+C
 thrift-0.2.0(http://incubator.apache.org/thrift/)
 ./bootstrap.sh
 ./configure --with-boost=/usr/local/boost_1_36_0
 make (较长时间)
 make install
 ll /usr/lib/python2.6/site-packages/thrift
 fb303(在thrift里:cd contrib/fb303)
 ./bootstrap.sh
 ./configure --with-boost=/usr/local/boost_1_36_0
 make
 make install
 ll /usr/lib/python2.6/site-packages/fb303
MONO错误需要pkg-config0.20
 scribe-2.2(http://github.com/facebook/scribe)
 vi /etc/profile
▪ export BOOST_ROOT=/usr/local/boost_1_36_0
▪ export LD_LIBRARY_PATH=/usr/local/boost_1_36_0/lib::/usr/lib:/usr/local/lib
 . /etc/profile
 ./bootstrap.sh
 ./configure --with-boost=/usr/local/boost_1_36_0
 make
 make install
 ll /usr/lib/python2.6/site-packages/scribe
 拷贝python库
 cp -r /usr/lib/python2.6/site-packages/* /usr/local/lib/python2.6/site-
packages
 cp /usr/local/bin/python /usr/bin/python
 验证:python, import thrift, import scribe
 启动服务端: /opt/soft/scribe
 scribed examples/example1.conf
 启动客户端: /opt/soft/scribe
 echo "hello world" | ./examples/scribe_cat test
 查看日志
 more /tmp/scribetest/test/test_current
 hello world
Thrift样例:Java、Python通信
Scribe Java客户端:pyserverjavaclient
 安装apache-ant-1.8.0
 export ANT_HOME=/opt/soft/apache-ant-1.8.0
 export PATH=$PATH:$ANT_HOME/bin
 编译libthrift.jar
 ant
 安装slf4j-1.6.0
 配置文件:/usr/liuzhongbing
 struct User {
 1: i32 uid,
 2: string name
 }
 service UserService {
 void store(1: User user),
 User retrieve(1: i32 uid)
 }
 生成:/usr/liuzhongbing
 thrift -r -gen java user.thrift
 产生:User.java、UserService.java
 编译:/usr/liuzhongbing/gen-java
 javac -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-1.6.0/slf4j-api-
1.6.0.jar:./ *.java
 启动:/usr/liuzhongbing/gen-java
 服务端:java -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-
1.6.0/slf4j-api-1.6.0.jar:./ JavaServer 9091
▪ Starting the server...
▪ store: 1=liuzhongbing
▪ store: 2=guest
▪ retrieve: 1=liuzhongbing
 客户端:java -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-
1.6.0/slf4j-api-1.6.0.jar:./ JavaClient localhost 9091
▪ retrieve: liuzhongbing
 生成:/usr/liuzhongbing
 thrift -r -gen py user.thrift
 启动:/usr/liuzhongbing/gen-py
 服务端:python PythonServer.py 9091
▪ Starting the server...
▪ store: 1=liuzhongbing
▪ store: 2=guest
▪ retrieve: 1=liuzhongbing
 客户端:python PythonClient.py localhost 9091
▪ retrieve: liuzhongbing
 生成:/opt/soft/scribe/if
 thrift -r -I /opt/soft/thrift-0.2.0/contrib -gen java
scribe.thrift
 thrift -r -I /opt/soft/thrift-0.2.0/contrib -gen py
scribe.thrift
 编译:/opt/soft/scribe/if/gen-java
 javac -classpath
/usr/local/lib/libthrift.jar:/opt/soft/slf4j-1.6.0/slf4j-
api-1.6.0.jar:./ *.java
 启动Python服务端:/opt/soft/scribe
 scribed examples/example1.conf
▪ [Thu May 13 15:39:29 2010] "[test] Creating new category from model default"
▪ [Thu May 13 15:39:29 2010] "store thread starting"
▪ [Thu May 13 15:39:29 2010] "[test] Opened file </tmp/scribetest/test/test_00000> for
writing"
▪ [Thu May 13 15:39:29 2010] "[test] Opened file </tmp/test/test_00000> for writing"
▪ [Thu May 13 15:39:29 2010] "[test] Changing state from <DISCONNECTED> to
<SENDING_BUFFER>"
▪ [Thu May 13 15:39:29 2010] "[test] successfully read <0> entries from file
</tmp/test/test_00000>"
▪ [Thu May 13 15:39:29 2010] "[test] No more buffer files to send, switching to streaming
mode"
▪ [Thu May 13 15:39:29 2010] "[test] Changing state from <SENDING_BUFFER> to
<STREAMING>"
 启动Java客户端:/opt/soft/scribe/if/gen-java
 java -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-1.6.0/slf4j-api-
1.6.0.jar:./ JavaClient localhost 1463
scribe-log4j部署结构
部署Scribe Server
引用scribe-log4j
测试Scribe Server
scribe-
log4j.jar
Central
Server:11810
web1
service2
Local
Server:
11811
Local
Server:
11811
service1
 Central Server:192.168.0.1:11810
 启动:/usr/local/scribe/conf/central_start.sh
 停止:/usr/local/scribe/conf/central_stop.sh
 查询:/usr/local/scribe/conf/central_status.sh
 统计:/usr/local/scribe/conf/central_counters.sh
 日志目录:/opt/scribelog/central, 暂存
/opt/scribelog/tmpcentral
 Local Server:192.168.0.2:11811(App所在主机)
 启动:/usr/local/scribe/conf/local_start.sh
 停止:/usr/local/scribe/conf/local_stop.sh
 查询:/usr/local/scribe/conf/local_status.sh
 统计:/usr/local/scribe/conf/local_counters.sh
 远程主机:192.168.0.1:11810,暂存/opt/scribelog/tmplocal
配置文件参见:192.168.0.1:/usr/local/scribe/conf/
 引用scribe-log4j
 <dependency>
 <groupId>${project.groupId}</groupId>
 <artifactId>scribe-log4j</artifactId>
 <version>${scribe-log4j.version}</version>
 </dependency>
 log4j.properties中增加了几个功能配置:
 # scribe
 log4j.logger.com.mycompany=DEBUG,scribeAppender
 log4j.appender.scribeAppender=org.apache.scribe_log4j.ScribeAppender
 log4j.appender.scribeAppender.layout=org.apache.log4j.PatternLayout
 log4j.appender.scribeAppender.layout.ConversionPattern=[%p] - [%d{yyyy-MM-dd
HH:mm:ss}] - [%c.%t(%L)]: %m%n
 log4j.appender.scribeAppender.host=localhost
 log4j.appender.scribeAppender.port=11811
 log4j.appender.scribeAppender.reconnectInterval=10000
 log4j.appender.scribeAppender.category=scribe-service
 注意:自动重连信息输出在当前App标准stderr.log中
 修改host指向Local Server
 log4j.appender.scribeAppender.host=192.168.0.1
 注意:App中必须host=localhost
 运行scribe-log4j测试类
 Test.java
 查看服务端收到的日志:
 tail -f /opt/scribelog/central/scribe-service/scribe-
service_current
在/commons/scribe-log4j下进行
 安装并启动服务端: /opt/soft
 ./setup.sh > setup.log
 使用scribe-log4j测试
 Test.java
Thrift+scribe实现分布式日志收集,并与log4j集成

Weitere ähnliche Inhalte

Was ist angesagt?

"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"Badoo Development
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Chris Tankersley
 
Deploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyDeploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyJoe Kutner
 
Docker deploy
Docker deployDocker deploy
Docker deployEric Ahn
 
Sphinx autodoc - automated api documentation - PyCon.KR 2015
Sphinx autodoc - automated api documentation - PyCon.KR 2015Sphinx autodoc - automated api documentation - PyCon.KR 2015
Sphinx autodoc - automated api documentation - PyCon.KR 2015Takayuki Shimizukawa
 
このPHP拡張がすごい!2017
このPHP拡張がすごい!2017このPHP拡張がすごい!2017
このPHP拡張がすごい!2017sasezaki
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry managerToshiaki Baba
 
Cacti安装手册
Cacti安装手册Cacti安装手册
Cacti安装手册Yiwei Ma
 
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析Mr. Vengineer
 
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRVROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRVJuxi Leitner
 
pip and virtualenv
pip and virtualenvpip and virtualenv
pip and virtualenvamaneu
 
TomcatCon: from a cluster to the cloud
TomcatCon: from a cluster to the cloudTomcatCon: from a cluster to the cloud
TomcatCon: from a cluster to the cloudJean-Frederic Clere
 
Nginx 0.9.x 安装手册
Nginx 0.9.x 安装手册Nginx 0.9.x 安装手册
Nginx 0.9.x 安装手册Yiwei Ma
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPTetsuyuki Kobayashi
 
Great Hiroshima with Python 170830
Great Hiroshima with Python 170830Great Hiroshima with Python 170830
Great Hiroshima with Python 170830Takuya Nishimoto
 
Ostinato FOSS.IN 2010
Ostinato FOSS.IN 2010Ostinato FOSS.IN 2010
Ostinato FOSS.IN 2010pstavirs
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)Masami Hiramatsu
 

Was ist angesagt? (20)

"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015
 
Deploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyDeploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRuby
 
Docker deploy
Docker deployDocker deploy
Docker deploy
 
Sphinx autodoc - automated api documentation - PyCon.KR 2015
Sphinx autodoc - automated api documentation - PyCon.KR 2015Sphinx autodoc - automated api documentation - PyCon.KR 2015
Sphinx autodoc - automated api documentation - PyCon.KR 2015
 
このPHP拡張がすごい!2017
このPHP拡張がすごい!2017このPHP拡張がすごい!2017
このPHP拡張がすごい!2017
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 
Cacti安装手册
Cacti安装手册Cacti安装手册
Cacti安装手册
 
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
 
CPAN For Private Code
CPAN For Private CodeCPAN For Private Code
CPAN For Private Code
 
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRVROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
 
pip and virtualenv
pip and virtualenvpip and virtualenv
pip and virtualenv
 
TomcatCon: from a cluster to the cloud
TomcatCon: from a cluster to the cloudTomcatCon: from a cluster to the cloud
TomcatCon: from a cluster to the cloud
 
Nginx 0.9.x 安装手册
Nginx 0.9.x 安装手册Nginx 0.9.x 安装手册
Nginx 0.9.x 安装手册
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAP
 
Great Hiroshima with Python 170830
Great Hiroshima with Python 170830Great Hiroshima with Python 170830
Great Hiroshima with Python 170830
 
Centos config
Centos configCentos config
Centos config
 
Ostinato FOSS.IN 2010
Ostinato FOSS.IN 2010Ostinato FOSS.IN 2010
Ostinato FOSS.IN 2010
 
Samba 4 - debian instalacao
Samba 4 - debian instalacaoSamba 4 - debian instalacao
Samba 4 - debian instalacao
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)
 

Andere mochten auch

hadoop&zing
hadoop&zinghadoop&zing
hadoop&zingzingopen
 
美团技术沙龙01 - 滴滴打车小成本架构演进
美团技术沙龙01 - 滴滴打车小成本架构演进美团技术沙龙01 - 滴滴打车小成本架构演进
美团技术沙龙01 - 滴滴打车小成本架构演进美团点评技术团队
 
Back end analytics_platform_2013_v1.0
Back end analytics_platform_2013_v1.0Back end analytics_platform_2013_v1.0
Back end analytics_platform_2013_v1.0Sentifi
 
Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧10y2try
 
Building a lock profiler on the JVM
Building a lock profiler on the JVMBuilding a lock profiler on the JVM
Building a lock profiler on the JVMPierre Laporte
 
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)Leon Chen
 
Save JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOMSave JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOMLeon Chen
 
大型网站架构演变
大型网站架构演变大型网站架构演变
大型网站架构演变xiaozhen1900
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in JavaHome
 
浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)诸葛修车网-诸葛商城
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionHaribabu Nandyal Padmanaban
 
Concurrency: Best Practices
Concurrency: Best PracticesConcurrency: Best Practices
Concurrency: Best PracticesIndicThreads
 
[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronization[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronizationxuehan zhu
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread poolsmaksym220889
 

Andere mochten auch (20)

hadoop&zing
hadoop&zinghadoop&zing
hadoop&zing
 
美团技术沙龙01 - 滴滴打车小成本架构演进
美团技术沙龙01 - 滴滴打车小成本架构演进美团技术沙龙01 - 滴滴打车小成本架构演进
美团技术沙龙01 - 滴滴打车小成本架构演进
 
Back end analytics_platform_2013_v1.0
Back end analytics_platform_2013_v1.0Back end analytics_platform_2013_v1.0
Back end analytics_platform_2013_v1.0
 
Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧
 
如何更好地设计测试用例-BQConf
如何更好地设计测试用例-BQConf如何更好地设计测试用例-BQConf
如何更好地设计测试用例-BQConf
 
Building a lock profiler on the JVM
Building a lock profiler on the JVMBuilding a lock profiler on the JVM
Building a lock profiler on the JVM
 
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)
 
Git基础培训
Git基础培训Git基础培训
Git基础培训
 
App开发过程的演变之路
App开发过程的演变之路App开发过程的演变之路
App开发过程的演变之路
 
Save JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOMSave JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOM
 
大型网站架构演变
大型网站架构演变大型网站架构演变
大型网站架构演变
 
Nginx+tomcat https 配置
Nginx+tomcat  https 配置Nginx+tomcat  https 配置
Nginx+tomcat https 配置
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in Java
 
Java多线程技术
Java多线程技术Java多线程技术
Java多线程技术
 
浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
Concurrency: Best Practices
Concurrency: Best PracticesConcurrency: Best Practices
Concurrency: Best Practices
 
[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronization[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronization
 
JVM及其调优
JVM及其调优JVM及其调优
JVM及其调优
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 

Ähnlich wie Thrift+scribe实现分布式日志收集,并与log4j集成

20111011 bigbluebutton
20111011 bigbluebutton20111011 bigbluebutton
20111011 bigbluebuttonhs1250
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionFabio Kung
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick RethansBachkoutou Toutou
 
Building Modern Data Streaming Apps with Python
Building Modern Data Streaming Apps with PythonBuilding Modern Data Streaming Apps with Python
Building Modern Data Streaming Apps with PythonTimothy Spann
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Henry Schreiner
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Henry Schreiner
 
Rust & Python : Python WA October meetup
Rust & Python : Python WA October meetupRust & Python : Python WA October meetup
Rust & Python : Python WA October meetupJohn Vandenberg
 
Linux sever building
Linux sever buildingLinux sever building
Linux sever buildingEdmond Yu
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confooCombell NV
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Combell NV
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hosterCombell NV
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
 
Open erp on ubuntu
Open erp on ubuntuOpen erp on ubuntu
Open erp on ubuntuIker Coranti
 
3.1.c apend scripting, crond, atd
3.1.c apend   scripting, crond, atd3.1.c apend   scripting, crond, atd
3.1.c apend scripting, crond, atdAcácio Oliveira
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 

Ähnlich wie Thrift+scribe实现分布式日志收集,并与log4j集成 (20)

PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
20111011 bigbluebutton
20111011 bigbluebutton20111011 bigbluebutton
20111011 bigbluebutton
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to Production
 
Flask for cs students
Flask for cs studentsFlask for cs students
Flask for cs students
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
 
Building Modern Data Streaming Apps with Python
Building Modern Data Streaming Apps with PythonBuilding Modern Data Streaming Apps with Python
Building Modern Data Streaming Apps with Python
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
 
Rust & Python : Python WA October meetup
Rust & Python : Python WA October meetupRust & Python : Python WA October meetup
Rust & Python : Python WA October meetup
 
170112
170112170112
170112
 
Linux sever building
Linux sever buildingLinux sever building
Linux sever building
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hoster
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Open erp on ubuntu
Open erp on ubuntuOpen erp on ubuntu
Open erp on ubuntu
 
3.1.c apend scripting, crond, atd
3.1.c apend   scripting, crond, atd3.1.c apend   scripting, crond, atd
3.1.c apend scripting, crond, atd
 
Running Symfony
Running SymfonyRunning Symfony
Running Symfony
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 

Kürzlich hochgeladen

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Thrift+scribe实现分布式日志收集,并与log4j集成

  • 2.  大型系统=多台服务器,监控体系=分布式 汇报+统一处理  Facebook每天log上百亿条信息(每秒log上 百万条)  Scribe不依赖中心服务器,中心服务器不可 用时log在本地,当中心服务器可用后又会 同步到中心服务器  Scribe本身由C++实现, RPC通信为Python 实现(基于Thrift)
  • 3.  1.Thrift简介  2.Scribe简介  3.安装Thrift+Scribe  4.简单演示样例  5.部署for log4j
  • 4.
  • 5.  Facebook的Thrift:基于C++,开源,跨语 言C++、C#、Erlang、Java、Perl、PHP、 Python、Ruby、HTML、XSD、Smalltalk、 Cocoa、OCaml、Haskell  Google的Protocol Buffers:基于C++,开源, 基于C++, Java, Python  Baidu使用的ICE基于C++,开源  Renren使用ACE基于C++(比ICE底层) Facebook与Google比较:http://stuartsierra.com/2008/07/10/thrift-vs-protocol-buffers
  • 7.  bool true, false  byte 8位的有符号整数  i16 16位的有符号整数  i32 32位的有符号整数  i64 64位的有符号整数  double 64位的浮点数  string UTF-8编码的字符串  binary 字符数组  struct 结构体  list<type> 有序的元素列表,类似于STL的vector  set<type> 无序的不重复元素集,类似于STL的set  map<type1,type2> key-value型的映射,类似于STL的map  exception 是一个继承于本地语言的exception基类  service 服务。包含多个函数接口(纯虚函数)
  • 8.  定义数据类型  struct User {  1: i32 uid,  2: string name  }  定义服务接口  service UserService {  void store(1: User user),  User retrieve(1: i32 uid)  }
  • 9.  导出命令  thrift –r –gen py service.thrift  可导出语言配置  cocoa(Cocoa)、cpp(C++)、csharp(C#)、 erl(Erlang)、hs(Haskell)、html(HTML)、 java(Java)、ocaml(OCaml)、perl(Perl)、 php(PHP)、py(Python)、rb(Ruby)、st(Smalltalk)、 xsd(XSD)
  • 10.
  • 12.  enum ResultCode  {  OK,  TRY_LATER  }  struct LogEntry  {  1: string category,  2: string message  }  service scribe extends fb303.FacebookService  {  ResultCode Log(1: list<LogEntry> messages);  }
  • 13.  启动Scribe Server:  scribed config.conf  停止Scribe Server:  scribe_ctrl stop 11810  监控Scribe Server:  scribe_ctrl {command} 11810 ▪ status – ALIVE表示运行 ▪ version – 版本 ▪ alive – 服务器启动时的时间(s) ▪ reload – 重载配置文件 ▪ counters – 统计项 ▪ received good, received bad, sent, denied for queue size, denied for rate, retries, requeue, lost, received blank category
  • 14.  配置项:  port: 端口,默认0  max_msg_per_second: 默认100,000  max_queue_size: 默认5,000,000 bytes  check_interval: 检查每个store间隔,默认5s  new_thread_per_category: 默认yes,为每一个catagory创建一个新 的线程  num_thrift_server_threads: 收取消息的监听线程数,默认1  例如:  port=1463  max_msg_per_second=2000000  max_queue_size=10000000  check_interval=3
  • 15.  file – 写入文件local or nfs.  network – 发送到Scribe Server  buffer – 主从存储,primary and a secondary store  bucket – 按照消息头分类hash存储  null – 忽略  thriftfile – 类似于file的ThriftTFileTransport  multi – 同时写多个 参考:http://wiki.github.com/facebook/scribe/scribe-configuration
  • 17.  autoconf-2.60(ftp://ftp.gnu.org/gnu)  ./configure  make  make install  autoconf --version  automake-1.10.1(ftp://ftp.gnu.org/gnu)  ./configure  make  make install  automake --version
  • 18.  libtool-2.2.6b(ftp://ftp.gnu.org/gnu)  ./configure  make  make install  libtool --version  zlib-1.2.5(http://www.zlib.net/)  ./configure  make  make install  ll /usr/local/include
  • 19.  libevent-2.0.4(http://monkey.org/~provos/libevent/)  ./configure  make  make install  ll /usr/local/lib/  python-2.6.5(http://python.org/)  ./configure  make(稍长时间,忽略Tcl/Tk错误)  make install  python –V, ctrl+D退出  输出库路径:import sys, print sys.path
  • 20.  boost-1.36.0(http://www.boost.org/)  ./configure --prefix=/usr/local/boost_1_36_0 -- without-icu  make install(较长时间)  ll /usr/local/boost_1_36_0/  erlang-R13B01(http://erlang.org/)  ./configure  make (较长时间)  make install  erl, ctrl+C
  • 21.  thrift-0.2.0(http://incubator.apache.org/thrift/)  ./bootstrap.sh  ./configure --with-boost=/usr/local/boost_1_36_0  make (较长时间)  make install  ll /usr/lib/python2.6/site-packages/thrift  fb303(在thrift里:cd contrib/fb303)  ./bootstrap.sh  ./configure --with-boost=/usr/local/boost_1_36_0  make  make install  ll /usr/lib/python2.6/site-packages/fb303 MONO错误需要pkg-config0.20
  • 22.  scribe-2.2(http://github.com/facebook/scribe)  vi /etc/profile ▪ export BOOST_ROOT=/usr/local/boost_1_36_0 ▪ export LD_LIBRARY_PATH=/usr/local/boost_1_36_0/lib::/usr/lib:/usr/local/lib  . /etc/profile  ./bootstrap.sh  ./configure --with-boost=/usr/local/boost_1_36_0  make  make install  ll /usr/lib/python2.6/site-packages/scribe  拷贝python库  cp -r /usr/lib/python2.6/site-packages/* /usr/local/lib/python2.6/site- packages  cp /usr/local/bin/python /usr/bin/python  验证:python, import thrift, import scribe
  • 23.  启动服务端: /opt/soft/scribe  scribed examples/example1.conf  启动客户端: /opt/soft/scribe  echo "hello world" | ./examples/scribe_cat test  查看日志  more /tmp/scribetest/test/test_current  hello world
  • 25.  安装apache-ant-1.8.0  export ANT_HOME=/opt/soft/apache-ant-1.8.0  export PATH=$PATH:$ANT_HOME/bin  编译libthrift.jar  ant  安装slf4j-1.6.0
  • 26.  配置文件:/usr/liuzhongbing  struct User {  1: i32 uid,  2: string name  }  service UserService {  void store(1: User user),  User retrieve(1: i32 uid)  }  生成:/usr/liuzhongbing  thrift -r -gen java user.thrift  产生:User.java、UserService.java
  • 27.  编译:/usr/liuzhongbing/gen-java  javac -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-1.6.0/slf4j-api- 1.6.0.jar:./ *.java  启动:/usr/liuzhongbing/gen-java  服务端:java -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j- 1.6.0/slf4j-api-1.6.0.jar:./ JavaServer 9091 ▪ Starting the server... ▪ store: 1=liuzhongbing ▪ store: 2=guest ▪ retrieve: 1=liuzhongbing  客户端:java -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j- 1.6.0/slf4j-api-1.6.0.jar:./ JavaClient localhost 9091 ▪ retrieve: liuzhongbing
  • 28.  生成:/usr/liuzhongbing  thrift -r -gen py user.thrift  启动:/usr/liuzhongbing/gen-py  服务端:python PythonServer.py 9091 ▪ Starting the server... ▪ store: 1=liuzhongbing ▪ store: 2=guest ▪ retrieve: 1=liuzhongbing  客户端:python PythonClient.py localhost 9091 ▪ retrieve: liuzhongbing
  • 29.  生成:/opt/soft/scribe/if  thrift -r -I /opt/soft/thrift-0.2.0/contrib -gen java scribe.thrift  thrift -r -I /opt/soft/thrift-0.2.0/contrib -gen py scribe.thrift  编译:/opt/soft/scribe/if/gen-java  javac -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-1.6.0/slf4j- api-1.6.0.jar:./ *.java
  • 30.  启动Python服务端:/opt/soft/scribe  scribed examples/example1.conf ▪ [Thu May 13 15:39:29 2010] "[test] Creating new category from model default" ▪ [Thu May 13 15:39:29 2010] "store thread starting" ▪ [Thu May 13 15:39:29 2010] "[test] Opened file </tmp/scribetest/test/test_00000> for writing" ▪ [Thu May 13 15:39:29 2010] "[test] Opened file </tmp/test/test_00000> for writing" ▪ [Thu May 13 15:39:29 2010] "[test] Changing state from <DISCONNECTED> to <SENDING_BUFFER>" ▪ [Thu May 13 15:39:29 2010] "[test] successfully read <0> entries from file </tmp/test/test_00000>" ▪ [Thu May 13 15:39:29 2010] "[test] No more buffer files to send, switching to streaming mode" ▪ [Thu May 13 15:39:29 2010] "[test] Changing state from <SENDING_BUFFER> to <STREAMING>"  启动Java客户端:/opt/soft/scribe/if/gen-java  java -classpath /usr/local/lib/libthrift.jar:/opt/soft/slf4j-1.6.0/slf4j-api- 1.6.0.jar:./ JavaClient localhost 1463
  • 33.  Central Server:192.168.0.1:11810  启动:/usr/local/scribe/conf/central_start.sh  停止:/usr/local/scribe/conf/central_stop.sh  查询:/usr/local/scribe/conf/central_status.sh  统计:/usr/local/scribe/conf/central_counters.sh  日志目录:/opt/scribelog/central, 暂存 /opt/scribelog/tmpcentral  Local Server:192.168.0.2:11811(App所在主机)  启动:/usr/local/scribe/conf/local_start.sh  停止:/usr/local/scribe/conf/local_stop.sh  查询:/usr/local/scribe/conf/local_status.sh  统计:/usr/local/scribe/conf/local_counters.sh  远程主机:192.168.0.1:11810,暂存/opt/scribelog/tmplocal 配置文件参见:192.168.0.1:/usr/local/scribe/conf/
  • 34.  引用scribe-log4j  <dependency>  <groupId>${project.groupId}</groupId>  <artifactId>scribe-log4j</artifactId>  <version>${scribe-log4j.version}</version>  </dependency>  log4j.properties中增加了几个功能配置:  # scribe  log4j.logger.com.mycompany=DEBUG,scribeAppender  log4j.appender.scribeAppender=org.apache.scribe_log4j.ScribeAppender  log4j.appender.scribeAppender.layout=org.apache.log4j.PatternLayout  log4j.appender.scribeAppender.layout.ConversionPattern=[%p] - [%d{yyyy-MM-dd HH:mm:ss}] - [%c.%t(%L)]: %m%n  log4j.appender.scribeAppender.host=localhost  log4j.appender.scribeAppender.port=11811  log4j.appender.scribeAppender.reconnectInterval=10000  log4j.appender.scribeAppender.category=scribe-service  注意:自动重连信息输出在当前App标准stderr.log中
  • 35.  修改host指向Local Server  log4j.appender.scribeAppender.host=192.168.0.1  注意:App中必须host=localhost  运行scribe-log4j测试类  Test.java  查看服务端收到的日志:  tail -f /opt/scribelog/central/scribe-service/scribe- service_current 在/commons/scribe-log4j下进行
  • 36.  安装并启动服务端: /opt/soft  ./setup.sh > setup.log  使用scribe-log4j测试  Test.java