Flume hdfs sink

hdfs sink

hdfs sink是将flume收集到的数据写入到hdfs中,方便数据可靠的保存

sink输出到hdfs中,默认每10个event生成一个hdfs文件,hdfs文件目录会根据hdfs.path的配置自动创建

配置参数:

hdfs.path hdfs目录路径

hdsf.filePrefix 文件前缀,默认值是FlumeData

hdfs.fileSuffix 文件后缀

hdfs.rollnterval 就是滚动,设置多长时间创建一个新文件进行存储,默认是30s

hdfs.rollSize 文件大小超过一定值后,然后再创建一个新文件进行存储,默认是1024

hdfs.rollCount 写入了多少个事件然后再创建一个新文件进行存储,默认是10个,设置为0的话表示不基于事件个数

hdfs.file.Type 文件格式,有三种格式可选择:SequenceFile(默认,二进制),DataStream(不压缩,以文本的形式【方便观察】),CompressedStream(可压缩)

hdfs.batchSize 批数次,HDFS Sink每次从Channel中拿的事件个数。默认值100(就是每100个事件就从sink中传到hdfs上一次)## 一般不设置

hdfs.maxOpenFiles 允许最多打开的文件数,默认是5000。如果超过了这个值,越早的文件会被关闭 ## 一般不设置

hdfs.callTimeout hdfs允许操作的事件,比如hdfs文件的open, write, flush, close操作,单位是ms,默认值10000

hdfs.codeC 压缩编解码器。以下之一:gzip, bzip2, lzo, lzop, snappy

a1.sources = r1
a1.channels = c1
a1.sinks = k1

a1.sources.r1.type = netcat
a1.sources.r1.bind = master
a1.sources.r1.port = 44444

a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 100

a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /data/hkjcpdd/%Y-%m-%d
a1.sinks.k1.hdfs.useLocalTimeStamp = true
a1.sinks.k1.hdfs.rollInterval= 10
a1.sinks.k1.hdfs.fileType = DataStream

a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

a1.sinks.k1.hdfs.useLocalTimeStamp = true这个是使用本地的事件戳