0%

scribe 安装记录

scribe是facebook的一款日志收集系统,看到fb瞬间觉得高大上的产品,但是整个安装历程很是坎坷啊,所以才把他记录下来,省得以后再次踩坑。

1. 系统依赖

a、gcc和gcc-c++ (vision 4.1.2 pass)

b、ruby (vision 1.8.5 pass)

c、python (vision 2.4.3 pass) 含 python 和 python-devel

d、libevent (vision 1.4 pass) 含 libevent 和 libevent-devel

e、其他: openssl-devel, bison, autoconf(vision > 2.65), bzip2-devel, automake

可以使用这个来解决依赖

sudo yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel openssl-devel

一定不要着急装后面的组件 先把这些确认好 否则可能会重新安装 折腾起来更麻烦

2. 安装前置组件

boost   1.5.4
thrift    0.9.0
fb303    thrift包中已包含

2.1 安装 boost

这是一个C++的标准库,用来后续编译c++代码使用

wget http://nchc.dl.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.bz2

tar jxvf boost_1_45_0.tar.bz2

cd boost_1_45_0

./bootstrap.sh

./b2 install

。。。此过程巨慢 需要等待

默认安装到了/usr/local/include/boost/下

2.2 安装 thrift & fb303

thrift同样是fb退出的一款框架,旨在打通多种语言程序之间的开发。

看到这里就知道了,其实fb的蓝图很大,为什么scribe不是一个单独的软件包了。安装了这些框架和编译库,你就有了fb的基础开发环境,当然fb之后的新东西也就0基础安装了。并且这也会传染其他开发者一起使用这套开发框架… 榜样作用嘛

A、trift安装

wget http://mirror.bjtu.edu.cn/apache/thrift/0.7.0/thrift-0.7.0.tar.gz

tar zxvf thrift-0.7.0.tar.gz

cd thrift-0.7.0.tar.gz

./configure CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H"

make

make install

*configure时CPPFLAGS参数不可少,否则make时会产生诸如“uint_32未定义”之类错误。另外,configure时如找不到boost库,则需使用--with-boost参数指定boost库位置。thrift安装后可以进行简单的测试以确认是否安装成功。

B、fb303安装

cd contrib/fb303/

./bootstrap.sh

./configure

make

make install

C、运行一下thrift的例子(可选 这个步骤可以验证之前的组件是否都工作正常)

cd tutorial

thrift -r --gen cpp tutorial.thrift

cd cpp

make

./CppServer 可以启动Server

./CppClient 可以启动Client

3. 安装scribe

下载安装包 https://github.com/facebookarchive/scribe 并且解压进入目录

./bootstrap.sh

./configure (如上一条命令出现报错 请参见下面的特殊参数)

make

make install

报错看这里 基本上这里不保存的可能性不大

  • 典型错误 1
configure时遇到
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-system=lboost_system
--with-boost-filesystem=lboost_filesystem
  • 典型错误2
make时遇到
undefined reference to 'boost::system::generic_category()'
undefined reference to 'boost::system::system_category()'
在确认boost::system库存在且路径正确后,检查GCC链接代码(根据make输出)
g++  -Wall -O3 -L/usr/local/lib/ -lboost_system -lboost_filesystem  -o scribed store.o store_queue.o conf.o file.o conn_pool.o scribe_server.o network_dynamic_config.o dynamic_bucket_updater.o  env_default.o  -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -lfb303 -lthrift -lthriftnb -levent -lpthread  libscribe.a libdynamicbucketupdater.a
此时需将-lboost_system -lboost_filesystem两个选项放在最后,并在src目录下手动执行链接即可完成编译。

我当时遇了上面的错误1,试验了好多种方法,终于得到了解决,最终我的configure参数是这样的

./configure --config-cache --prefix=/usr/local --with-boost=/usr/local/lib --with-boost-system=boost_system --with-boost-filesystem=boost_filesystem CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DBOOST_FILESYSTEM_VERSION=3"

4 参考资料

  1. http://www.2cto.com/os/201307/224832.html
  2. http://abentotoro.blog.sohu.com/190515962.html
  3. http://www.linuxidc.com/Linux/2012-12/76340.htm
  4. http://shiyanjun.cn/archives/107.html