设为首页 加入收藏

TOP

Flume 配置和读取tomcat文件到指定位置
2018-11-28 17:43:22 】 浏览:129
Tags:Flume 配置 读取 tomcat 文件 指定 位置

需要交流请进群-- 494831900 --我和群中朋友会及时回答

1:去官网下载 flume 1.5 网址是:flume.apache.org

2: 解压对应的tar 包

3:进去flume的conf目录 创建一个文件 vi example.conf

# Define a memory channel called ch1 on agent1
agent1.channels.ch1.type = memory
# Define an Avro source called avro-source1 on agent1 and tell it
# to bind to0.0.0.0:41414. Connect it to channel ch1.
agent1.sources.avro-source1.channels = ch1
agent1.sources.avro-source1.type = avro
agent1.sources.avro-source1.bind =0.0.0.0
agent1.sources.avro-source1.port =41414
# Define a logger sink that simply logs all events it receives
# and connect it to the other end of the same channel.
agent1.sinks.log-sink1.channel = ch1
agent1.sinks.log-sink1.type = logger
# Finally, now that we've defined all of our components, tell
# agent1 which ones we want to activate.
agent1.channels = ch1
agent1.sources = avro-source1
agent1.sinks = log-sink1
_____________________________________________________________
把内容拷贝进去
mvflume-env.sh.templateflume-env.sh
然后更改flume-env.sh 里面的java_home 变成你自己的
执行命令 --进入bin目录后 如果配置了环境变量 不需要进去bin目录执行次命令否则进入bin执行此命令
flume-ng agent --conf conf/ -f example.conf -Dflume.root.logger=DEBUG,console -n agent1
--name,-n <agentname>
是指配置文件中的 agent的名字 我这个里叫 agent1
--conf-file,-f <file> 这个是指配置文件的目录 和要指定的配置文件

flume-ng avro-client --conf /usr/local/flume/conf -H localhost -p41414-F /etc/passwd -Dflume.root.logger=DEBUG,console
会打印出内容

----------------------读取tomcat logs ------------------------------------------------

在配置文件中 新建一个 tomcat.conf 内容如下
agent1.channels.ch1.type = file

agent1.sources.avro-source1.channels = ch1
agent1.sources.avro-source1.type = exec
agent1.sources.avro-source1.bind = 0.0.0.0
agent1.sources.avro-source1.port = 41414
agent1.sources.avro-source1.command = t
ail -n +0 -F /usr/local/tomcat/logs/catalina.out #linux命令的输出接受

agent1.sinks.log-sink1.channel = ch1
agent1.sinks.log-sink1.type = file_rol
l #是指输入类型 读取文件时的
agent1.sinks.log-sink1.directory=/var/log/d
ata #这个是指读取tomcat的日志到什么目录下

agent1.channels = ch1
agent1.sources = avro-source1
agent1.sinks = log-sink1
a

配置好后,执行命令:flume-ng agent --conf conf --conf-file conf/tomcat.conf --name agent1 -Dflume.root.logger=INFO,console

启动tomcat 进入 cd/var/log/data 就会看到如下图


大功告成!!!


下面是一篇详细介绍flume的文章链接
http://www.jb51.net/article/53542.htm










】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇flume开发-自定义拦截器(Intercep.. 下一篇logback与flume集成

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目