Flume採集Nginx日誌到HDFS

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.