開源日誌收集軟體fluentd 轉寄(forward)架構配置

來源:互聯網
上載者:User

標籤:hadoop   hdfs   fluentd   

需求:

通過開源軟體fluentd收集各個裝置的apache訪問日誌到fluentd的轉寄伺服器中,然後通過webHDFS介面,寫入到hdfs檔案系統中。


軟體版本說明:

hadoop版本:1.1.2

fluentd版本:1.1.21


測試環境說明:

node29伺服器上安裝了apache,以及fluentd,作為fluentd的用戶端;

node1伺服器,為hadoop伺服器的namenode;


node29伺服器上fluentd設定檔:

<source>  type tail  format apache2  path /var/log/httpd/access_log  pos_file /var/log/td-agent/access_log.pos  time_format %Y-%m-%d %H:%M:%S  localtime  tag apache.access </source>#Log Forwarding to node1 server<match apache.access>  type forward#  time_slice_format %Y%m%d#  time_slice_wait 10m#  localtime #定義日誌入庫日誌的時間;  time_format %Y-%m-%d %H:%M:%S#localtime非常重要,不設定日誌時間和系統時間相差8小時;    localtime #定義入庫日誌的時間;   <server>  host node1  port 24224  </server>   flush_interval 1s</match>


node1伺服器配置,這個伺服器上配置了hadoop的namenode,以及作為fluentd的轉寄角色,具體設定檔如下:

<source>  type forward  port 24224</source>


<match apache.access>

  type webhdfs

  host node1.test.com

  port 50070

  path /apache/%Y%m%d_%H/access.log.${hostname}

  time_slice_format %Y%m%d

  time_slice_wait 10m


#定義日誌入庫日誌的時間;

  time_format %Y-%m-%d %H:%M:%S

  localtime


  flush_interval 1s

</match>


配置好以後,重啟fluentd服務;


開始測試,在node29用ab命令開始訪問apache,產生訪問日誌;

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/58/2E/wKioL1Srm8vR_ovaAAPZIkcRXtw457.jpg" title="ab.png" alt="wKioL1Srm8vR_ovaAAPZIkcRXtw457.jpg" />



然後,到node1伺服器上去查看HDFS檔案系統中,是否產生了相關檔案及目錄:

查看產生的目錄:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/58/2E/wKioL1SrnD2T4tjMAANsBMDhnlw258.jpg" title="QQ圖片20150106162233.png" alt="wKioL1SrnD2T4tjMAANsBMDhnlw258.jpg" />


查看檔案裡面具體日誌:

hadoop fs -cat /apache/20150106_16/access.log.node1.test.com

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/58/32/wKiom1Srm-KBfz8qAAYjJTfE3zY387.jpg" title="QQ圖片20150106162421.png" alt="wKiom1Srm-KBfz8qAAYjJTfE3zY387.jpg" />


如所示,fluentd已經通過轉寄模式,把node29伺服器上apache日誌收集到hdfs檔案系統中了,方便下一步用hadoop進行離線分析。

本文出自 “shine_forever的部落格” 部落格,請務必保留此出處http://shineforever.blog.51cto.com/1429204/1599771

開源日誌收集軟體fluentd 轉寄(forward)架構配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.