大數據應用日誌採集之Scribe 安裝配置指南php
Scribe是Facebook開源的日誌收集系統,在Facebook內部已經獲得大量的應用。它能從各類日誌源收集日誌,存儲到一箇中央存儲系統上,便於進行集中統計分析處理。它爲日誌的」分佈式收集,統一處理」提供了一個可擴展的,高容錯的方案。scribe代碼很簡單,可是安裝配置卻很複雜,本文記錄了做者實際的一次安裝的過程,感受真是不通常的瑣碎,另外Scribe開源社區的版本已是幾年前的版本了,最新的維護信息一致沒有看到,HDFS和Thrift的版本使用的都是比較舊的版本,考慮另開一個分支,升級一下Scribe,看到時候有沒有時間了。java
Scribe 依賴於多個環境,有pthyon,boost,thirft,libevent,openssl等。在編譯的時候還有一些編譯錯誤須要進行修正,安裝的和準備以下。python
1.安裝編譯環境c++
#yum install gcc-c++ libevent libevent-devel automake autoconf m4 bison zlib zlib-devel bzip2 bzip2-devel flex pkgconfig python python-devel ruby ruby-devel mono-devel libxml2 libxml2-devel ant openssl-develgit
2.安裝boost環境:最低版本1.36github
#wget http://nchc.dl.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.gzapache
#tar zxvf boost_1_45_0.tar.gzbootstrap
#cd boost_1_45_0vim
#./bootstrap.sh ruby
#./bjam
#./bjam --s HAVE_ICU=1 --prefix=/usr/local/boost --includedir=/usr/local/boost/include --libdir=/usr/local/boost/lib
#./bjam install –prefix=/usr/local/boost
#echo "/usr/local/boost/lib" >> /etc/ld.so.conf
#echo /usr/local/boost/include >> /etc/ld.so.conf
#ldconfig
3. 安裝thrift環境
#wget https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz
#tar xzvf thrift-0.9.0.tar.gz
#./configure --prefix=/usr/local/thrift --with-boost=/usr/local/boost --with-java=no --with-erlang=no --with-perl=no --with-php=no --with-ruby=no
備註:若是提示找不到libcrpty增長openssl路徑
./configure --prefix=/usr/local/thrift --with-boost=/usr/local/boost --with-java=no --with-erlang=no --with-perl=no --with-php=no --with- ruby=no CPPFLAGS="-I/usr/local/openssl/include" LDFLAGS="-ldl -L/usr/local/openssl/lib"
修改文件:
Thrift/lib/ src/thrift/Thrift.cpp 增長頭文件:#include<stdlib.h>
同時修改config.h文件,註釋掉:
/* Define to rpl_malloc if the replacement function should be used. */
//modby zhangzl++:
//#define malloc rpl_malloc
//--
…
/* Define to rpl_realloc if the replacement function should be used. */
//modby zhangzl++:
//#define realloc rpl_realloc
//--
#make
#make install
# echo "/usr/local/thrift/lib" >> /etc/ld.so.conf
#ldconfig
#cd contrib.
4.安裝fb303
#cd fb303
#./bootstrap.sh
#./configure --prefix=/usr/local/thrift/fb303 --with-boost=/usr/local/boost/ --with-thriftpath=/usr/local/thrift
#make
//注意修改觀察生成的Makefile關於頭文件和庫文件路徑的信息是否正確,若是正確則能夠直接編譯。
#make install
4.安裝scribe
在https://github.com/facebook/scribe下載zip包。
#unzip scribe-master.zip
#cd scribe-master
# export BOOST_ROOT=/usr/local/boost
#export LD_LIBRARY_PATH=/usr/local/thrift/lib:/usr/lib:/usr/local/lib:/usr/local/boost/lib:/usr/local/thrift/fb303/lib
#./bootstrap.sh --with-boost=/usr/local/boost --with-boost-filesystem=boost_filesystem
遇到問題:
checking whether the Boost::System library is available… yes
checking whether the Boost::Filesystem library is available… yes
configure: error: Could not link against !
解決辦法,在configure 後加一個參數 --with-boost-filesystem=boost_filesystem
#./configure --prefix=/usr/local/scribe --with-boost=/usr/local/boost --with-thriftpath=/usr/local/thrift --with-fb303path=/usr/local/thrift/fb303 --with-boost-filesystem=boost_filesystem
#make
遇到問題:
#tar zxvf libevent-2.0.18-stable.tar.gz
#cd libevent-2.0.18-stable
#./configure –prefix=/usr/local/libevent
#make
#make install
3.安裝libevent-devel
yum install libevent-devel
error: there are no arguments to 'htons' that depend on a template parameter, so a declaration of 'htons' must be available
須要本身修改一下文件:
vim /usr/local/thrift/include/thrift/protocol/TBinaryProtocol.tcc
在首行添加頭文件引用: #include <arpa/inet.h>
#echo /usr/local/libevent/include >> /etc/ld.so.conf
#ldconfig
#make install
#cp example/example1.conf /tmp
#/usr/local/scribe/bin/scribed /tmp/example1.conf
進行測試。
若是失敗,根據提示信息,進行相應修改。
我啓動時出現下面的錯誤:
./scribed: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
解決辦法是find這個庫文件libevent-2.0.so.5,拷貝到/usr/lib64目錄下。
啓動成功後,出現下面的界面:
Scribe 的配置解析見http://my.oschina.net/guol/blog/110258
測試經過的server端和client端的配置文件以下:
port=1463
max_msg_per_second=100000000
max_queue_size=10000000
check_interval=1
new_thread_per_category=true
<store>
category=squid
type=file
file_path=/tmp/test/logcollect/
base_filename=21vianet__squid_access_all_
rotate_period=daily
rotate_hour=0
rotate_minute=0
max_size=1610612736
add_newlines=0
</store>
port=1464
max_msg_per_second=2000000
max_queue_size=1000000
check_interval=1
new_thread_per_category=true
<store>
category=default
type=buffer
target_write_size=20480
max_write_interval=1
buffer_send_rate=2
retry_interval=30
retry_interval_range=10
<primary>
type=network
#remote_host=218.93.205.106
remote_host=192.168.11.95
remote_port=1463
</primary>
<secondary>
type=file
fs_type=std
write_meta=no
file_path=/tmp/test/scribed
base_filename=accesslog
max_size=100000000
add_newlines=0
</secondary>
</store>
注意:
在server端接收的日誌,將以文件的方式來記錄log,這個文件不能刪除,它是個軟鏈接。須要先copy過去,再調用touch命令將文件清空。