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 &
相关推荐
Volunteer Technology23 分钟前
Flink编程模型与API(二)
大数据·数据库·flink
团象科技27 分钟前
企业出海本地化攻坚阶段 云端大模型微调的跨区域适配实践观察
大数据·人工智能
罗小罗同学31 分钟前
Nat Med发表SPARK智能体框架,可以自主思考、提出假设、设计实验并验证结果,让AI也能主动发现肿瘤生物学规律
大数据·人工智能·spark·医学图像处理
卷毛迷你猪1 小时前
快速实验篇(A3)基于 Hive 的气象数据数仓构建与干旱指标初步分析
大数据·hadoop·分布式
HannahTx1 小时前
解锁客户资料管理新姿势:便捷查找不再是梦
大数据
Nile1 小时前
解密Palantir系列一:3. Palantir 是谁
大数据·人工智能·ai
云天AI实战派1 小时前
AI 智能体总是跑偏怎么办?ChatGPT/API/Agent 故障排查指南与全流程修复手册
大数据·人工智能·chatgpt·agent
逸Y 仙X1 小时前
文章六:ElasticSearch 集群通信安全权限
java·大数据·服务器·elasticsearch·搜索引擎·全文检索
小脑斧1231 小时前
AI Skills 全链路自动化运营实践:抖音热点、小红书种草与文生图一体化方案
大数据·人工智能·小红书·skills·自动化运营
白露与泡影2 小时前
告别OOM焦虑:Flink 内存模型原理与诊断调优
大数据·flink