大数据学习——实现多agent的串联,收集数据到HDFS中
2024-09-08 00:39:25
采集需求:比如业务系统使用log4j生成的日志,日志内容不断增加,需要把追加到日志文件中的数据实时采集到hdfs,使用agent串联
根据需求,首先定义以下3大要素
第一台flume agent
l 采集源,即source——监控文件内容更新 : exec ‘tail -F file’
l 下沉目标,即sink——数据的发送者,实现序列化 : avro sink
l Source和sink之间的传递通道——channel,可用file channel 也可以用 内存channel
第二台flume agent
l 采集源,即source——接受数据。并实现反序列化 : avro source
l 下沉目标,即sink——HDFS文件系统 : HDFS sink
l Source和sink之间的传递通道——channel,可用file channel 也可以用 内存channel
配置文件编写:
在mini1的conf下
vi execsource-avrosink.conf
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /root/logs/test.log # Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.channel = c1
a1.sinks.k1.hostname = mini2
a1.sinks.k1.port =
a1.sinks.k1.batch-size = # Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
在mini2造数据
while true; do date >>test.log ;sleep .5s; done
在mini2的conf下
avro-sink.conf
a1.sources = r1
a1.sinks =s1
a1.channels = c1 ##source中的avro组件是一个接收者服务
a1.sources.r1.type = avro
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = a1.sinks.s1.type=hdfs
a1.sinks.s1.hdfs.path=/flumedata
a1.sinks.s1.hdfs.filePrefix = access_log
a1.sinks.s1.hdfs.batchSize=
a1.sinks.s1.hdfs.fileType = DataStream
a1.sinks.s1.hdfs.writeFormat =Text
a1.sinks.s1.hdfs.rollSize =
a1.sinks.s1.hdfs.rollCount =
a1.sinks.s1.hdfs.rollInterval =
a1.sinks.s1.hdfs.round = true
a1.sinks.s1.hdfs.roundValue =
a1.sinks.s1.hdfs.roundUnit = minute a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = a1.sources.r1.channels = c1
a1.sinks.s1.channel = c1
启动
在mini2先启动 bin/flume-ng agent -c conf -f conf/avro-sink.conf -n a1 -Dflume.root.logger=INFO,console
在mini1再启动 bin/flume-ng agent -c conf -f conf/execsource-avrosink.conf -n a1 -Dflume.root.logger=INFO,console
结果
最新文章
- C#遐想/瞎想
- jQuery初探 jQuery选取和操纵元素的特点
- IE8的parseInt
- 对CPU做下性能测试
- only for equality comparisons Hash Index Characteristics
- Java部分总结图片版(已经加上原图链接下载!!!)
- Float Equal Problem
- 常用Ubuntu 命令
- SQL 局域网远程备份
- 201521123036 《Java程序设计》第14周学习总结
- C++ 精英化趋势
- Exp3 免杀原理与实践 20164302 王一帆
- javascript var变量删除
- 开源流媒体服务器SRS学习笔记(1) - 安装、推流、拉流
- NoSQL——not onlySQL不仅仅是SQL
- AWS S3 CLI的安装和配置
- Mysql安装(win10 64位)
- 初识云计算的三种服务模式 (IaaS SaaS PaaS)
- JavaScript的事件的处理函数(鼠标,键盘,HTML)
- [Angular-Scaled web] 5. ui-router $stateParams for sharing information