由于scribe是基于thrift服务框架开发的,所以需要先安装thrift,thrift又依赖很多工具和库.
首先安装依赖库
yum install gcc-c++ libevent libevent-devel automake autoconf m4 bison zlib zlib-devel bzip2 bzip2-devel flex pkgconfig python python-devel ruby ruby-devel mono-devel libxml2 libxml2-devel ant openssl-devel
安装boost,当前安装的1.45 最低版本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/
安装thrift
http://incubator.apache.org/thrift/
(版本>=0.5.0)
1)先安装thrift,
解压并进入thrift目录
./configure CPPFLAGS=
"-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H" --without-csharp --with-boost=/usr/local/boost
947 make
948 make install
查看版本 thrift -version
安装 fb303
在thrift 目录下已经存在此文件
cd contrib/
cd fb303/
./bootstrap.sh
./configure --with-boost=/usr/local/boost
make
make install
安装scribe (从官网下载2.2 安装失败。。。。。)
https://github.com/facebook/scribe
下载2.0版本
解压后,进入scribe 目录
- ./bootstrap --with-boost=/usr/local/boost
- ./configure CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H" --with-boost=/usr/local/boost --prefix=/usr/local/scribe
-
- make
- make install
三、测试
进入安装后的目录/usr/local/scribe
代码
- mkdir conf
- cp ~/facebook-scribe-2ee14d3/examples/example1.conf /usr/local/scribe/conf/
启动,默认端口是1463
python代码
- /usr/local/scribe/bin/scribed -c /usr/local/scribe/conf/example1.conf
[root@hadoop-1 bin]# scribed -c /usr/local/scribe/conf/example1.conf
[Tue Mar 25 18:01:12 2014] "STATUS: STARTING"
[Tue Mar 25 18:01:12 2014] "STATUS: configuring"
[Tue Mar 25 18:01:12 2014] "got configuration data from file </usr/local/scribe/conf/example1.conf>"
如能看到如上结果,表示运行成功
测试程序:
代码
- mkdir /tmp/scribetest
测试写入:
代码
- echo "hello world"| 原目录/examples/scribe_cat test
查看结果:
代码
- cat /tmp/scribetest/test/test_current
如果能看到hello world 表示正常
错误解决
安装scribe在make的时候出现如下错误:
1 |
undefined reference to `boost::system::generic_category()' |
2 |
undefined reference to `boost::system::generic_category()' |
3 |
undefined reference to `boost::system::system_category()' |
6 |
g++ -Wall -O3 -L/usr/lib -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-mt -lboost_filesystem-mt |
8 |
在configure的时候加上-lboost_system-mt -lboost_filesystem-mt参数 |
-DBOOST_FILESYSTEM_VERSION=2 参数只有在你的boost版本大于1.46的时候需要添加
测试时错误:
1 |
root@py-6:~/scribe/examples |
2 |
Traceback (most recent call last): |
3 |
File "./scribe_cat" , line 24, in <module> |
4 |
from scribe import scribe |
5 |
ImportError: No module named scribe |
8 |
在debian/ubuntu系列安装完毕后,python的scribe模块并没有在默认搜索路径中,所以: |
9 |
cp -a /usr/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages/ |
库连接错误:
2 |
scribed: error while loading shared libraries: libthrift-0.9.0.so: cannot open shared object file : No such file or directory |
4 |
ldd /usr/ local /bin/scribed 发现 |
5 |
libthrift-0.9.0.so => not found |
6 |
libthriftnb-0.9.0.so => not found |
7 |
在/usr/ local /lib/中都已经有该so文件,因为是环境变量有问题 |
9 |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/ local /lib |