OK.
For those who don't know so much like me
in Host-1 which is your master node host, You should up a cluster with just one master node and if you want use kibana.
and on the other Hosts You should setup a single node cluster and change seed_host and initial_master_node to your master node host.
then if everything ok you can see the joining message in master node logs and data node logs.
for eg.:
master node:
version: "2.2"
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
volumes:
- certs:/usr/share/elasticsearch/config/certs
- esdata01:/usr/share/elasticsearch/data
ports:
- ${ES_PORT}:9200
- 9300:9300
environment:
- network.publish_host="172.16.3.8"
- xpack.security.enabled=false
- node.name=es01
- network.host=0.0.0.0
- cluster.name=${CLUSTER_NAME}
- cluster.initial_master_nodes=172.16.3.8
- discovery.seed_hosts=172.16.3.8:9300
- node.roles=[master, remote_cluster_client]
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
- bootstrap.memory_lock=true
- reindex.remote.whitelist=172.12.30.10:9280
- xpack.license.self_generated.type=${LICENSE}
- ES_JAVA_OPTS=-Xms4g -Xmx4g
- reindex.ssl.verification_mode=none
mem_limit: ${MEM_LIMIT_NODE}
ulimits:
memlock:
soft: -1
hard: -1
healthcheck:
test:
[
"CMD-SHELL",
"curl localhost:9200/_cat/health",
]
interval: 10s
timeout: 10s
retries: 120
kibana:
depends_on:
es01:
condition: service_healthy
image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
volumes:
- certs:/usr/share/kibana/config/certs
- kibanadata:/usr/share/kibana/data
ports:
- 5601:5601
environment:
- SERVERNAME=kibana
- ELASTICSEARCH_HOSTS=http://es01:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
- SERVER_HOST=0.0.0.0
mem_limit: ${KIB_MEM_LIMIT}
healthcheck:
test:
[
"CMD-SHELL",
"curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'",
]
interval: 10s
timeout: 10s
retries: 120
volumes:
certs:
driver: local
esdata01:
driver: local
esdata02:
driver: local
kibanadata:
driver: local
data node:
version: '3.8'
services:
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.3
container_name: es03
ports:
- 9200:9200
- 9300:9300
environment:
- xpack.security.enabled=false
- network.publish_host="172.16.3.10"
- node.name=es03
- cluster.initial_master_nodes=172.16.3.8:9300
- cluster.name=docker-cluster
- node.roles=[data, remote_cluster_client]
- node.roles=data
- network.host=0.0.0.0
- discovery.seed_hosts=172.16.3.8:9300
- bootstrap.memory_lock=true
- ES_JAVA_OPTS=-Xms5g -Xmx5g
- reindex.ssl.verification_mode=none
mem_limit: ${MEM_LIMIT_NODE}
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata03:/usr/share/elasticsearch/data
networks:
- es-net
volumes:
esdata03:
driver: local
networks:
es-net:
driver: bridge