CentOS Stream 9
Sponsored Link

Elastic Stack 8 : Elasticsearch Cluster2022/12/09

 
Configure Elasticsearch Cluster.
This example shows to configure Elasticsearch Cluster with 3 Nodes and configure each Node is Master Eligible Node and Data Node (default).
Each node serves one or more purpose, refer to details below.
⇒ https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html

[1]
[2] On the 1st node, start Elasticsearch and generate an enrollment token for other nodes.
[root@node01 ~]#
vi /etc/elasticsearch/elasticsearch.yml
# line 17 : uncomment and change (any name you like)

cluster.name:
elastic-cluster
# line 56 : uncomment and change (listen all)

network.host:
0.0.0.0
[root@node01 ~]#
systemctl enable --now elasticsearch
[root@node01 ~]#
/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node

eyJ2ZXIiOiI4LjUuMyIsImFkciI6WyIxMC4wLjAuNTE6OTIwMCJdLCJmZ3IiOiJjNjk2ZGIyMmFjMmY4Y2U2ZWQ4NTBjMTQ5ODMyN2VmNmE3ZmNiMDZiMjIzOTNlNTIxMjEwNTgyMzg0NjA3NTRkIiwia2V5IjoiVXVHODlZUUJCeElZUm9NSlBEMmk6YUFyT1E4V05SME9qZTJGY2hiZGtJUSJ9
[3] If Firewalld is running, allow service ports on all Nodes.
[root@node01 ~]#
firewall-cmd --add-port={9200/tcp,9300/tcp}

success
[root@node01 ~]#
firewall-cmd --runtime-to-permanent

success
[4] On other nodes, join in cluster with an enrollment token generated on the 1st node above.
[root@node02 ~]# /usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token \
eyJ2ZXIiOiI4LjUuMyIsImFkciI6WyIxMC4wLjAuNTE6OTIwMCJdLCJmZ3IiOiJjNjk2ZGIyMmFjMmY4Y2U2ZWQ4NTBjMTQ5ODMyN2VmNmE3ZmNiMDZiMjIzOTNlNTIxMjEwNTgyMzg0NjA3NTRkIiwia2V5IjoiVXVHODlZUUJCeElZUm9NSlBEMmk6YUFyT1E4V05SME9qZTJGY2hiZGtJUSJ9
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
# line 17 : uncomment and specify the same name with 1st node

cluster.name:
elastic-cluster
# line 56 : uncomment and change (listen all)

network.host:
0.0.0.0
[root@node02 ~]#
systemctl enable --now elasticsearch
[5] Verify Cluster status. If the status is green, That's 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.52           30          97   2    0.00    0.04     0.02 cdfhilmrstw -      node02.srv.world
10.0.0.51           37          96   1    0.16    0.06     0.05 cdfhilmrstw *      node01.srv.world
10.0.0.53           25          97   5    0.06    0.07     0.02 cdfhilmrstw -      node03.srv.world

[root@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" : 2,
  "active_shards" : 4,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_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
}
Matched Content