docker-compose-elasticsearch-kibana icon indicating copy to clipboard operation
docker-compose-elasticsearch-kibana copied to clipboard

elastic search and kibana

Open rbsdotnet opened this issue 6 years ago • 17 comments
trafficstars

hi Thanks for submitting the latest version I just want elastic and kibana Which sections should I delete? If you can provide a file for these two items

rbsdotnet avatar Jun 28 '19 11:06 rbsdotnet

Below you will have a working configuration using 7.2.0 version of elasticsearch and kibana. This will create 3 elasticsearch nodes called es01,es02, es03, references each 9200 docker port to your 9200,9201,9202 host ports. Kibana will be located on port 5601 and connect to node es01, which will be the master node.

docker-compose.yml : (can't attach it)

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
    container_name: es01
    environment:
      - node.name=es01
      - discovery.seed_hosts=es01,es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile: 
        soft: 65536
        hard: 65536
    volumes:
      - esdata01:/usr/share/elasticsearch/data
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"      

    ports:
      - 9200:9200
    networks:
      - esnet

  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
    container_name: es02
    environment:
      - node.name=es02
      - discovery.seed_hosts=es01,es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile: 
        soft: 65536
        hard: 65536
    volumes:
      - esdata02:/usr/share/elasticsearch/data
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"      

    ports:
      - 9201:9200
    networks:
      - esnet
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
    container_name: es03
    environment:
      - node.name=es03
      - discovery.seed_hosts=es01,es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile: 
        soft: 65536
        hard: 65536
    volumes:
      - esdata03:/usr/share/elasticsearch/data
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"
    ports:
      - 9202:9200
    networks:
      - esnet
  kibana:
    depends_on:
      - es01
      - es02
      - es03
    image: docker.elastic.co/kibana/kibana:7.2.0
    container_name: kibana
    environment:
      SERVER_NAME: kibana
      ELASTICSEARCH_HOSTS: http://es01:9200
    ports:
      - 5601:5601
    networks:
      - esnet 
    volumes:
      - kibanadata:/usr/share/kibana/data
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"
volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local
  esdata03:
    driver: local
  kibanadata:
    driver: local

networks:
  esnet:

I hope this helps, I created it myself.

bygre14790 avatar Jul 02 '19 07:07 bygre14790

hi when running docker-compuse up error

Creating network "docker_esnet" with the default driver Creating volume "docker_elasticsearchdata" with local driver Creating volume "docker_kibanadata" with local driver Pulling elasticsearch (docker.elastic.co/elasticsearch/elasticsearch:7.2.0)... 7.2.0: Pulling from elasticsearch/elasticsearch 48914619bcd3: Pull complete ece8dc200401: Pull complete d26560684299: Pull complete 4943fd7a304e: Pull complete 25b51252b6aa: Pull complete 9fafca4c9640: Pull complete 0af2bd946cdc: Pull complete Pulling kibana (docker.elastic.co/kibana/kibana:7.2.0)... 7.2.0: Pulling from kibana/kibana 48914619bcd3: Already exists f2bc79fc77ab: Pull complete e199d976e62e: Pull complete 45c55dc324de: Pull complete 251ebec231a8: Pull complete 46b00c7f387a: Pull complete 5f329b8f1505: Pull complete 504f4879470f: Pull complete Creating elasticsearch ... error

ERROR: for elasticsearch Cannot start service elasticsearch: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused "rootfs_linux.go:58: mounting \"/etc/localtime\" to rootfs \"/var/lib/docker/overlay2/49c3b012a11f3d034c968430229f7cb69f14f1c59b9a4f37c13027b78ed0ca65/merged\" at \"/var/lib/docker/overlay2/49c3b012a11f3d034c968430229f7cb69f14f1c59b9a4f37c13027b78ed0ca65/merged/usr/share/zoneinfo/UTC\" caused \"not a directory\""": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

ERROR: for elasticsearch Cannot start service elasticsearch: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused "rootfs_linux.go:58: mounting \"/etc/localtime\" to rootfs \"/var/lib/docker/overlay2/49c3b012a11f3d034c968430229f7cb69f14f1c59b9a4f37c13027b78ed0ca65/merged\" at \"/var/lib/docker/overlay2/49c3b012a11f3d034c968430229f7cb69f14f1c59b9a4f37c13027b78ed0ca65/merged/usr/share/zoneinfo/UTC\" caused \"not a directory\""": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: Encountered errors while bringing up the project.

RezaAVS avatar Jul 03 '19 06:07 RezaAVS

I didn´t get any error.
I set it because my docker container was 2 hours late compared my real time. remove this lanes and try again: - "/etc/timezone:/etc/timezone:ro" - "/etc/localtime:/etc/localtime:ro"

Say me if this work.

bygre14790 avatar Jul 03 '19 10:07 bygre14790

Thnx for replying. this work when remove timezone & localtime. There is only one problem When the docker is restarted for any reason, it should be run once docker-cpmpose up Is there a way to run elastic and kibana without executing the above command?

RezaAVS avatar Jul 03 '19 10:07 RezaAVS

i don't know if i understand your doubt. Correct me if i'm wrong : you want to deploy the enviroment without run docker compose?

bygre14790 avatar Jul 03 '19 10:07 bygre14790

Yes When the operating system or docker resets To re-run, you must call the docker-compose command I want this process to be done automatically by rebooting the docker

RezaAVS avatar Jul 03 '19 10:07 RezaAVS

Well. I will give you a solution but i don't know at the moment if it will work. For each instance you want to auto-start when docker is up use this parameter:

restart: always

I can't test it rigth now. Can you try it and say me if this work for you?

Note : if you kill the container or stop it manually it wouldn't auto-restart, try to stop docker and start it again. So I advice you not to use docker-compose stop | docker-compose down

I learned about docker 2 days ago, so im not the best one to say you how to solve it, im just trying. If i do something wrong please, notify me, im new on this tecnology.

bygre14790 avatar Jul 03 '19 11:07 bygre14790

After a few days, I became acquainted with you and I handed in the instructions you provided to my servant I will test and inform you Thank you for the time you left me and answered your questions

RezaAVS avatar Jul 03 '19 11:07 RezaAVS

The docker-compose version should be changed from 2.2 to 3 And this parameter will be added restart: always For each section

version: '3' services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0 container_name: elasticsearch restart: always environment: - node.name=elasticsearch - discovery.seed_hosts=elasticsearch - cluster.initial_master_nodes=elasticsearch - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

ulimits:
  memlock:
    soft: -1
    hard: -1
  nofile: 
    soft: 65536
    hard: 65536
volumes:
  - elasticsearchdata:/usr/share/elasticsearch/data

ports:
  - 9200:9200
networks:
  - esnet

kibana: depends_on: - elasticsearch image: docker.elastic.co/kibana/kibana:7.2.0 container_name: kibana restart: always environment: SERVER_NAME: kibana ELASTICSEARCH_HOSTS: http://elasticsearch:9200 ports: - 5601:5601 networks: - esnet volumes: - kibanadata:/usr/share/kibana/data volumes: elasticsearchdata: driver: local kibanadata: driver: local

networks: esnet:

docker-compose.txt

RezaAVS avatar Jul 03 '19 11:07 RezaAVS

Pleased to help. If there are any more trouble you can ask again, and if i have the knowlegde i'll be glad to help you. I will change the version now, thanks for advise me. This mean that it works for you?

bygre14790 avatar Jul 03 '19 11:07 bygre14790

Yes, your advice worked perfectly

RezaAVS avatar Jul 03 '19 11:07 RezaAVS

Perfect! i will continue exploring this tecnology. I have a doubt that maybe you can answer.

When we reference the port of docker container to the real one, for example 5601. It reference automatically to http://localhost:5601 i dont have testing enougth yet, but i want to reffer the real ip of my host machine. So i want something like this: http://172.22.1.x:5601.

I think if i put on ports declaration something like this, it will work:

ports : 
172.22.1.x:5601:5601

If you know if this work, or how to do it, you will help me a lot.

bygre14790 avatar Jul 03 '19 11:07 bygre14790

Well, I did not test this part Soon, I'll test and get the result to you

RezaAVS avatar Jul 03 '19 11:07 RezaAVS

Thanks!

Remember any doubt.. just ask!

bygre14790 avatar Jul 03 '19 11:07 bygre14790

Glad to say that the 172.22.1.x:5601:5601 works for me. Right now I'm referring to the port of my host machine.

bygre14790 avatar Jul 04 '19 08:07 bygre14790

I finally started the whole services, however, I am getting this

Kibana server is not ready yet

Any thoughts? I searched the web but cannot fix it.

Vimos avatar Oct 14 '19 10:10 Vimos

Answering my own question, I created volumes from local drive and can use kibana now.

+  esdata2: 
+    driver: local
+    driver_opts:
+      type: none
+      o: bind
+      device: "./data/esdata2"

Vimos avatar Oct 15 '19 06:10 Vimos