|NO.Z.00014|——————————|BigDataEnd|——|Hadoop&PB级数仓.V06|——|PB数仓.v06|会员活跃度分析|启动自定义拦截器采集日志|

网友投稿 240 2022-11-19

|NO.Z.00014|——————————|BigDataEnd|——|Hadoop&PB级数仓.V06|——|PB数仓.v06|会员活跃度分析|启动自定义拦截器采集日志|

一、采集启动日志(使用自定义拦截器)

### --- 定义配置文件 [root@hadoop02 ~]# vim /data/yanqidw/conf/flume-log2hdfs2.confa1.sources = r1a1.sinks = k1a1.channels = c1# taildir sourcea1.sources.r1.type = TAILDIRa1.sources.r1.positionFile = /data/yanqidw/conf/startlog_position.jsona1.sources.r1.filegroups = f1a1.sources.r1.filegroups.f1 = /data/yanqidw/logs/start/.*loga1.sources.r1.interceptors = i1a1.sources.r1.interceptors.i1.type = cn.yanqi.dw.flume.interceptor.CustomerInterceptor$Builder# memorychannela1.channels.c1.type = memorya1.channels.c1.capacity = 100000a1.channels.c1.transactionCapacity = 2000# hdfs sinka1.sinks.k1.type = hdfsa1.sinks.k1.hdfs.path = /user/data/logs/start/dt=%{logtime}/a1.sinks.k1.hdfs.filePrefix = startlog.a1.sinks.k1.hdfs.fileType = DataStream# 配置文件滚动方式(文件大小32M)a1.sinks.k1.hdfs.rollSize = 33554432a1.sinks.k1.hdfs.rollCount = 0a1.sinks.k1.hdfs.rollInterval = 0a1.sinks.k1.hdfs.idleTimeout = 0a1.sinks.k1.hdfs.minBlockReplicas = 1# 向hdfs上刷新的event的个数a1.sinks.k1.hdfs.batchSize = 1000# 使用本地时间# a1.sinks.k1.hdfs.useLocalTimeStamp = true# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1

### --- 修改:~~~ 给source增加自定义拦截器;~~~ 去掉本地时间戳 a1.sinks.k1.hdfs.useLocalTimeStamp = true~~~ 根据header中的logtime写文件

~~~ # 启动agent服务[root@hadoop02 ~]# flume-ng agent --conf /opt/yanqi/servers/flume-1.9.0/conf \--conf-file /data/yanqidw/conf/flume-log2hdfs2.conf \-name a1 -Dflume.root.logger=INFO,console

### --- 拷贝日志[root@hadoop02 ~]# cp /data/yanqidw/logs/data/start0802.log /data/yanqidw/logs/start/start7.log[root@hadoop02 ~]# cp /data/yanqidw/logs/data/start0802.log /data/yanqidw/logs/start/start8.log

### --- 检查HDFS文件[root@hadoop02 ~]# hdfs dfs -ls /user/data/logs/start/drwxr-xr-x - root supergroup 0 2021-09-28 18:28 /user/data/logs/start/2021-09-28drwxr-xr-x - root supergroup 0 2021-09-28 20:00 /user/data/logs/start/dt=2020-07-21drwxr-xr-x - root supergroup 0 2021-09-28 19:51 /user/data/logs/start/dt=Unknown

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart

——W.S.Landor

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:mybatis 实现字段大小写赋值
下一篇:|NO.Z.00017|——————————|BigDataEnd|——|Hadoop&PB级数仓.V01|——|PB数仓.v01|会员活跃度分析|数据处理&ODS建表&加载数据|
相关文章

 发表评论

暂时没有评论,来抢沙发吧~