简体   繁体   中英

how to create ES cluster and store data if elastic search and kibana is installed using docker

I've installed Elastic Search and Kibana using docker image in ubuntu machine and the commands used to run are:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.5.1

docker run --link 36c0ea06f9e3:elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:7.5.1

and it gets successfully run in my local machine.

Now the major concern for me when you try to create a cluster node with one master and slave node, user need to edit the /etc/elasticsearc/elasticsearch.yml .

But in this case (installed using docker image in ubuntu).

No such file or folder is created. Do let me know how can I create a cluster and store data in such case.

You already have part of the solution in your first docker run statement. The docker image of elasticsearch is configured using environment variables. For example your run statement sets the node to single-node mode using the -e "discovery.type=single-node" flag. A full list of configuration options you can find here .

You may also share the config directory with the host using a host-shared volume:

docker run -p 9200:9200 -p 9300:9300 -v <your-dir>/elasticsearch.yml/:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:7.5.1

This allows you to edit the config at your_dir/elasticsearch.yml directly from your hosts filesystem. Just make sure the config file exists in the specified directory before attempting to start the container.

Not sure if this is useful but here you go

https://blog.patricktriest.com/text-search-docker-elasticsearch/

from is official guide you can use envirmental varible to pass option to /etc/elasticsearc/elasticsearch.yml

this is sample docker-compose.yml:

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data02:/usr/share/elasticsearch/data
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data03:/usr/share/elasticsearch/data
    networks:
      - elastic

volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM