尝试使用Fluentd/Elasticsearch/kibana:(1)安装
首先
这是关于尝试流行的fluentd、Elasticsearch和kibana时的记录,它们在日志收集和可视化方面被广泛使用。
由于这些工具似乎适用于多种应用,我打算以它们为中心进行各种测试。
暂且不考虑冗余性等问题,我们的目标是在一个环境中进行最基本的功能测试。
相关文章
尝试使用fluentd/Elasticsearch/kibana:
(1)安装fluentd/Elasticsearch/kibana
(2)基本配置/启动/停止fluentd/Elasticsearch/kibana
整体描述/总览
使用Fluentd收集和处理日志,并将其存储在Elasticsearch中。假设存储的数据通过Kibana进行可视化。
Fluentd (流利收集器)
这是一个用于日志收集的中间件。
提供了各种支持功能,以便收集和处理位于不同位置且有不同格式的日志。
开发者:TreasureData Inc.
许可证:Apache License 2.0
弹性搜索
这个中间件提供了作为存储收集的数据的数据存储功能,以及搜索这些数据的功能。它使用了名为Apache Lucene的全文搜索库进行开发,由Elastic公司进行开发,并在Apache License 2.0下授权。
可视化分析工具
这是用于数据分析和可视化的工具。可以通过Web用户界面进行聚合处理、图形化和仪表板创建等操作。
开发者: Elastic公司
许可证: Apache许可证2.0
环境信息
尽量使用最新版本。
REHL V7.5
fluentd V1.0 (td-agent V3)
Elasticsearch V6.2
kibana V6.2
安装
流畅日志
通过rpm包安装Fluentd的参考步骤。
按照上面链接的指示,使用curl获取并执行安装用的shell脚本!
[root@test06 ~]# curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent3.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 849 100 849 0 0 1862 0 --:--:-- --:--:-- --:--:-- 1865
==============================
td-agent Installation Script
==============================
This script requires superuser access to install rpm packages.
You will be prompted for your password by sudo.
読み込んだプラグイン:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
treasuredata | 2.9 kB 00:00:00
読み込んだプラグイン:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ td-agent.x86_64 0:3.1.1-0.el7 を インストール
--> 依存性の処理をしています: redhat-lsb-core のパッケージ: td-agent-3.1.1-0.el7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ redhat-lsb-core.x86_64 0:4.1-27.el7 を インストール
--> 依存性の処理をしています: redhat-lsb-submod-security(x86-64) = 4.1-27.el7 のパッケージ: redhat-lsb-core-4.1-27.el7.x86_64
--> 依存性の処理をしています: spax のパッケージ: redhat-lsb-core-4.1-27.el7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ redhat-lsb-submod-security.x86_64 0:4.1-27.el7 を インストール
---> パッケージ spax.x86_64 0:1.5.2-13.el7 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
==========================================================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
==========================================================================================================================
インストール中:
td-agent x86_64 3.1.1-0.el7 treasuredata 44 M
依存性関連でのインストールをします:
redhat-lsb-core x86_64 4.1-27.el7 rhel-dvd 37 k
redhat-lsb-submod-security x86_64 4.1-27.el7 rhel-dvd 15 k
spax x86_64 1.5.2-13.el7 rhel-dvd 260 k
トランザクションの要約
==========================================================================================================================
インストール 1 パッケージ (+3 個の依存関係のパッケージ)
総ダウンロード容量: 44 M
インストール容量: 148 M
Downloading packages:
警告: /run/media/root/RHEL-7.5 Server.x86_64/Packages/redhat-lsb-core-4.1-27.el7.x86_64.rpm: ヘッダー V3 RSA/SHA256 Signature、鍵 ID fd431d51: NOKEY
redhat-lsb-core-4.1-27.el7.x86_64.rpm の公開鍵がインストールされていません
td-agent-3.1.1-0.el7.x86_64.rpm | 44 MB 00:00:14
--------------------------------------------------------------------------------------------------------------------------
合計 3.1 MB/s | 44 MB 00:00:14
file:///run/media/root/RHEL-7.5%20Server.x86_64/RPM-GPG-KEY-redhat-release から鍵を取得中です。
Importing GPG key 0xFD431D51:
Userid : "Red Hat, Inc. (release key 2) <security@redhat.com>"
Fingerprint: 567e 347a d004 4ade 55ba 8a5f 199e 2f91 fd43 1d51
From : /run/media/root/RHEL-7.5%20Server.x86_64/RPM-GPG-KEY-redhat-release
Importing GPG key 0x2FA658E0:
Userid : "Red Hat, Inc. (auxiliary key) <security@redhat.com>"
Fingerprint: 43a6 e49c 4a38 f4be 9abf 2a53 4568 9c88 2fa6 58e0
From : /run/media/root/RHEL-7.5%20Server.x86_64/RPM-GPG-KEY-redhat-release
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : spax-1.5.2-13.el7.x86_64 1/4
インストール中 : redhat-lsb-submod-security-4.1-27.el7.x86_64 2/4
インストール中 : redhat-lsb-core-4.1-27.el7.x86_64 3/4
インストール中 : td-agent-3.1.1-0.el7.x86_64 4/4
adding 'td-agent' group...
adding 'td-agent' user...
Installing default conffile...
prelink detected. Installing /etc/prelink.conf.d/td-agent-ruby.conf ...
Configure td-agent to start, when booting up the OS...
THANK YOU FOR USING TREASURE DATA’s PACKAGED VERSION OF FLUENTD (TD-AGENT). IF YOU ARE NOT A TREASURE DATA CUSTOMER AND NEED HELP TROUBLESHOOTING OR THE ENTERPRISE VERSION VISIT https://fluentd.treasuredata.com
rhel-dvd/productid | 1.6 kB 00:00:00
検証中 : redhat-lsb-core-4.1-27.el7.x86_64 1/4
検証中 : redhat-lsb-submod-security-4.1-27.el7.x86_64 2/4
検証中 : spax-1.5.2-13.el7.x86_64 3/4
検証中 : td-agent-3.1.1-0.el7.x86_64 4/4
インストール:
td-agent.x86_64 0:3.1.1-0.el7
依存性関連をインストールしました:
redhat-lsb-core.x86_64 0:4.1-27.el7 redhat-lsb-submod-security.x86_64 0:4.1-27.el7 spax.x86_64 0:1.5.2-13.el7
完了しました!
Installation completed. Happy Logging!
在Shell脚本中,为了安装fluentd,需要添加新的yum存储库并通过yum进行安装。也就是说,需要有Internet连接。
执行后,以下存储库定义将被添加。
[treasuredata]
name=TreasureData
baseurl=http://packages.treasuredata.com/3/redhat/$releasever/$basearch
gpgcheck=1
gpgkey=https://packages.treasuredata.com/GPG-KEY-td-agent
文件将解压缩在以下位置。
-
- モジュール類: /opt/td-agent/
-
- 構成ファイル: /etc/td-agent/td-agent.conf
- ログ: /var/log/td-agent/
以下的内容似乎可以通过下载Fluentd的rpm软件包来进行安装。
弹性搜索
参考:手动使用RPM安装Elasticsearch-下载并安装RPM
可以下载和解压ZIP文件, 但由于可以使用systemd进行启动/停止管理,建议使用RPM进行安装。
这里将尝试下载RPM软件包并使用rpm命令进行安装。
[root@test06 /Inst_Image/elasticsearch624]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.rpm
--2018-05-22 10:49:06-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.rpm
artifacts.elastic.co (artifacts.elastic.co) をDNSに問いあわせています... 107.21.237.188, 107.21.253.15, 107.21.237.95, ...
artifacts.elastic.co (artifacts.elastic.co)|107.21.237.188|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 28992177 (28M) [binary/octet-stream]
`elasticsearch-6.2.4.rpm' に保存中
100%[================================================================================>] 28,992,177 694KB/s 時間 26s
2018-05-22 10:49:33 (1.06 MB/s) - `elasticsearch-6.2.4.rpm' へ保存完了 [28992177/28992177]
[root@test06 /Inst_Image/elasticsearch624]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.rpm.sha512
--2018-05-22 10:49:39-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.rpm.sha512
artifacts.elastic.co (artifacts.elastic.co) をDNSに問いあわせています... 184.73.245.233, 107.21.253.15, 107.21.237.188, ...
artifacts.elastic.co (artifacts.elastic.co)|184.73.245.233|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 153 [application/octet-stream]
`elasticsearch-6.2.4.rpm.sha512' に保存中
100%[================================================================================>] 153 --.-K/s 時間 0s
2018-05-22 10:49:40 (11.0 MB/s) - `elasticsearch-6.2.4.rpm.sha512' へ保存完了 [153/153]
[root@test06 /Inst_Image/elasticsearch624]# shasum -a 512 -c elasticsearch-6.2.4.rpm.sha512
elasticsearch-6.2.4.rpm: OK
[root@test06 /Inst_Image/elasticsearch624]# rpm -ivh elasticsearch-6.2.4.rpm
警告: elasticsearch-6.2.4.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID d88e42b4: NOKEY
準備しています... ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
更新中 / インストール中...
1:elasticsearch-0:6.2.4-1 ################################# [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
文件会被提取到以下位置附近。
-
- モジュール類: /usr/share/elasticsearch/
-
- 構成ファイル: /etc/elasticsearch/elasticsearch.yml
- ログ: /var/log/elasticsearch/
Kibana 可视化分析工具
参考:手动使用RPM包安装Kibana – 下载并手动安装RPM包。
在这里,我们将尝试下载rpm包并使用rpm命令进行安装。
步骤与elasticsearch相似。
[root@test06 /Inst_Image/kibana]# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.4-x86_64.rpm
--2018-05-22 13:11:26-- https://artifacts.elastic.co/downloads/kibana/kibana-6.2.4-x86_64.rpm
artifacts.elastic.co (artifacts.elastic.co) をDNSに問いあわせています... 107.21.253.15, 107.21.237.188, 23.23.109.100, ...
artifacts.elastic.co (artifacts.elastic.co)|107.21.253.15|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 87218216 (83M) [binary/octet-stream]
`kibana-6.2.4-x86_64.rpm' に保存中
100%[================================================================================>] 87,218,216 1.43MB/s 時間 72s
2018-05-22 13:12:39 (1.16 MB/s) - `kibana-6.2.4-x86_64.rpm' へ保存完了 [87218216/87218216]
[root@test06 /Inst_Image/kibana]# shasum -a 512 kibana-6.2.4-x86_64.rpm
4a8d9c262da1679ba15b323f3eaedbd9d6f3dab9f74b326c8f17442ad23692f0bd2a81a396691e3c1627017923e14bba40bc24b7349003cfdd127c9492829105 kibana-6.2.4-x86_64.rpm
[root@test06 /Inst_Image/kibana]# rpm -ivh kibana-6.2.4-x86_64.rpm
警告: kibana-6.2.4-x86_64.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID d88e42b4: NOKEY
準備しています... ################################# [100%]
更新中 / インストール中...
1:kibana-6.2.4-1 ################################# [100%]
文件将会被解压缩在以下区域。
-
- モジュール類: /usr/share/kibana/
- 構成ファイル: /etc/kibana/kibana.yml
安装过程到此结束。相当顺利完成了。