2021年9月5日21:41:08
ファイアウォールの無効化
systemctl stop firewalld
systemctl stop iptables
systemctl disable firewalld.service
systemctl disable iptables.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
JAVAのインストール
公式サイト: http://openjdk.java.net/install/
参考: https://www.cnblogs.com/mabiao008/p/12059069.html
以前は直接実行ファイルを用いていたが、現在は別の方法を採用する必要がある。
注意: 現在はyumでも環境変数の設定が必要で、やや非直感的。
yum install java-1.8.0-openjdk
yum install java-1.8.0-openjdk-devel.x86_64
JDKのパス: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64
環境変数の設定
javaコマンドは使用可能だが、jpsなどの関連コマンドは使用できない。
vi /etc/profile
JVM_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64
JRE_HOME=$JVM_HOME/jre
CLASS_PATH=.:$JVM_HOME/lib/dt.jar:$JVM_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JVM_HOME/bin:$JRE_HOME/bin
export JVM_HOME JRE_HOME CLASS_PATH PATH
バージョン管理の重要性
A: https://www.elastic.co/cn/downloads/past-releases#filebeat
過去バージョンの整合性を確認し、elasticsearch-analysis-ikのバージョンを一致させることが推奨される。
- 3つのソフトウェアのバージョンを統一することを強く推奨。
- FilebeatとKibanaはyumでインストールすることを推奨。
- Elasticsearchクラスタ構築時は3ノード以上を推奨。
- Elasticsearchを先に起動しないとKibanaが起動できない。
Elasticsearch Yumリポジトリの追加
https://www.elastic.co/guide/en/beats/filebeat/7.14/setup-repositories.html#_yum
sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
/etc/yum.repos.d/にelastic.repoを作成:
[elastic-7.x]
name=Elastic repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
Filebeatのインストール
https://www.elastic.co/cn/downloads/beats/filebeat
systemctl enable filebeat
systemctl start filebeat
設定ファイルディレクトリ: /etc/filebeat
Kibanaのインストール
https://www.elastic.co/cn/downloads/kibana
yum install kibana
systemctl enable kibana
systemctl start kibana
設定ファイル: /etc/kibana
ポート: 5601
Grafanaのインストール
https://grafana.com/grafana/download?pg=get&plcmt=selfmanaged-box1-cta1
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.1.3-1.x86_64.rpm
sudo yum install grafana-enterprise-8.1.3-1.x86_64.rpm
systemctl start grafana-server
systemctl enable grafana-server
ポート: 3000
Elasticsearchのインストール
yum search elasticsearch
yum install elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-linux-x86_64.tar.gz
単体運用はyumでインストール可能。注意: Elasticsearchはroot以外のユーザーで実行すること。
設定ファイルの編集
http.cors.enabled: true
http.cors.allow-origin: "*"
systemctl stop elasticsearch
systemctl start elasticsearch
プラグインディレクトリ: /usr/share/elasticsearch/plugins
基本設定例
cluster.name: my-cluster
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
echo "bootstrap.memory_lock: false" >> /etc/elasticsearch/elasticsearch.yml
echo "bootstrap.system_call_filter: false" >> /etc/elasticsearch/elasticsearch.yml
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 131072" >> /etc/security/limits.conf
echo "* soft nproc 4096" >> /etc/security/limits.conf
echo "* hard nproc 4096" >> /etc/security/limits.conf
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
sysctl -p
cd /etc/elasticsearch/
echo "ES_HEAP_SIZE=8g" >> elasticsearch-env
IK Analyzerのインストール
https://github.com/medcl/elasticsearch-analysis-ik/releases
ESバージョンと整合性を確認してからプラグインをコピー。
elasticsearch-headのインストール
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install
npm run start
アクセスURL: http://localhost:9100/
Filebeat設定例
filebeat.inputs:
- type: log
paths:
- /var/log/*.log
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
output.elasticsearch:
hosts: ["127.0.0.1:9200"]
Kibana設定例
server.port: 5601
server.host: "192.168.1.100"
elasticsearch.hosts: ["http://127.0.0.1:9200"]