ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

|NO.Z.00014|——————————|BigDataEnd|——|Hadoop&PB级数仓.V06|---------------------------------------|PB数仓.v

2022-04-10 14:32:52  阅读:237  来源: 互联网

标签:a1 拦截器 sinks 自定义 hdfs PB k1 data logs




[BigDataHadoop:Hadoop&PB级数仓.V06]                                      [BigDataHadoop.PB级企业电商离线数仓][|章节二|Hadoop|会员活跃度分析:日志数据采集&启动自定义拦截器采集日志|]








一、采集启动日志(使用自定义拦截器)
### --- 定义配置文件   

[root@hadoop02 ~]# vim /data/yanqidw/conf/flume-log2hdfs2.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# taildir source
a1.sources.r1.type = TAILDIR
a1.sources.r1.positionFile = /data/yanqidw/conf/startlog_position.json
a1.sources.r1.filegroups = f1
a1.sources.r1.filegroups.f1 = /data/yanqidw/logs/start/.*log
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = cn.yanqi.dw.flume.interceptor.CustomerInterceptor$Builder

# memorychannel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 100000
a1.channels.c1.transactionCapacity = 2000

# hdfs sink
a1.sinks.k1.type = hdfs
a1.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 = 33554432
a1.sinks.k1.hdfs.rollCount = 0
a1.sinks.k1.hdfs.rollInterval = 0
a1.sinks.k1.hdfs.idleTimeout = 0
a1.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 channel
a1.sources.r1.channels = c1
a1.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-28
drwxr-xr-x   - root supergroup          0 2021-09-28 20:00 /user/data/logs/start/dt=2020-07-21
drwxr-xr-x   - root supergroup          0 2021-09-28 19:51 /user/data/logs/start/dt=Unknown








===============================END===============================


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



来自为知笔记(Wiz)

标签:a1,拦截器,sinks,自定义,hdfs,PB,k1,data,logs
来源: https://www.cnblogs.com/yanqivip/p/16125762.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有