http://my.oschina.net/u/204498/blog/601449shell
Logger Sink
apache
Logs會輸出到console,是爲了debug用的。oop
[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_tail agent.channels = memoryChannel agent.sinks = loggerSink agent.sources.exec_tail.type = exec agent.sources.exec_tail.command = tail -F /opt/flume-data/exec-tail.log agent.sources.exec_tail.channels = memoryChannel agent.sinks.loggerSink.type = logger agent.sinks.loggerSink.channel = memoryChannel agent.channels.memoryChannel.type = memory agent.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 Sinkui
[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 = memoryChannel agent.sinks = hdfs_sink agent.sources.exec_tail.type = exec agent.sources.exec_tail.command = tail -F /opt/flume-data/exec-tail.log agent.sources.exec_tail.interceptors = i1 agent.sources.exec_tail.interceptors.i1.type = org.apache.flume.interceptor.TimestampInterceptor$Builder agent.sources.exec_tail.channels = memoryChannel agent.sinks.hdfs_sink.type = hdfs agent.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,則disable agent.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.codeC agent.sinks.hdfs_sink.hdfs.writeFormat = Text agent.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 = memoryChannel agent.channels.memoryChannel.type = memory agent.channels.memoryChannel.capacity = 100
File Roll Sinkspa
[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-1 agent.channels = memoryChannel agent.sinks = file_roll-1 agent.sources.exec_tail-1.type = exec agent.sources.exec_tail-1.command = tail -F /opt/flume-data/exec-tail.log agent.sources.exec_tail-1.channels = memoryChannel agent.sinks.file_roll-1.type = file_roll agent.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 = memoryChannel agent.channels.memoryChannel.type = memory agent.channels.memoryChannel.capacity = 100
Kafka Sink.net