I've setup an ES cluster inside docker like described here:
version: '2' services: elasticsearch1: image: docker.elastic.co/elasticsearch/elasticsearch:5.5.2 container_name: elasticsearch1 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata1:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - esnet elasticsearch2: image: docker.elastic.co/elasticsearch/elasticsearch:5.5.2 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - "discovery.zen.ping.unicast.hosts=elasticsearch1" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata2:/usr/share/elasticsearch/data networks: - esnet volumes: `Preformatted text` esdata1: driver: local esdata2: driver: local networks: esnet:
This works fine but I still don't really understand the setup. For example. When I want to connect from my logstash to my ES. To which node do I have to connect? (elastichsearch1 and elastichsearch2 or only elasticsearch1?. (I make the connection internal in docker).
Only ES1 has exposed its ports so when I perform API commands it's always on ES node1. Is ES node2 taking all the info and is it some pure replication of ES1? And when ES1 goes down will ES2 take it over?
(Still connect to 1 but route immediatly to 2 or how is this working?)
I really need a full explanation about the 2 nodes of ES in docker and how they are working together and how I'm supposed to communicate with this cluster.