flume收集tomcat日志保存到本地目录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flume收集tomcat日志保存到本地目录相关的知识,希望对你有一定的参考价值。
下载flume和jdk
flume下载地址:
wget https://mirrors.cnnic.cn/apache/flume/1.6.0/apache-flume-1.6.0-src.tar.gz
解压文件
tar zxvf apache-flume-1.6.0-src.tar.gz
移动指定目录
mv apache-flume-1.6.0-src.tar.gz /usr/local
进入/etc/profile.d目录,添加java.sh文件,添加环境变量
JAVA_HOME=/usr/local/java
JAVA_BIN=/usr/local/java/bin
JRE_HOME=/usr/local/java/jre
FLUME_HOME=/usr/local/flume
CATALINA_HOME=/usr/local/tomcat
CLASS_PATH="$JAVA_HOME/lib:$JRE_HOME/lib:$JRE_HOME/lib/charsets.jar"
export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$FLUME_HOME/bin
让环境变量生效
source /etc/profile
创建vim /usr/local/flume/conf/tomcat.conf
a1.sources = s1
a1.sources.s1.type = exec
a1.sources.s1.command = tail -F /usr/local/tomcat/logs/catalina.out
a1.sources.s1.channels = m1
a1.channels = m1
a1.channels.m1.type = memory
a1.channels.m1.capacity = 1000
a1.channels.m1.transactionCapacity = 100
a1.sinks = LocalOut
a1.sinks.LocalOut.type = file_roll
a1.sinks.LocalOut.sink.directory = /opt/data
a1.sinks.LocalOut.sink.rollInterval = 0
a1.sinks.LocalOut.channel = m1
进入flume目录
cd /usr/local/flume/conf
执行
flume-ng agent -c . -f /usr/local/flume/conf/exec_tail.conf -n a1 -Dflume.root.logger=INFO,console
查看保存目录,已保存
ll /opt/data
以上是关于flume收集tomcat日志保存到本地目录的主要内容,如果未能解决你的问题,请参考以下文章
通过 Apache Flume 将日志文件从本地文件系统移动到 HDFS 时出错