標籤:type mem div nginx日誌 lint font style master .sh
下載apache-flume-1.7.0-bin.tar.gz,用
tar -zxvf
解壓,在/etc/profile檔案中增加設定:
export FLUME_HOME=/opt/apache-flume-1.7.0-binexport PATH=$PATH:$FLUME_HOME/bin
修改$FLUME_HOME/conf/下的兩個檔案,在flume-env.sh中增加JAVA_HOME:
JAVA_HOME=/opt/jdk1.8.0_121
最重要的,修改flume-conf.properties檔案:
# 配置Agenta1.sources = r1a1.sinks = k1a1.channels = c1# 配置Sourcea1.sources.r1.type = execa1.sources.r1.channels = c1a1.sources.r1.deserializer.outputCharset = UTF-8# 配置需要監控的日誌輸出目錄a1.sources.r1.command = tail -F /usr/local/nginx/log/access.log# 配置Sinka1.sinks.k1.type = hdfsa1.sinks.k1.channel = c1a1.sinks.k1.hdfs.useLocalTimeStamp = truea1.sinks.k1.hdfs.path = hdfs://master:9000/flume/events/%Y-%ma1.sinks.k1.hdfs.filePrefix = %Y-%m-%d-%Ha1.sinks.k1.hdfs.fileSuffix = .loga1.sinks.k1.hdfs.minBlockReplicas = 1a1.sinks.k1.hdfs.fileType = DataStreama1.sinks.k1.hdfs.writeFormat = Texta1.sinks.k1.hdfs.rollInterval = 86400a1.sinks.k1.hdfs.rollSize = 1000000a1.sinks.k1.hdfs.rollCount = 10000a1.sinks.k1.hdfs.idleTimeout = 0# 配置Channela1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# 將三者串連a1.sources.r1.channel = c1a1.sinks.k1.channel = c1
以上檔案設定了Source、Channel和Sink,將Nginx日誌中的記錄採集到HDFS,運行
flume-ng agent -n a1 -c conf -f $FLUME_HOME/conf/flume-conf.properties
如果沒有報錯,則安裝設定成功了,Nginx中新增加的記錄都會被Flume採集,並且儲存到HDFS。
Flume採集Nginx日誌到HDFS