Flume采集日志存储到HDFS

1 日志服务器上配置Flume,采集本地日志文件,发送到172.19.115.96 的flume上进行聚合,如日志服务器有多组,则在多台服务器上配置相同的配置

复制代码
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = TAILDIR
a1.sources.r1.filegroups = f1
#通配符是以.*为标识的,如采集所有文件则.*,此处表示采集.log结尾的文件
a1.sources.r1.filegroups.f1 = /home/admin/app/api/logs/.*log
#a1.sources.r1.filegroups = f1 f2
#a1.sources.r1.filegroups.f2 = /usr/local/flume-1.9.0/files2/.*
a1.sources.r1.positionFile = /usr/local/flume-1.9.0/taildir_position.json

# Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = 172.19.115.96
a1.sinks.k1.port = 4141


# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

2 hdfs服务器上配置flume

复制代码
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 172.19.115.96
a1.sources.r1.port = 4141


# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://localhost:8020/test/%Y%m%d
#生成的hdfs文件名的前缀
a1.sinks.k1.hdfs.filePrefix = logs-
#指定滚动时间,默认是30秒,设置为0表示禁用该策略 生产调整为3600
a1.sinks.k1.hdfs.rollInterval = 10
#指定滚动大小,设置为0表示禁用该策略,128M
a1.sinks.k1.hdfs.rollSize = 134217700
#指定滚动条数
a1.sinks.k1.hdfs.rollCount = 0
#a1.sinks.k1.hdfs.batchSize = 100
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#生成的文件类型,默认是Sequencefile,可用DataStream,则为普通文本
a1.sinks.k1.hdfs.fileType = DataStream


# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3 在hdfs服务器上启动HDFS

复制代码
start-dfs.sh

4 先启动hdfs服务器上的flume

复制代码
 bin/flume-ng agent -c conf/ -f job/avro-flume-hdfs.conf -n a1

后台运行

复制代码
 nohup ./bin/flume-ng agent -c conf/ -f job/avro-flume-hdfs.conf -n a1 &

5 再启动日志服务器上的flume

复制代码
bin/flume-ng agent -c conf/ -f job/file-flume-avro.conf -n a1

后台运行

复制代码
nohup ./bin/flume-ng agent -c conf/ -f job/file-flume-avro.conf -n a1 &
相关推荐
Mikhail_G2 小时前
Python应用八股文
大数据·运维·开发语言·python·数据分析
Elastic 中国社区官方博客6 小时前
JavaScript 中的 ES|QL:利用 Apache Arrow 工具
大数据·开发语言·javascript·elasticsearch·搜索引擎·全文检索·apache
lifallen8 小时前
Flink task、Operator 和 UDF 之间的关系
java·大数据·flink
源码宝10 小时前
智慧工地云平台源码,基于微服务架构+Java+Spring Cloud +UniApp +MySql
java·大数据·源码·智慧工地·智能监测·智能施工
XiaoQiong.Zhang10 小时前
简历模板3——数据挖掘工程师5年经验
大数据·人工智能·机器学习·数据挖掘
Faith_xzc12 小时前
Apache Doris FE 问题排查与故障分析全景指南
大数据·数据仓库·apache·doris
潘小磊12 小时前
高频面试之6Hive
大数据·hive·面试·职场和发展
数据与人工智能律师14 小时前
当机床开始“思考”,传统“制造”到“智造”升级路上的法律暗礁
大数据·网络·算法·云计算·区块链
摘星编程15 小时前
华为云Flexus+DeepSeek征文 | 模型即服务(MaaS)安全攻防:企业级数据隔离方案
大数据·人工智能·安全·华为云·deepseek
木鱼时刻15 小时前
从大数据到大模型:我们是否在重蹈覆覆辙
大数据