How does one setup a clustered elasticsearch?

Hello,

I'm on the verge of raging and flipping my desk. I have tried to setup a elasticsearch cluster version 7.2.0 and this is just not working. Here's my problem: Each master node is creating their own single node cluster. I understand why this is happening as my config says the following:

cluster.initial_master_nodes:
 - ${NODE_NAME}
discovery.seed_hosts:
 - ${NODE_NAME}

Above is issue 1. So lets say I put in the following config:

cluster.initial_master_nodes:
      - elasticsearch-master01
      - elasticsearch-master02
      - elasticsearch-master03
 discovery.seed_hosts:
      - ${NODE_NAME}

Then I get the following error in my logs:

"message": "skipping cluster bootstrapping as local node does not match bootstrap requirements: [elasticsearch-master01, elasticsearch-master02, elasticsearch-master03]"
"message": "master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and this node must discover master-eligible nodes [elasticsearch-master01, elasticsearch-master02, elasticsearch-master03] to bootstrap a cluster: have discovered []; discovery will continue using [] from hosts providers and.....

Above is issue 2. So lets say I put in the following config:

cluster.initial_master_nodes:
      - elasticsearch-master01
      - elasticsearch-master02
      - elasticsearch-master03

 discovery.seed_hosts:
      - elasticsearch-discovery

Then guess what....I get the same error as number 2.

"message": "skipping cluster bootstrapping as local node does not match bootstrap requirements: [elasticsearch-master01, elasticsearch-master02, elasticsearch-master03]"
"message": "master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and this node must discover master-eligible nodes [elasticsearch-master01, elasticsearch-master02, elasticsearch-master03] to bootstrap a cluster: have discovered []; discovery will continue using [] from hosts providers and.....

Above is issue 3. Issue number 3's config is based on elasticsearch own configuration:

https://www.elastic.co/guide/en/elasticsearch/reference/current/discovery-settings.html

I use the default port on the discovery 9300.

Here is my complete config:

cluster:
  name: elastic

node.master: true
node.data: true
node.ingest: true

processors: ${PROCESSORS:1}

network.host: 0.0.0.0

cluster.initial_master_nodes:
  - elasticsearch-master01
  - elasticsearch-master02
  - elasticsearch-master03

path:
  data: /data/data
  logs: /data/log

discovery.seed_hosts:
  - elasticsearch-discovery

xpack.license.self_generated.type: basic
xpack.monitoring.enabled: true
xpack.security.enabled: true
xpack.watcher.enabled: false
xpack.ml.enabled: false
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /usr/share/elasticsearch/config/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /usr/share/elasticsearch/config/elastic-certificates.p12

xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.verification_mode: certificate
xpack.security.http.ssl.keystore.path: /usr/share/elasticsearch/config/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: /usr/share/elasticsearch/config/elastic-certificates.p12
xpack.security.http.ssl.client_authentication: optional

SO! I must have missed something, can someone please explain what.

Solved! for anyone who comes accross this, you have to match you pod name with the name in the cluster.initial_master_nodes:

I did this by setting a static name in the NODE_NAME in my deployment file and then in the config, node.name: ${NODE_NAME}

1 Like

Yes, that looks like it was exactly the problem. Here is a link to the relevant docs to give future readers a bit more context too:

The node names used in the cluster.initial_master_nodes list must exactly match the node.name properties of the nodes.