要点: 1.linux上必须有hadoop,并已经启动起来,因为使用的是hadfsink 2.在a2.sources.r2.command必须需要使用流式命令,如tail,cat,而不是如 date之类的
a2.sources = r2 a2.sinks = k2 a2.channels = c2 # Describe/configure the source a2.sources.r2.type = exec a2.sources.r2.command = tail -F /export/servers/hive-1.2.1/logs/hive.log a2.sources.r2.shell = /bin/bash -c # Describe the sink a2.sinks.k2.type = hdfs a2.sinks.k2.hdfs.path = hdfs://hadoop01:9000/flume/%Y%m%d/%H #上传文件的前缀 a2.sinks.k2.hdfs.filePrefix = logs- #是否按照时间滚动文件夹 a2.sinks.k2.hdfs.round = true #多少时间单位创建一个新的文件夹 a2.sinks.k2.hdfs.roundValue = 1 #重新定义时间单位 a2.sinks.k2.hdfs.roundUnit = hour #是否使用本地时间戳 a2.sinks.k2.hdfs.useLocalTimeStamp = true #积攒多少个Event才flush到HDFS一次 #下面三个是或的关系 a2.sinks.k2.hdfs.batchSize = 100 #多久生成一个新的文件 建议修改为0避免产生大量的小文件,或者修改为更长的时间 a2.sinks.k2.hdfs.rollInterval =10 #设置每个文件的滚动大小 a2.sinks.k2.hdfs.rollSize = 134217700 #文件的滚动与Event数量无关 a2.sinks.k2.hdfs.rollCount = 0 # Use a channel which buffers events in memory #可能回丢失数据 a2.channels.c2.type = memory a2.channels.c2.capacity = 10000 a2.channels.c2.transactionCapacity = 1000 # Bind the source and sink to the channel a2.sources.r2.channels = c2 a2.sinks.k2.channel = c2 #我的flume的安装目录 /export/servers/flume #启用命令 flume-ng agent -c conf/ -n a2 -f myagents/flume-file-hdfs.conf