日誌收集器fluentd:配置forward從客戶機到收集入庫端

轉載請聲明出處:http://blackwing.iteye.com/blog/2152319

試用了fluentd,挺方便易用,支持直接到hdfs,hbase,mangoDB等,可以跟已有業務結合。
安裝fluentd非常簡單,官方教材地址:[url]http://docs.fluentd.org/categories/installation[/url]

以下是針對ubuntu 12.04 LTS進行說明:
1.先修改系統環境,例如增加open files數目、修改網絡參數等:[url]http://docs.fluentd.org/articles/before-install[/url]

2.根據自己系統版本,直接執行官方寫好的一鍵安裝腳本:
curl -L http://toolbelt.treasuredata.com/sh/install-ubuntu-precise-td-agent2.sh | sh


安裝好後,個文件路徑爲:
1)配置文件:/etc/td-agent/td-agent.conf
2)起停腳本:/etc/init.d/td-agent start|stop|restart|status
3)默認log路徑:/var/log/td-agent/td-agent.log

應用場景是:收集其他部門某應用的log,發回到本部門服務器,併入庫到hdfs。所以需要在某部門服務器上,安裝fluentd用於把日誌forward到本地服務。

借用官方圖解:
[img]http://docs.fluentd.org/images/fluentd_ha.png[/img]

官方的配置可以參考高可用部分的配置:[url]http://docs.fluentd.org/articles/high-availability[/url]

大概配置如下:
forward端的配置:
<source>
type forward
port 24224
</source>

# Log Forwarding
<match testforward.**>
type forward
host 172.19.99.176
flush_interval 10s
</match>


聚集端的配置:
<source>
type forward
port 24224
</source>

<match testforward.*>
type webhdfs
host namenode
port 50070
path /log/%Y%m%d_%H/access.log.${hostname}
flush_interval 10s
</match>



但官方沒有詳細說明,導致配置後fluentd不能啓動,其實原來的td-agent.conf配置文件已經有以下配置:

<source>
type forward
</source>


所以,會有兩個forward的source,導致fluentd啓動失敗,報錯說端口24224已經在使用,解決辦法是刪掉以上默認配置就行。


現在可以測試curl一條信息到forward機器,它就會直接把細心轉發到聚集機器,並且自動入庫到hdfs。

另外,關於其他日誌收集工具,請看董西成的blog:[url]http://dongxicheng.org/search-engine/log-systems/[/url]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章