奇忠诚 发表于 2015-9-17 10:01:35

Scribe+HDFS日志收集系统安装方法

  1、概述
  Scribe是facebook开源的日志收集系统,可用于搜索引擎中进行大规模日志分析处理。其通常与Hadoop结合使用,scribe用于向HDFS中push日志,而Hadoop通过MapReduce作业进行定期处理,具体可参见日文日志:
  http://d.hatena.ne.jp/tagomoris/touch/20110202/1296621133
  其安装非常复杂,主要是因为其依赖的包,需要设置的环境变量非常多,另外,它与Hadoop兼容不好,安装急需要技巧。目前对于Scirbe的安装方法,网上尽管有人介绍,但往往过于粗略,用处不大。本文比较全面的介绍了Scribe的安装方法,方法已经得到验证。
  2、安装前的准备
  (1)Thrift依赖软件
  具体参见文章:http://wiki.apache.org/thrift/ThriftRequirements, 关于Thrift的介绍,参见我的另一篇日志:http://dongxicheng.org/search-engine/thrift-framework-intro/
  (2)Thrift
  最新版本即可。
  (3)Scribe
  版本2.1和2.2存在问题,直接下载github的当前版本才可用(见参考资料4)。
  (4)Hadoop
  Apache的所有版本(0.20.2(包括)之前)不可用,因为它们的libhdfs与Scribe均不兼容。
  Cloudera的几乎所有版本不可用,只有CDH3 beta2(0.20.2+320)可用。需要强调的是:Cloudera的0.20.2+737和 0.20.2+320之间不可以相互通信(在此指HDFS不可相互通信),Apache 0.20.2版本和Cloudera 0.20.2之间也不可相互通信。具体错误参见参考资料1。
  需要注意的是,我所用的机器是64位的,操作系统是Ubuntu。
  3、安装流程
  (1)安装Thrift依赖软件
  必须得安装的是:g++, boost,autoconf,libevent,Apache ant, JDK, PHP,python
  其它脚本语言根据需要安装
  (2)安装Thirft
  大体流程是:
  tar -zxvf thrift-0.2.0.tar.gz
  cd thrift-0.2.0
  ./bootstrap.sh
  ./configure
  sudo make
  sudo make install
  遇到具体问题,可到google上查找,这方面资料很多。
  安装完Thirft后,记得运行一下它提供的example,看是否安装成功。方法:在thrift源代码目录有一个叫tutorial的目录,进行其中后运行thrift命令生成相应的服务代码:
  $ thrift -r –gen cpp tutorial.thrift // -r对其中include的文件也生成服务代码 -gen是生成服务代码的语言
  运行完之后会在当前目录看到一个gen-cpp目录,其中就是thrfit命令生成的代码。这时你cd到tutorial/cpp目录,运行make,生成相应的CppServer与CppClient程式。
  此时你可以分别运行CppServer和CppClient,让它们通信。
  (3)安装Hadoop
  如果你发现Hadoop中自带的已经编译好的libhdfs不可用(libhdfs在$HADOOOP_HOME/c++中),可自己编译生成libhdfs,方法是,在$HADOOP_HOME下,输入: ant compile-c++-libhdfs -Dislibhdfs=true ,同时设置Hadoop的CLASSPATH。
  (4)安装Scribe
  ./boottrap.sh (主要目的是生成configure, 如果出现类似于configure: error: Could not link against!的错误,不要管,进行下一步好了!)
  ———————————
  ./configure –with-boost=/usr/local/boost –prefix=/usr/local/scribe –with-hadooppath=/home/dong/hadoop-0.20.2/ –enable-hdfs CPPFLAGS=”-I/opt/jdk1.6.0_21/include/ -I/opt/jdk1.6.0_21/include/linux -I/home/dong/hadoop-0.20.2/src/c++/libhdfs” LDFLAGS=”-L/opt/jdk1.6.0_21/jre/lib/amd64 -L/opt/jdk1.6.0_21/jre/lib/amd64/server -L/home/dong/hadoop-0.20.2/build/c++/Linux-amd64-64/lib -ljvm -lhdfs”
  ————————————————
  make
  ———————————————–
  sudo make install
  安装成功验证方法参见参考文献(5)。
  4、可能出现的错误及解决方法
  (1)运行boottrap.sh时,产生以下错误:
  checking whether the Boost::System library is available… yes
  checking whether the Boost::Filesystem library is available… yes
  configure: error: Could not link against!
  当安装的boost目录不在默认的/usr目录下时,用户需要配置boost安装目录,如:
  ./configure –with-boost=/usr/local/boost –prefix=/usr/local/scribe
  (2)运行examples时,产生以下错误:
  Traceback (most recent call last):
  File “examples/scribe_cat”, line 24, in <module>
  from scribe import scribe
  ImportError: No module named scribe
  解决方法:python找不到scribe模块,需要把scribe package包含进来,如:
  export PYTHONPATH=”/usr/lib/python2.6/site-packages/”
  (3)Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/ hadoop/conf/Configuration
  解决方法,将Hadoop的classpath加到环境变量中,如:
  export CLASSPATH=$HADOOP_HOME/hadoop-core-0.20.2+320.jar
  5、参考资料
  (1)介绍scribe与libhdfs的兼容性问题(日文):
  http://d.hatena.ne.jp/tagomoris/touch/20110107/1294368321
  (2)介绍scribe的安装方法(日文):
  http://d.hatena.ne.jp/tagomoris/touch/20110106/1294311969
  (3)介绍scribe的安装方法(英文):http://www.myhpcblog.blogspot.com/
  (4)scribe下载官方主页:https://github.com/facebook/scribe
  (5)Scribe应用介绍:
  http://blog.octo.com/en/scribe-a-way-to-aggregate-data-and-why-not-to-directly-fill-the-hdfs/
  (6)Scribe安装方法:http://blog.octo.com/en/scribe-installation/
  (7)Hadoop的各个CDH版本下载地址:http://archive.cloudera.com/cdh/3/

  原创文章,转载请注明: 转载自董的博客
  本文链接地址: http://dongxicheng.org/search-engine/scribe-installation/
页: [1]
查看完整版本: Scribe+HDFS日志收集系统安装方法