Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build elasticsearch Cluster by docker

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 300

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report