安装scribe
wget
elinks
yum install gcc ruby python ruby-devel
tar zxvf libevent-1.3.tar.gz
cd libevent-1.3
./configure --prefix=/usr/local/libevent
make
make install
cd ..
tar jxvf boost_1_45_0.tar.bz2
cd boost_1_45_0
./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
cd ..
tar zxvf thrift-0.5.0.tar.gz
cd thrift-0.5.0
./configure --with-boost=/usr/local/boost --with-php-config=/usr/local/php5/bin/php-config --with-libevent=/usr/local/libevent/
make
make install
cd contrib/fb303
./bootstrap.sh
./configure --with-boost=/usr/local/boost
make
make install
export BOOST_ROOT=/usr/local/boost
export LD_LIBRARY_PATH=/usr/local/boost/lib::/usr/lob:/usr/local/lib:/usr/local/libevent/lib/
tar xzvf facebook-scribe-2ee14d3.tar.gz
cd facebook-scribe-2ee14d3
./bootstrap.sh --with-boost=/usr/local/boost/
./configure --with-boost=/usr/local/boost/ --prefix=/usr/local/scribe/
ln -s /usr/local/libevent/include/* /usr/local/include/
ln -s /usr/local/libevent/lib/* /usr/local/lib/
make
make install
测试
mkdir /usr/local/scribe/conf
cp /usr/local/soft/facebook-scribe-2ee14d3/examples/example1.conf /usr/local/scribe/conf
/usr/local/scribe/bin/scribed -c /usr/local/scribe/conf/example1.conf
[Wed Mar 16 16:50:44 2011] "STATUS: STARTING"
[Wed Mar 16 16:50:44 2011] "STATUS: configuring"
[Wed Mar 16 16:50:44 2011] "got configuration data from file "
[Wed Mar 16 16:50:44 2011] "CATEGORY : default"
[Wed Mar 16 16:50:44 2011] "Creating default store"
[Wed Mar 16 16:50:44 2011] "configured <1> stores"
[Wed Mar 16 16:50:44 2011] "STATUS: "
[Wed Mar 16 16:50:44 2011] "STATUS: ALIVE"
[Wed Mar 16 16:50:44 2011] "Starting scribe server on port 1463"
Thrift: Wed Mar 16 16:50:44 2011 libevent 1.3 method epoll
echo "hello world"| /usr/local/src/a/facebook-scribe-2ee14d3/examples/scribe_cat test
php接口
/usr/local/bin/thrift -o . -I /usr/local/share/ --gen php /usr/local/share/fb303/if/fb303.thrift
cp /usr/local/src/a/thrift-0.5.0/lib/php/src includes -r
mkdir -p includes/packages/fb303
mkdir -p includes/packages/scribe
mv gen-php/fb303/FacebookService.php gen-php/fb303/fb303_types.php includes/packages/fb303/
mv gen-php/scribe/scribe_types.php includes/packages/scribe/
mv gen-php/scribe/scribe.php includes/
rm -rf gen-php
测试程序:
vi test.php
//参考
$GLOBALS['THRIFT_ROOT'] = './includes';
include_once $GLOBALS['THRIFT_ROOT'] . '/scribe.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';
$msg1['category'] = 'keyword';
$msg1['message'] = "This is some message for the category\n";
$msg2['category'] = 'keyword';
$msg2['message'] = "Some other message for the category\n";
//$log_entry = new LogEntry( array('category'=>$category, 'category'=>$category) )
$entry1 = new LogEntry($msg1);
$entry2 = new LogEntry($msg2);
$messages = array($entry1, $entry2);
$socket = new TSocket('localhost', 1463, true);
$transport = new TFramedTransport($socket);
//$protocol = new TBinaryProtocol($trans, $strictRead=false,$strictWrite=true)
$protocol = new TBinaryProtocol($transport, false, false);
//$scribe_client = new scribeClient($iprot=$protocol, $oprot=$protocol)
$scribe_client = new scribeClient($protocol, $protocol);
$transport->open();
$scribe_client->Log($messages);
$transport->close();
?>
cd /usr/local/scribe/;/usr/local/php5/bin/php test.php;cd ~
监控apache日志
下载scribe_log
elinks
tar zxvf silas-scribe_log-c2d401f.tar.gz
cp silas-scribe_log-c2d401f/scribe_log /usr/local/sbin/scribe_log
安装
vi /etc/supervisord.conf
添加
[program:scribe.apache.access]
command=/usr/local/sbin/scribe_log --category apache.access --file /var/log/httpd/access_log
以下为发送到远程scribe日志主机
command=/usr/local/sbin/scribe_log --host=scribe.example.com --port=1463 --category apache.access --file /var/log/httpd/access_log
阅读(1335) | 评论(0) | 转发(0) |