Elastic Stack : Elasticsearch クラスターを構成する2025/10/16 |
|
Elasticsearch クラスターを構成します。
当例では 3ノード構成で Elasticsearch クラスターを設定します。 ⇒ https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html |
|
| [1] |
こちらを参考に全ノードに Elasticsearch をインストールしておきます。(インストールのみで起動はしない) |
| [2] | 1 台目のノードで、Elasticsearch を起動して、認証トークンを発行しておきます。 |
|
root@node01:~#
vi /etc/elasticsearch/elasticsearch.yml # 17行目 : コメント解除して変更 (任意のクラスター名) cluster.name: elastic-cluster
# 56行目 : コメント解除して変更 (全てリスンする) network.host: 0.0.0.0
systemctl enable --now elasticsearch root@node01:~# /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node eyJ2ZXIiOiI4LjE0LjAiLCJhZHIiOlsiMTAuMC4wLjUxOjkyMDAiXSwiZmdyIjoiOGNmMTAyMjRlZTUxMDcwODZjYjM1OGNmODFiMjhmNTdlNzFlNmMxNzE1MTc3YzkxNGEwOTU1NWExNDhhZTkwMiIsImtleSI6InFtU1U2cGtCVHlfbmNTOEpqcTVOOkRUbFpXS3Exb3VpU1ZQTWt1b1pTbkEifQ== |
| [3] | 2 台目以降のノードで、1 台目のノードで発行した認証トークンを指定して、クラスターに参加します。 |
root@node02:~# /usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token \ eyJ2ZXIiOiI4LjE0LjAiLCJhZHIiOlsiMTAuMC4wLjUxOjkyMDAiXSwiZmdyIjoiOGNmMTAyMjRlZTUxMDcwODZjYjM1OGNmODFiMjhmNTdlNzFlNmMxNzE1MTc3YzkxNGEwOTU1NWExNDhhZTkwMiIsImtleSI6InFtU1U2cGtCVHlfbmNTOEpqcTVOOkRUbFpXS3Exb3VpU1ZQTWt1b1pTbkEifQ== This node will be reconfigured to join an existing cluster, using the enrollment token that you provided. This operation will overwrite the existing configuration. Specifically: - Security auto configuration will be removed from elasticsearch.yml - The [certs] config directory will be removed - Security auto configuration related secure settings will be removed from the elasticsearch.keystore Do you want to continue with the reconfiguration process [y/N]y
root@node02:~#
vi /etc/elasticsearch/elasticsearch.yml # 17行目 : コメント解除して変更 (1 台目と同じクラスター名) cluster.name: elastic-cluster
# 56行目 : コメント解除して変更 (全てリスンする) network.host: 0.0.0.0
systemctl enable --now elasticsearch
|
| [4] | 設定後はクラスターの状態を確認し、以下のように [status] が [green] 且つ ノードの数が設定数分の数値になっていれば OK です。 |
|
root@node01:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://node01.srv.world:9200/_cat/nodes?v Enter host password for user 'elastic': ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name 10.0.0.53 34 97 22 0.32 0.17 0.07 cdfhilmrstw - node03.srv.world 10.0.0.51 54 95 6 0.16 0.19 0.09 cdfhilmrstw * node01.srv.world 10.0.0.52 35 97 8 0.11 0.15 0.07 cdfhilmrstw - node02.srv.worldroot@node01:~# curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://node01.srv.world:9200/_cluster/health?pretty
Enter host password for user 'elastic':
{
"cluster_name" : "elastic-cluster",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 3,
"active_shards" : 6,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"unassigned_primary_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
|
| Sponsored Link |
|
|