Below is the docker compose file which i am using deploy it as swarm.
version: '3.7'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- bootstrap.memory_lock=false
- network.host=0.0.0.0
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.zen.ping.unicast.hosts=es01,es02
- discovery.zen.minimum_master_nodes=1
- node.master=true
- node.data=true
- node.ingest=true
volumes:
- /opt/es01:/usr/share/elasticsearch/data
ports:
- 9200:9200
deploy:
placement:
constraints:
- "node.hostname == node1"
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- bootstrap.memory_lock=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.zen.ping.unicast.hosts=es01,es02
- discovery.zen.minimum_master_nodes=1
- node.master=false
- node.data=true
- node.ingest=true
volumes:
- /opt/es02:/usr/share/elasticsearch/data
deploy:
placement:
constraints:
- "node.hostname == node2"
Here are the logs from node1:
{"type": "server", "timestamp": "2020-03-30T06:30:40,328Z", "level": "INFO", "component": "o.e.c.s.MasterService", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "elected-as-master ([1] nodes joined)[{es01}{TxAWx5BJRKWaFA4_n7dIDA}{OlRlsCl9SrCT9qNDlbIjSQ}{10.0.61.3}{10.0.61.3:9300}{dilm}{ml.machine_memory=135024914432, xpack.installed=true, ml.max_open_jobs=20} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 9, version: 40, delta: master node changed {previous [], current [{es01}{TxAWx5BJRKWaFA4_n7dIDA}{OlRlsCl9SrCT9qNDlbIjSQ}{10.0.61.3}{10.0.61.3:9300}{dilm}{ml.machine_memory=135024914432, xpack.installed=true, ml.max_open_jobs=20}]}" }
{"type": "server", "timestamp": "2020-03-30T06:30:40,377Z", "level": "INFO", "component": "o.e.c.s.ClusterApplierService", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "master node changed {previous [], current [{es01}{TxAWx5BJRKWaFA4_n7dIDA}{OlRlsCl9SrCT9qNDlbIjSQ}{10.0.61.3}{10.0.61.3:9300}{dilm}{ml.machine_memory=135024914432, xpack.installed=true, ml.max_open_jobs=20}]}, term: 9, version: 40, reason: Publication{term=9, version=40}" }
{"type": "server", "timestamp": "2020-03-30T06:30:40,418Z", "level": "INFO", "component": "o.e.h.AbstractHttpServerTransport", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "publish_address {10.0.61.3:9200}, bound_addresses {0.0.0.0:9200}", "cluster.uuid": "_s5dqoIUSAyNPNUvb-TeBg", "node.id": "TxAWx5BJRKWaFA4_n7dIDA" }
{"type": "server", "timestamp": "2020-03-30T06:30:40,418Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "started", "cluster.uuid": "_s5dqoIUSAyNPNUvb-TeBg", "node.id": "TxAWx5BJRKWaFA4_n7dIDA" }
{"type": "server", "timestamp": "2020-03-30T06:30:40,627Z", "level": "INFO", "component": "o.e.l.LicenseService", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "license [2db2e78c-fd6f-4c49-b4a6-a230739bac5c] mode [basic] - valid", "cluster.uuid": "_s5dqoIUSAyNPNUvb-TeBg", "node.id": "TxAWx5BJRKWaFA4_n7dIDA" }
{"type": "server", "timestamp": "2020-03-30T06:30:40,628Z", "level": "INFO", "component": "o.e.x.s.s.SecurityStatusChangeListener", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "Active license is now [BASIC]; Security is disabled", "cluster.uuid": "_s5dqoIUSAyNPNUvb-TeBg", "node.id": "TxAWx5BJRKWaFA4_n7dIDA" }
{"type": "server", "timestamp": "2020-03-30T06:30:40,637Z", "level": "INFO", "component": "o.e.g.GatewayService", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "recovered [0] indices into cluster_state", "cluster.uuid": "_s5dqoIUSAyNPNUvb-TeBg", "node.id": "TxAWx5BJRKWaFA4_n7dIDA" }
logs from node 2:
{"type": "server", "timestamp": "2020-03-30T06:29:00,459Z", "level": "DEBUG", "component": "o.e.a.ActionModule", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "Using REST wrapper from plugin org.elasticsearch.xpack.security.Security" }
{"type": "server", "timestamp": "2020-03-30T06:29:00,577Z", "level": "INFO", "component": "o.e.d.DiscoveryModule", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "using discovery type [zen] and seed hosts providers [settings]" }
{"type": "server", "timestamp": "2020-03-30T06:29:01,403Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "initialized" }
{"type": "server", "timestamp": "2020-03-30T06:29:01,403Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "starting ..." }
{"type": "server", "timestamp": "2020-03-30T06:29:01,525Z", "level": "INFO", "component": "o.e.t.TransportService", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "publish_address {10.0.60.12:9300}, bound_addresses {0.0.0.0:9300}" }
{"type": "server", "timestamp": "2020-03-30T06:29:01,789Z", "level": "INFO", "component": "o.e.b.BootstrapChecks", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "bound or publishing to a non-loopback address, enforcing bootstrap checks" }
ERROR: [2] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /usr/share/elasticsearch/logs/es-docker-cluster.log
{"type": "server", "timestamp": "2020-03-30T06:29:01,827Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "stopping ..." }
{"type": "server", "timestamp": "2020-03-30T06:29:01,848Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "stopped" }
{"type": "server", "timestamp": "2020-03-30T06:29:01,848Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "closing ..." }
{"type": "server", "timestamp": "2020-03-30T06:29:01,864Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "closed" }
{"type": "server", "timestamp": "2020-03-30T06:29:01,881Z", "level": "INFO", "component": "o.e.x.m.p.NativeController", "cluster.name": "es-docker-cluster", "node.name": "es02", "message": "Native controller process has stopped - no new native processes can be started" }