preface

Install ES, it is not difficult, the main online search, look at the documentation, but through the pit or need to record the main reference to these three documents:

  • Running the Elastic Stack on Docker

  • Docker easy to build ElasticSearch cluster

  • Running Kibana on Docker

Updated docker-comemage. yml file — 2019-12-30

Install the es

Docker pull elasticSearch does not have this tag, dockerhub adds version 6.7.0 to the tag

Pull the mirror

Docker pull elasticsearch: 6.7.0Copy the code

Create es mount directory and configuration file:

cd  /
mkdir-p mnt/elasticsearch
cd  mnt/elasticsearch
mkdir config
mkdir matser
mkdir slave
chmod 777 master
chmod 777 slave
Copy the code

Put two configuration files in config

cd config
touch master.yml
touch slave.yml
Copy the code

matser.yml

Cluster. name: elasticsearch-cluster node.name: master network.bind_host: 0.0.0.0 network.publish_host: `your ip` http.port: 9200 transport.tcp.port: 9300 http.cors.enabled:true
http.cors.allow-origin: "*"
node.master: true 
node.data: true  
discovery.zen.ping.unicast.hosts: [" `your ip`:9300"." `your ip`:9301"]
Copy the code

slave.yml

Cluster. name: elasticsearch-cluster node.name: slave network.bind_host: 0.0.0.0 network.publish_host: elasticsearch-cluster node.name: slave network.bind_host: 0.0.0.0 network.publish_host: `your ip` http.port: 9202 transport.tcp.port: 9302 http.cors.enabled:true
http.cors.allow-origin: "*"
node.master: false
node.data: true  
discovery.zen.ping.unicast.hosts: ["`your ip`:9300"."`your ip`:9301"]
Copy the code

Increase the JVM thread limit (otherwise an error will occur when starting the container, try it yourself)

vim /etc/sysctl.conf
# add this
vm.max_map_count=262144 
Run this command after saving
sysctl -p
Copy the code

Initialize the container

master

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d-p 9200:9200 -p 9300:9300 -v /mnt/elasticsearch/config/master.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v / MNT/elasticsearch/master: / usr/share/elasticsearch/data - the name es - master elasticsearch: 6.7.0Copy the code

slave

 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d-p 9201:9201 -p 9301:9301 -v /mnt/elasticsearch/config/slave.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v / MNT/elasticsearch/slave: / usr/share/elasticsearch/data - the name es - slave elasticsearch: 6.7.0Copy the code

Verify whether the installation is successful

Browser visit http://yourip:9200

Install kibana

At the beginning of installation, I read online tutorials, but I couldn’t connect to ES, so I went directly to the official website to find documents, details are as follows

Docker pull Kibana :6.7.0 docker run --link es-master: elasticSearch -p 5601:5601 -- Name Kibana-dKibana: 6.7.0Copy the code

Go to http://yourip:5601

Use Compose to install version 7.3.1

Because of the experience, go directly to dockerHub to see the installation tutorial

Step 1: Adjust the number of threads, as described above

Step 2: Write docker-comemage.yml

version: '2.2'Services: ES01: image: elasticSearch :7.5.1 Container_name: ES01 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.seed_hosts=es02 - cluster.initial_master_nodes=es01,es02 -  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: ElasticSearch :7.5.1 container_name: ES02 environment: - node.name=es02 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01 - cluster.initial_master_nodes=es01,es02 -  bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"ulimits: memlock: soft: -1 hard: -1 volumes: - data02:/usr/share/elasticsearch/data networks: - elastic kibana: image: Kibana :7.5.1 Container_name: kibana restart: always ports: -"5601:5601"
    environment:
      I18N_LOCALE: zh-CN # localization
    networks:
      - elastic
    links:
      - es01:elasticsearch
volumes:
  data01:
    driver: local
  data02:
    driver: local
networks:
  elastic:
    driver: bridge
Copy the code

There was a problem with the installation. It was in the notes

Step 3:

docker-compose up -d
Copy the code