CentOS 7 gemインストールfluentd


ELKでのlogstashが肥大化しすぎてCPUやメモリが大きすぎて、
パフォーマンスが向上し、リソース消費が低い代替品が必要です.fluentdは私たちが望んでいるものです.
試験は,同じ負荷の場合fluentdの性能がlogstashの数倍であることを示した.
元のログ収集アーキテクチャ
filebeat >kafka > logstash > elasticsearch > kibana
新しいログ収集アーキテクチャ
filebeat > kafka > fluentd > elasticsearch > kibana
CentOS 7はrubyバージョンが低すぎるため、ここではruby 2.4.1を使用してfluentdをインストールする.
1、持参したrubyをアンインストールする
yum remove ruby -y

2、ruby 2.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個の同時処理が可能であることが知られている.
性が需要を満たすことができなければ、プロセスを多く開くことができます.