分布式日志系统Scribe编译安装

岁酱吖の 提交于 2019-12-06 22:00:56

最近准备整合多个系统的日志,因而想到构建一套分布式日志存储系统,首先考虑的是Scribe,不过编译安装耗费了很多时间(Scribe相关文档确实少了点,相比Flume)

环境:Ubuntu13.04 32bit

组件:
scribe    2.x(最新版)
thrift    0.9.0
boost    1.54
fb303    thrift自带

至于其他所依赖的相关包(如libevent、automake、flex、bison等)可根据configure的结果进行安装或更新。

1、安装boost

官网下载boost,版本要求高于1.36(作者用的是1.54.0),按照文档中给出的方法编译:
    $tar --bzip2 -xf /home/vincent/Download/boost_1_54_0.tar.bz2
    $cd /home/vincent/Download/boost_1_54_0
    $./bootstrap.sh --help
    $./bootstrap.sh --prefix=opt/boost_1.54
    $./b2 install

至此,boost库编译完成,编译时无需指定其他选项,在--prefix参数指定的目录下生成include和lib文件夹存放头文件和库文件。

2、安装thrift

下载thrift包,安装是经典的三大步:
    $tar zxvf thrift-0.9.0.tar.gz
    $cd thrift-0.9.0/
    $sudo ./configure CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H" 
    $sudo make
    $sudo make install

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

3、安装fb303

fb303包含在thrift安装包里,直接make安装:
    $cd contrib/fb303 
    $sudo ./bootstrap.sh --with-boost=/opt/boost_1.54/lib/ 
    $sudo make 
    $sudo make install 

此处--with-boost即是指定boost库位置

4、安装scribe

依赖组件安装完毕,即可开始编译scribe:
    $./bootstrap.sh
    $sudo ./configure --with-boost=/opt/boost_1.54/lib/ --prefix=/opt/scribe
    $sudo make
    $sudo 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
笔者的configure如下:

    sudo ./configure --prefix=/opt/scribe --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"

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目录下手动执行链接即可完成编译。(该问题是由于gcc在静态链接时对依赖库的顺序有要求导致,详细解释可参考http://www.cppblog.com/wiisola/archive/2010/05/18/115637.html




  

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!