当前位置: 首页 > news >正文

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 &

http://www.lryc.cn/news/267026.html

相关文章:

  • redis—String字符串
  • 三相电机转差率为负值的情形
  • 关于Dark Frost 僵尸网络对游戏行业进行DDoS攻击的动态情报
  • MongoDB数据库本地部署并结合内网穿透实现navicat公网访问
  • 前端学习笔记
  • Vue实现响应式布局
  • linux:下载、网络请求、端口
  • 182.【2023年华为OD机试真题(C卷)】敏感字段加密(字符串的分割、替换和拼接实现JavaPythonC++JS)
  • 新版IDEA中Git的使用(三)
  • node - koa 获取 Content-Type: text/plain 的数据
  • 树形结构
  • 《C++避坑神器·二十四》简单搞懂json文件的读写之根据键值对读写Json
  • SQL进阶理论篇(二十一):基于SQLMap的自动化SQL注入
  • xtu oj 1055 整数分类
  • (2023|CVPR,Corgi,偏移扩散,参数高斯分布,弥合差距)用于文本到图像生成的偏移扩散
  • ACE中为socket增加keepalive策略(windows和linux)
  • 前端工程注入版本号
  • Android 10.0 SystemUI禁用长按recent键的分屏功能
  • 自媒体实战篇:作品爆款三要素的使用场景和重要性
  • Hbase的安装配置
  • VMware17Pro虚拟机安装Linux CentOS 7.9(龙蜥)教程(超详细)
  • QT trimmed和simplified
  • Ensp dhcp全局地址池(配置命令 + 实例)
  • spring aop实际开发中怎么用,Spring Boot整合AOP,spring boot加spring mvc一起使用aop,项目中使用aop
  • C语言操作符if语句好习惯 详解分析操作符(详解4)
  • 【什么是泛型,有什么好处】
  • Stable Diffusion系列(三):网络分类与选择
  • Twincat中PLC的ST语言编程实现机器人安全交互
  • Redis实现日榜|直播间榜单|排行榜|Redis实现日榜01
  • 如何使用内网穿透工具实现Java远程连接本地Elasticsearch搜索分析引擎