栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

flume-使用KafkaChannel读取不到数据

flume-使用KafkaChannel读取不到数据

使用TAILDIR监听日志写入KafkaChannel。

配置如下:

a1.sources = r1
a1.channels = c1

#描述source
a1.sources.r1.type = TAILDIR
a1.sources.r1.filegroups = f1
a1.sources.r1.filegroups.f1 = /opt/module/applog/log22/app.*
a1.sources.r1.positionFile = /opt/module/flume/taildir_position.json
#a1.sources.r1.interceptors =  i1
#a1.sources.r1.interceptors.i1.type = com.atguigu.flume.interceptor.ETLInterceptor$Builder

#描述channel
a1.channels.c1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.c1.kafka.bootstrap.servers = 192.168.88.161:9092
a1.channels.c1.kafka.topic = topic_log
a1.channels.c1.parseAsFlumeEvent = false

#绑定source和channel以及sink和channel的关系
a1.sources.r1.channels = c1

启动命令:
/export/soft/apache-flume-1.9.0-bin/bin/flume-ng agent --name=$agent_name -Dflume.monitoring.type=http -Dflume.monitoring.port=1234 -c /export/soft/apache-flume-1.9.0-bin/conf -f /export/soft/apache-flume-1.9.0-bin/conf/user/applog_flie-kafka2.conf -Dflume.root.logger=INFO,LOGFILE >/opt/module/flume/server/log/log.txt 2>&1

发现kafka对应的topic没有接收到消息。

排查:

1,修改启动命令,将日志输出到控制台,查看相应的组件是否启动,正常情况日志应该有如下的日志:xxx started:

但我的日志中发现一个组件都没有启动。


2,推测是不是flume监听日志文件除了问题,于是想把监听文件内容输出到控制台,另外写一个flume的配置文件,source(文件)->channel(内存)->sink(控制台):

a1.sources = r1
a1.channels = c1
a1.sinks = k1

#描述source
a1.sources.r1.type = TAILDIR
a1.sources.r1.filegroups = f1
a1.sources.r1.filegroups.f1 = /opt/module/applog/log22/app.*
a1.sources.r1.positionFile = /opt/module/flume/taildir_position.json
#a1.sources.r1.interceptors =  i1
#a1.sources.r1.interceptors.i1.type = com.atguigu.flume.interceptor.ETLInterceptor$Builder

#描述channel
#a1.channels.c1.type = org.apache.flume.channel.kafka.KafkaChannel
#a1.channels.c1.kafka.bootstrap.servers = no1de1:9092,noide2:9092
#a1.channels.c1.kafka.topic = topic_log
#a1.channels.c1.parseAsFlumeEvent = false


# Describe the sink
a1.sinks.k1.type = logger
  
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


#绑定source和channel以及sink和channel的关系
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

启动命令:

../../bin/flume-ng agent -n a1 -c ../../conf -f applog_flie-memory.conf -Dflume.root.logger=INFO,console

测试发现监听文件没有问题,文件内容会打印到控制台,说明flume监听文件是没问题的。

3,又一次启动flume任务,仔细研究日志,发现有这样一行:

错误找到了,整个管道的名称不是xa1,而是a1:

修改启动命令,指定正确的名称 :

启动后,日志打印正常,kafka也接收到消息。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/780062.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号