关于Scribe集中式日志服务器的安装、配置与使用
[libevent] Event Notification library
[boost] Boost C++ library (version 1.36 or later)
[thrift] Thrift framework (version 0.5.0 or later)
[fb303] Facebook Bassline (included in thrift/contrib/fb303/)
fb303 r697294 or later is required.
[hadoop] optional. version 0.19.1 or higher (http://hadoop.apache.org)
thrift也依赖与boost
一、安装thrift
见
http://running.iteye.com/blog/1983463
三、安装Scribe
项目地址:https://github.com/facebook/scribe
wget https://github.com/downloads/facebook/scribe/scribe-2.2.tar.gz
下载facebook-scribe-2ee14d3.tar.gz
./bootstrap.sh --with-boost=/usr/local/boost
./configure --prefix=/usr/local/scribe --with-boost=/usr/local/boost --with-thriftpath=/usr/local/thrift
make
make install
#禁用优化,打开调试模式(默认情况下是打开优化的)
./configure --disable-opt
# To disable static libraries and enable shared libraries. [ default has been set to static]
./configure --disable-static
# To build scribe with Hadoop support
./configure --enable-hdfs
# If the build process cannot find your Hadoop/Jvm installs, you may need to specify them manually:
./configure --with-hadooppath=/usr/local/hadoop --enable-hdfs CPPFLAGS="-I/usr/local/java/include -I/usr/local/java/include/linux" LDFLAGS="-ljvm -lhdfs"
# To set thrift home to a non-default location
./configure --with-thriftpath=/myhome/local/thrift
# If Boost is installed in a non-default location or there are multiple Boost versions
# installed, you will need to specify the Boost path and library names
./configure --with-boost=/usr/local --with-boost-system=boost_system-gcc40-mt-1_36 --with-boost-filesystem=boost_filesystem-gcc40-mt-1_36
四、配置scribe
cd examples
cp scribe_c* /usr/local/scribe/bin/
mkdir -p /usr/local/scribe/conf
cd /usr/local/scribe/conf
vim scribe.conf
参考examples下的配置
五、测试
进入安装后的目录/usr/local/scribe
mkdir conf
cp ~/facebook-scribe-2ee14d3/examples/example1.conf /usr/local/scribe/conf/
启动,默认端口是1463
/usr/local/scribe/bin/scribed -c /usr/local/scribe/conf/example1.conf
测试程序:
mkdir /tmp/scribetest
测试写入:
echo "hello world"| /usr/local/scribe/bin/scribe_cat test
查看结果:
cat /tmp/scribetest/test/test_current
六、其它
scribe支持hdfs
1.编译hadoop,支持c++接口
ant compile-c++-libhdfs -Dislibhdfs=true
编译完以后,会在hadoop的跟目录生成c++的目录
2.编译scribe
./bootstrap.sh --with-boost=/usr/local/boost --enable-hdfs
./configure --with-boost=/usr/local/boost --prefix=/usr/local/scribe --with-hadooppath=/usr/lib/hadoop/ --enable-hdfs
生成客户端
生成Scribe的java客户端
cd facebook-scribe-2ee14d3/if/
thrift -r -I ../../thrift-0.5.0/contrib/ -gen java scribe.thrift
这里需要指到你的thrift的源码目录
生成thrift的java客户端
cd thrift-0.5.0/lib/java
ant
生成libthrift.jar
七、常见异常
1.编译scribe时,所报错误:
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
1.启动Scribe时,所报错误:
scribed: error while loading shared libraries: libboost_filesystem.so.1.45.0:
cannot open shared object file: No such file or directory
这是因为找不到libboost_filesystem.so.1.45.0
查找find / -name libboost_filesystem.so.1.45.0
解决办法:
1.通过软连接过去
ln -s /usr/local/boost/lib/libboost_filesystem.so.1.45.0 /usr/lib/libboost_system.so.1.45.0
2.配置export
export LD_LIBRARY_PATH=/usr/local/boost/lib:/usr/local/lib/:/usr/lib/