Elastic cluster with docker externale elasticsearch.yml


(abdujaprov) #1

Hi,
I am trying to create an elasticsearch test cluster with docker.
I took compose from install elastic guide and I modified it using externale elasticsearch.yml.
My problem is that I cannot build the cluster, cluster.name is not set as in yml and moreover, no cluster is built.

elasticsearch.yml node1:
    cluster.name: es-db-cluster
    discovery.zen.minimum_master_nodes: 2
    discovery.zen.ping_timeout: 10s
    discovery.zen.ping.unicast.hosts: ["es1","es2"]
    bootstrap.memory_lock: true
    node.name: es1
    node.master: true

elasticsearch.yml node2:
    cluster.name: es-db-cluster
    discovery.zen.minimum_master_nodes: 2
    discovery.zen.ping_timeout: 10s
    discovery.zen.ping.unicast.hosts: ["es1","es2"]
    bootstrap.memory_lock: true
    node.name: es2
    node.master: false

docker-compose.yml is:
    version: '2.2'
    services:
      es1:
        image: blacktop/elasticsearch:6.2
        container_name: es1
        environment:
          - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
        volumes:
          - /home/docker/elasticsearch/node1/data:/usr/share/elasticsearch/data
          - /home/docker/elasticsearch/node1/elasticsearch.yml:/usr/share/elasticsearch/data/elasticsearch.yml
        ports:
          - 9200:9200
        networks:
          - esnet
      es2:
        image: blacktop/elasticsearch:6.2
        container_name: es2
        environment:
          - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
        volumes:
          - /home/docker/elasticsearch/node2/data:/usr/share/elasticsearch/data
          - /home/docker/elasticsearch/node2/elasticsearch.yml:/usr/share/elasticsearch/data/elasticsearch.yml
        networks:
          - esnet
    networks:
      esnet:

If I verify noded I see only node es1:
http://192.168.1.150:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.18.0.3 17 54 11 0.46 0.41 0.27 mdi * iXpylo8

cluster.name that I see is: "elasticsearch" and not "es-db-cluster". In container property file contains the correct values.

Where is the problems?

If I take the docker-compose.yml in elastic installation guide it works fine and I have the cluster with parameter in compose but I need external elasticsearch.yml document .

Thanks a lot!


(Christian Dahlqvist) #2

in order for this to be correct you need to make both nodes master eligible. With your current setting the cluster will never be able to elect a master.


(Julien) #3

This is wrong location, the file elasticsearch.yml is in folder config, not data folder

This should solve but note there is no reason to overwrite elasticsearch.yml, you can use environment variables, example for cluster name:

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
container_name: es1
environment:
- cluster.name=es-cluster


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.