上一篇简要的了解了scribe的原理,这个一篇可以实践一下scribe。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.
详细如下图:
安装环境:debian6
安装组件:boost、thrift、fb303、scribe。(其余依赖包通过apt-get安装)
安装相关依赖包
apt-get install build-essential bison flex libboost-all-dev
apt-get install libevent-dev libglib2.0-dev libboost-dev libssl-dev python-dev
apt-get install libboost-system-dev libboost-filesystem-dev libtool
apt-get install git automake
1 安装boost
wget 'http://nchc.dl.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.gz'
tar zxvf boost_1_45_0.tar.gz
cd boost_1_45_0
./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
export BOOST_ROOT=/usr/local/boost
export LD_LIBRARY_PATH=/usr/local/boost/lib:/usr/lib:/usr/local/lib
2 安装thrift&&fb303(fb303在thrift源码包中)
wget 'https://dist.apache.org/repos/dist/release/thrift/0.9.0/thrift-0.9.0.tar.gz'
tar zxvf thrift-0.9.0.tar.gz
cd thrift-0.9.0
./configure --with-boost=/usr/local/boost
make
make install
cd contrib/fb303
./bootstrap.sh --with-boost=/usr/local/boost/
make
make install
3 安装scribe
git clone https://github.com/facebook/scribe
cd scribe
./bootstrap.sh --with-boost=/usr/local/boost --prefix=/usr/local/scribe
./configure --with-boost=/usr/local/boost --prefix=/usr/local/scribe CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DBOOST_FILESYSTEM_VERSION=2"
make
make install
4 在debian中需要做如下调整,因为生成的scribe模块并未在默认的搜索路径中
cp -a /usr/lib/python2.6/site-packages/* /usr/lib/python2.6/dist-packages/
5 测试
#配置scribe配置文件,scribe源码中有简单的模版
mkdir /usr/local/scribe/conf
cp scribe/examples/example1.conf /usr/local/scribe/conf
cp scribe/examples/scribe_cat /sbin/
cp scribe/examples/scribe_ctrl /sbin/
#启动scribe
cd /usr/local/scribe/bin/
./scribed -c ../conf/example1.conf
#出现如下则说明启动成功
[Fri Feb 22 21:12:11 2013] "STATUS: STARTING"
[Fri Feb 22 21:12:11 2013] "STATUS: configuring"
[Fri Feb 22 21:12:11 2013] "got configuration data from file <../conf/example1.conf>"
[Fri Feb 22 21:12:11 2013] "CATEGORY : default"
[Fri Feb 22 21:12:11 2013] "Creating default store"
[Fri Feb 22 21:12:11 2013] "configured <1> stores"
[Fri Feb 22 21:12:11 2013] "STATUS: "
[Fri Feb 22 21:12:11 2013] "STATUS: ALIVE"
[Fri Feb 22 21:12:11 2013] "Starting scribe server on port 1463"
Thrift: Fri Feb 22 21:12:11 2013 TNonblockingServer: Serving on port 1463, 1 io threads.
Thrift: Fri Feb 22 21:12:11 2013 TNonblockingServer: using libevent 1.4.13-stable method epoll
Thrift: Fri Feb 22 21:12:11 2013 TNonblocking: IO thread #0 registered for listen.
Thrift: Fri Feb 22 21:12:11 2013 TNonblocking: IO thread #0 registered for notify.
Thrift: Fri Feb 22 21:12:11 2013 TNonblockingServer: IO thread #0 entering loop...
#另开窗口进行测试
mkdir /tmp/scribetest
echo "hello world"| scribe_cat test
#可以看到输入scribe的内容
cat /tmp/scribetest/test/test_current
#查看scribe的状态
scribe_ctrl status
#停止和重新加载scribe
scribe_ctrl stop/reload
终于安装完毕,网上也有很多安装过程可以参考,安装过程中出现问题最多的是boost库的依赖问题。
参考:
http://www.cnblogs.com/oubo/archive/2011/10/28/2394607.html
http://blog.veryamt.com/play-with-scribe-in-debian-6.html