CentOS 7 gem 安裝fluentd

由於ELK中的logstash 太過臃腫,CPU和內存使用過大,

我們需要一個性能更好,資源消耗低的替代品。fluentd就是我們想要的。

測試表明,在相同負載情況下,fluentd的性能數倍於logstash。


原日誌收集架構

filebeat >kafka > logstash > elasticsearch > kibana


新日誌收集架構

filebeat > kafka > fluentd > elasticsearch > kibana


由於CentOS7 自帶ruby版本過低,本文使用ruby 2.4.1 安裝fluentd .


1、卸載自帶的ruby

yum remove ruby -y


2、安裝ruby2.4.1

yum install http://120.24.7.75:8000/centos/7/x86_64/ruby2.4-2.4.1-1.el7.centos.x86_64.rpm


3、調整gem源

gem sources  #列出默認源
gem sources --remove https://rubygems.org/  #移除默認源
gem sources -a https://mirrors.ustc.edu.cn/rubygems/  #添加科大源


4、安裝編譯環境和軟件包依賴

yum install gcc gcc-c++ make automake autoconf libtool openssl-devel jemalloc-devel gmp-devel -y


5、安裝fluentd

gem install fluentd --no-ri --no-rdoc


6、安裝fluent插件

gem install fluent-plugin-kafka --no-ri --no-rdoc
gem install fluent-plugin-elasticsearch --no-ri --no-rdoc


7、初始化fluentd

fluentd --setup /etc/fluentd

前臺debug 測試,用於檢查配置文件

fluentd -c /etc/fluentd/fluentd/fluent.conf -vv


8、創建啓動腳本/usr/lib/systemd/system/fluentd.service

[Unit]
Description=Fluentd
Documentation=http://www.fluentd.org/
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/fluentd -c /etc/fluentd/fluent.conf
Restart=on-failure
User=fluentd
Group=fluentd

[Install]
WantedBy=multi-user.target


9、啓動fluentd

 systemctl daemon-reload
 systemctl enable fluentd
 systemctl start fluentd


fluentd 是cruby寫的,受限於GIL,無法利用多核CPU,已知每個CPU可處理5000個併發,

如果性能不能滿足需求,可以進程多開。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章