Flume的Sink怎么使用
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,这篇文章主要介绍"Flume的Sink怎么使用",在日常操作中,相信很多人在Flume的Sink怎么使用问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"Flume的Sin
千家信息网最后更新 2025年12月02日Flume的Sink怎么使用
这篇文章主要介绍"Flume的Sink怎么使用",在日常操作中,相信很多人在Flume的Sink怎么使用问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"Flume的Sink怎么使用"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
Logger Sink
Logs会输出到console,是为了debug用的。
[root@hftest0001 conf]# pwd/opt/apache-flume-1.6.0-bin/conf[root@hftest0001 conf]# vi s-exec_c-m_s-logger.conf agent.sources = exec_tailagent.channels = memoryChannelagent.sinks = loggerSinkagent.sources.exec_tail.type = execagent.sources.exec_tail.command = tail -F /opt/flume-data/exec-tail.logagent.sources.exec_tail.channels = memoryChannelagent.sinks.loggerSink.type = loggeragent.sinks.loggerSink.channel = memoryChannelagent.channels.memoryChannel.type = memoryagent.channels.memoryChannel.capacity = 100[root@hftest0001 apache-flume-1.6.0-bin]# pwd/opt/apache-flume-1.6.0-bin[root@hftest0001 opt]# mkdir -p /opt/flume-data/[root@hftest0001 opt]# touch /opt/flume-data/exec-tail.log[root@hftest0001 apache-flume-1.6.0-bin]# flume-ng agent -n agent -c conf/ -f conf/s-exec_c-m_s-logger.conf ........[root@hftest0001 opt]# echo "Hello Flume" >> /opt/flume-data/exec-tail.log观察console,类似于 Event:{headers{} bodys: xxx xx x x x x Hello Flume }HDFS Sink
[root@hftest0001 conf]# pwd/opt/apache-flume-1.6.0-bin/conf[root@hftest0001 conf]# vi s-exec_c-m_s-hdfs.conf agent.sources = exec_tail agent.channels = memoryChannelagent.sinks = hdfs_sinkagent.sources.exec_tail.type = execagent.sources.exec_tail.command = tail -F /opt/flume-data/exec-tail.logagent.sources.exec_tail.interceptors = i1agent.sources.exec_tail.interceptors.i1.type = org.apache.flume.interceptor.TimestampInterceptor$Builderagent.sources.exec_tail.channels = memoryChannelagent.sinks.hdfs_sink.type = hdfsagent.sinks.hdfs_sink.hdfs.path = hdfs://10.224.243.124:9000/flume/events/%y-%m-%d =>写入hdfs的路径##roll file的三个策略,(避免生成大量的空文件,或者小文件)#agent.sinks.hdfs_sink.hdfs.rollInterval = 30 =>基于时间:default 30s,设置为0,则disable#agent.sinks.hdfs_sink.hdfs.rollSize = 1024 =>基于文件大小:default 1024bytes,设置为0,则disable#agent.sinks.hdfs_sink.hdfs.rollCount = 10 =>基于文件消息的数量:default 10个,设置为0,则disableagent.sinks.hdfs_sink.hdfs.fileType = DataStream =>flume写入hdfs的文件类型 default:SequenceFile#SequenceFile => 类似于hadoop.io.LongWritable "ora.apache.hadoop.io.ByteWritable..."...#DataStream => 不会对输出进行压缩,即不能再设置hdfs.codeC#CompressedStream =>就会对输出进行压缩,并要求设置可用的hdfs.codeC#agent.sinks.hdfs_sink.hdfs.codeCagent.sinks.hdfs_sink.hdfs.writeFormat = Textagent.sinks.hdfs_sink.hdfs.filePrefix = flume#agent.sinks.hdfs_sink.hdfs.hdfs.callTimeout = 10000 => flume对Hdfs的操作如open,write,flush等等,对network不佳的系统,可以适当的调大该参数agent.sinks.hdfs_sink.channel = memoryChannelagent.channels.memoryChannel.type = memoryagent.channels.memoryChannel.capacity = 100
File Roll Sink
[root@hftest0001 conf]# pwd/opt/apache-flume-1.6.0-bin/conf[root@hftest0001 conf]# vi s-exec_c-m_s-file-roll.conf agent.sources = exec_tail-1agent.channels = memoryChannelagent.sinks = file_roll-1agent.sources.exec_tail-1.type = execagent.sources.exec_tail-1.command = tail -F /opt/flume-data/exec-tail.logagent.sources.exec_tail-1.channels = memoryChannelagent.sinks.file_roll-1.type = file_rollagent.sinks.file_roll-1.sink.directory= /opt/flume-data/file-roll-1#agent.sinks.file_roll-1.sink.rollInterval= 30 => roll file策略,default:30s 生成一个新的文件。设置为0,则disable roll file,即会全部写入单一的文件中agent.sinks.file_roll-1.channel = memoryChannelagent.channels.memoryChannel.type = memoryagent.channels.memoryChannel.capacity = 100
到此,关于"Flume的Sink怎么使用"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
文件
学习
输出
更多
策略
帮助
生成
实用
适当
接下来
三个
参数
大小
数量
文章
方法
时间
消息
理论
知识
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
常见的简单的数据库系统
网关作为dhcp服务器
随机获取数据库表中的一条数据
互联网科技公司宣传片脚本
关于网络安全的有趣图片
软件开发需要研究图像吗
小学生如何关注网络安全
2020年网络安全实施方案
网络技术 英语高效课堂
闲美软件开发
服务器和交换机如何连接以及配置
物联网软件开发前景
数据库菜单设计模块
网警具备哪些网络技术
软件开发工程师转入互联网行业
mysql数据库修复工具
路由器 服务器未响应
手机扫码录入图书数据库
泰州营销软件开发项目
GT7 服务器目前正在维护
网络技术专业报云赛道
四年软件开发
城关区软件开发app开发
网络安全情报与分析会议
幼儿园网络安全教育目标
哪个服务器比较平衡
自建数据库 扫描枪
改系统数据库英文
手机远程阿里云服务器的软件
路由器 服务器未响应