Ubuntu12.04.5 Scribe 日志系统安装
很久都没来写自己的博客了,最近有时间写下这篇文章分享给大家。提供帮助和参考。
最近项目中使用scribe来采集应用程序日志,起初安装的时候,到处都是折腾,网上这方面的资料又比较不靠谱,现在记录下来,有这方面需要的童鞋,可以看看。
软件包下载地址:http://down.51cto.com/data/1902192
第一步,修改镜像源、安装必要的软件包、依赖包等。
root@vmware:~# mv /etc/apt/sources.list /etc/apt/sources.list.bak
root@vmware:~# vim /etc/apt/sources.list
deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
root@vmware:~# apt-get update
root@vmware:~# apt-get upgrade
root@vmware:~# reboot
root@vmware:~# apt-get install -y gcc make g++ automake libssl-dev pkg-config libncurses5-dev heirloom-mailx lrzsz multitail nmon htop unzip
第二步,采用apt-get方法安装 boost,避免编译thrift时,出现莫名其妙的错误。
root@vmware:~# apt-get install -y build-essential bison flex libboost-all-dev libevent-dev libglib2.0-dev \
libboost-dev libssl-dev python-dev \
libboost-system-dev libboost-filesystem-dev libtool git automake gawk
第三步,下载thrift安装包 http://down.51cto.com/data/1902192、编译安装 thrift。
root@vmware:~# cd /usr/local/
root@vmware:/usr/local# mkdir software
\\将下载的软件包拷贝到/usr/local/software目录下,
root@vmware:/usr/local/software# tar zxvf thrift-0.9.1.tar.gz
root@vmware:/usr/local/software#cd thrift-0.9.1/
root@vmware:/usr/local/software/thrift-0.9.1#./configure CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H"
root@vmware:/usr/local/software/thrift-0.9.1# make
make后会出现如下图错误信息:
处理方法:
root@vmware:/usr/local/software/thrift-0.9.1# cp test/cpp/*.o test/cpp/.libs/
root@vmware:/usr/local/software/thrift-0.9.1# make
root@vmware:/usr/local/software/thrift-0.9.1# make install
##接着安装下fb303
root@vmware:/usr/local/software/thrift-0.9.1# cd contrib/fb303/
root@vmware:/usr/local/software/thrift-0.9.1/contrib/fb303# ./bootstrap.sh
root@vmware:/usr/local/software/thrift-0.9.1/contrib/fb303# make
root@vmware:/usr/local/software/thrift-0.9.1/contrib/fb303# make install
##安装完成,检查下版本。
root@vmware:~# thrift -version
Thrift version 0.9.1
第三步,编译安装scribe
root@vmware:~# cd /usr/local/software/
root@vmware:/usr/local/software# tar zxvf scribe.tar.gz
root@vmware:/usr/local/software# cd scribe
root@vmware:/usr/local/software/scribe# ./bootstrap.sh
root@vmware:/usr/local/software/scribe# ./configure CPPFLAGS="-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DBOOST_FILESYSTEM_VERSION=2" --prefix=/usr/local/scribe
root@vmware:/usr/local/software/scribe# make
make后会出现如下图错误信息:
处理方法:
root@vmware:/usr/local/software/scribe# cd src/
root@vmware:/usr/local/software/scribe/src# 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
## 再次编译下:
root@vmware:/usr/local/software/scribe/src# cd ..
root@vmware:/usr/local/software/scribe# make
root@vmware:/usr/local/software/scribe# make install
第四步,配置scribe
root@vmware:/usr/local/software/scribe# cd /usr/local/scribe/
root@vmware:/usr/local/scribe# mkdir etc logs
root@vmware:/usr/local/scribe# cd etc
root@vmware:/usr/local/scribe/etc# vim scribe.conf
port=1463
max_msg_per_second=2000000
check_interval=3
<store>
category=default
type=file
fs_type=std
file_path=./logs/
base_filename=tmpdata
max_size=1000000000
</store>
##启动scribe
root@vmware:/usr/local/scribe/bin# ldconfig
root@vmware:/usr/local/scribe/bin#nohup /usr/local/scribe/bin/scribed /usr/local/scribe/etc/scribe.conf &
root@vmware:/usr/local/scribe# netstat -ntpl |grep 1463
tcp 0 0 0.0.0.0:1463 0.0.0.0:* LISTEN 59125/scribed
## 测试 scribe
测试时错误:
root@vmware:/usr/local/scribe# cd /usr/local/software/scribe/examples/
root@vmware:/usr/local/software/scribe/examples# echo "hello world"|./scribe_cat testecho "hello world"|./scribe_cat test
Traceback (most recent call last):
File "./scribe_cat", line 24, in <module>
from scribe import scribe
ImportError: No module named scribe
解决办法
在debian/ubuntu系列安装完毕后,python的scribe模块并没有在默认搜索路径中,所以:
cp -a /usr/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages/
测试结果如下
到这里,scribe已经安装完成。安装流程本人亲自安装测试过,如有问题可以发表评论。
李惟忠
写于 2014.12.20 晚
转载于:https://blog.51cto.com/liweizhong/1580938