Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build elasticsearch Cluster by docker

Shulou Source: shulou.com Published: 2022-06-02 02:38:54 09月30日 Update

This article shows you how to build docker elasticsearch cluster, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

1. Pull the es image docker pull docker.io/elasticsearch:5.6.82, create the mount directory mkdir-p / docker/es/configmkdir-p / docker/es/data1mkdir-p / docker/es/data2mkdir-p / docker/es/data33, create the configuration file touch / docker/es/config/es1.ymltouch / docker/es/config/es2.ymltouch / docker/es/config/es3.yml4, and modify the configuration file

The content of the es1.yml file is:

Cluster.name: elasticsearch-clusternode.name: es-node1network.bind_host: 0.0.0.0network.publish_host: 192.168.100.102http.port: 9200transport.tcp.port: 9300http.cors.enabled: truehttp.cors.allow-origin: "*" node.master: truenode.data: truediscovery.zen.ping.unicast.hosts: ["192.168.100.102 0.0.0.0network.publish_host 9301", "192.168.100.102 0.0.0.0network.publish_host 9301"] discovery.zen.minimum_master_nodes: 2

The content of the es2.yml file is:

Cluster.name: elasticsearch-clusternode.name: es-node2network.bind_host: 0.0.0.0network.publish_host: 192.168.100.102http.port: 9201transport.tcp.port: 9301http.cors.enabled: truehttp.cors.allow-origin: "*" node.master: truenode.data: truediscovery.zen.ping.unicast.hosts: ["192.168.100.102 0.0.0.0network.publish_host 9301", "192.168.100.102 0.0.0.0network.publish_host 9301"] discovery.zen.minimum_master_nodes: 2

The content of the es3.yml file is:

Cluster.name: elasticsearch-clusternode.name: es-node3network.bind_host: 0.0.0.0network.publish_host: 192.168.100.102http.port: 9202transport.tcp.port: 9302http.cors.enabled: truehttp.cors.allow-origin: "*" node.master: truenode.data: truediscovery.zen.ping.unicast.hosts: ["192.168.100.102es-node3network.bind_host 9300", "192.168.100.102purl 9301" "192.168.100.102 9302"] discovery.zen.minimum_master_nodes: 25, modify system parameters

Add a line at the end of the / etc/sysctl.conf file

Vm.max_map_count=262144

Execute the following command

Sysctl-w vm.max_map_count=262144

6 、 Launch node docker run-e ES_JAVA_OPTS= "- Xms256m-Xmx256m"-d-p 9200 Xmx256m 9200-p 9300 Xmx256m 9300-- privileged=true-v / docker/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml-v / docker/es/data1:/usr/share/elasticsearch/data-- name es-node1 elasticsearch:5.6.8docker run-e ES_JAVA_OPTS= "- Xms256m-Xmx256m"-d-p 9201-p 9301mer 9301-- privileged=true -v / docker/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml-v / docker/es/data2:/usr/share/elasticsearch/data-- name es-node2 elasticsearch:5.6.8docker run-e ES_JAVA_OPTS= "- Xms256m-Xmx256m"-d-p 9202 9302 ES_JAVA_OPTS= 9302-- privileged=true-v / docker/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml-v / docker/es/data3:/ Usr/share/elasticsearch/data-name es-node3 elasticsearch:5.6.87, Install the es-head plug-in docker pull mobz/elasticsearch-head:5docker run-di-- name=es-head-p 9100 di 9100 docker.io/mobz/elasticsearch-head:58, install the ik word splitter

Download the word splitter plug-in: https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v5.6.8

Decompress at the host

Unzip elasticsearch-analysis-ik-5.6.8.zip

And change the folder name to ik

Mv elasticsearch ik

Copy the extracted ik to the docker image directory

Docker cp ik es-node1:/usr/share/elasticsearch/plugins9, restart container docker restart container id10, single point of operation

If you want to run a single point, you can stop es-node2 es-node3 and comment out some of the configurations in the es1.yml configuration file

Cluster.name: elasticsearch-clusternode.name: es-node1network.bind_host: 0.0.0.0http.port: 9200transport.tcp.port: 9300http.cors.enabled: truehttp.cors.allow-origin: "*" node.data: true#network.publish_host: 192.168.100.102#node.master: true# discovery.zen.ping.unicast.hosts: ["192.168.100.102purl 9300", "192.168.100.102purl 9301" "192.168.100.102 ELASTICSEARCH_URL= 9302"] # discovery.zen.minimum_master_nodes: 211, install kibana docker run-it-d-e ELASTICSEARCH_URL= kibana:5.6.8-- name kibana-p 5601 it 5601 kibana:5.6.8

The URL of es needs to write the ip inside the container and view the ip commands inside the container.

Docker inspect

The above is how docker builds elasticsearch clusters. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: File content container configuration cluster command skill plug-in directory knowledge mirror single point run concise to the point one line parameters host host that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn Apple Microsoft Shulou Technology