2
1

More than 1 year has passed since last update.

Elasticsearchクラスタ検証(3): Elasticsearch 8.xのクラスタ化(HTTPS未対応)

Last updated at Posted at 2022-08-11
[前回] Elasticsearchクラスタ検証(2): Elasticsearch 8.xを導入

はじめに

今回は、3ノードのElasticsearchクラスタを設定します。

  • node1: AlmaLinux8-1
  • node2: AlmaLinux8-2
  • node3: AlmaLinux8-3

node1で以下実施(管理者権限)

ファイアウォール設定

  • ノード間通信を可能にするため、ポート9200、9300へのアクセス許可
# firewall-cmd --add-port={9200,9300}/tcp --zone=public --permanent
# firewall-cmd --reload
# firewall-cmd --list-port
9200/tcp 9300/tcp

/etc/hostsに3ノードのIPアドレスを追加

172.21.192.11 node1
172.21.192.12 node2
172.21.192.13 node3

Elasticsearchのデータディレクトリを削除

  • Elasticsearchが既にシングルノードのクラスタで開始されたため、停止しデータディレクトリを削除
# systemctl stop elasticsearch
# rm -rf /var/lib/elasticsearch/*

Elasticsearch設定ファイルを変更

/etc/elasticsearch/elasticsearch.ymlで下記項目を設定し保存

  • クラスタ名
    • cluster.name: mycluster
  • クラスタ参加ノード
    • discovery.seed_hosts: ["node1", "node2", "node3"]
  • Elasticsearchサービスに他のノードからアクセス可能に
    • network.host: 0.0.0.0
  • セキュリティ機能を一旦無効に
    • xpack.security.enabled: false
    • xpack.security.enrollment.enabled: false
    • ※ クラスタ検証に集中するためで、実運用では有効にすべき
      • セキュリティ機能は重要であり、別途取り上げる予定です

Elasticsearchを起動しステータス確認

# systemctl start elasticsearch
# curl -q http://localhost:9200
{
  "name" : "node1",
  "cluster_name" : "mycluster",
  "cluster_uuid" : "1ry3LhAFRWCpBk2oGtowZA",
  "version" : {
    "number" : "8.3.3",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "801fed82df74dbe537f89b71b098ccaff88d2c56",
    "build_date" : "2022-07-23T19:30:09.227964828Z",
    "build_snapshot" : false,
    "lucene_version" : "9.2.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

node2でも上記と同じ手順を実施

node3でも上記と同じ手順を実施

いずれかのノードで、クラスタのステータスを確認

# curl -q http://localhost:9200/_cat/nodes?v
ip            heap.percent ram.percent cpu load_1m load_5m load_15m node.role   master name
172.21.192.12           23          96   4    0.24    0.20     0.08 cdfhilmrstw *      node2
172.21.192.13           18          93   3    0.19    0.17     0.08 cdfhilmrstw -      node3
172.21.192.11           20          96   4    0.11    0.10     0.03 cdfhilmrstw -      node1

期待とおり、クラスタにノードが三つ存在し、masterはnode1となっています。

おわりに

3ノードのElasticsearchクラスタを構築できました。
次回も続きます。お楽しみに。

[次回] Elasticsearchクラスタ検証(4): Elasticsearch 8.xのクラスタ化(HTTPS対応)
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1