奔跑的羚羊 发表于 2013-1-28 09:37:22

Scribe安装

关于Scribe集中式日志服务器的安装、配置与使用


一、依赖的软件环境:
1.安装libevent
    http://www.monkey.org/~provos/libevent/
解压缩安装
./configuremakemake install


2.安装boost
      http://www.boost.org
(版本>=1.36) boost_1_45_0.tar.bz2
解压
./bootstrap.sh./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/local/lib/:/usr/lib/



3.安装php环境
1)必须先安装 libxml2 ,然后在安装 php,
下载:ftp://xmlsoft.org/libxml2/ ,下载libxml2-2.7.8.tar.gz
tar -xvf libxml2-2.7.8.tar.gz./configuremakemake install

2)下载 php:http://cn.php.net/downloads.php ,下载php-5.3.6.tar.gz
tar -vxfphp-5.3.6.tar.gz./configure --prefix=/usr/local/php5 --with-php-config=/usr/local/php5/bin/php-config makemake install
(因为在 scribe 的一些版本中用到 php-config ,所以这里面要用 —with-php-config ,但是在我的安装过程没有用到,所以这个可以忽略)


4.安装thrift
      http://incubator.apache.org/thrift/
(版本>=0.5.0)
1)先安装thrift,
解压并进入thrift目录      
./configure --with-boost=/usr/local/boost --with-php-config=/usr/local/php5/bin/php-configmakemake install   

2)再安装fb303
Facebook Bassline (included in thrift/contrib/fb303/)
      fb303 r697294 or later is required.
      (已经包含在Thrift中了,重新编译一下fb303就可以)
cd contrib/fb303/./bootstrap.sh ./configure --with-boost=/usr/local/boostmakemake install


安装完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,让它们通信。


二、安装Scribe
项目地址:https://github.com/facebook/scribe
下载facebook-scribe-2ee14d3.tar.gz
./bootstrap./configure --with-boost=/usr/local/boost --prefix=/usr/local/scribemakemake 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


三、测试
进入安装后的目录/usr/local/scribe
mkdir confcp ~/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"| facebook-scribe-2ee14d3/examples/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安装