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 with docker

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article focuses on "how to use docker to build elasticsearch clusters", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use docker to build elasticsearch clusters.

Overview

The deployment of elasticsearch with docker is very simple. If you want to achieve cluster configuration, you need to do some special processing. This paper introduces how to use docker to build elasticsearch clusters.

You can refer to the example for specific configuration.

Master node configuration docker-compose.yml configuration file es: image: elasticsearch volumes: -. / es:/usr/share/elasticsearch/data -. / elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml ports:-9200 image 9300

Among them,. / es:/usr/share/elasticsearch/data hangs the data files of elasticsearch on a local directory. The local directory specified here is. / es, which can be changed to another directory with permissions.

Elasticsearch.yml configuration file cluster.name: elasticsearch_clusternode.name: node-masternode.master: truenode.data: truehttp.port: 9200network.host: 0.0.0.0network.publish_host: master-ipdiscovery.zen.ping.unicast.hosts: ["master-ip"]

Network.publish_host: master-ip specifies the native ip and needs to modify the master-ip to a real machine ip. The master-ip in discovery.zen.ping.unicast.hosts also needs to be modified to a real machine ip.

Start the service

First confirm whether the vm.max_map_count in the / etc/sysctl.conf configuration file is greater than 655360. If not, or the configuration is not in the configuration file, use the root user to modify the configuration to vm.max_map_count=655360, and execute the command sysctl-p, otherwise elasticsearch will report an error at startup.

Execute docker-compose up-d, and you can start normally.

Data Node configuration docker-compose.yml profile

The configuration is the same as the primary node.

Elasticsearch.yml configuration file cluster.name: elasticsearch_clusternode.name: node-data-1node.master: falsenode.data: truehttp.port: 9200network.host: 0.0.0.0network.publish_host: data-ipdiscovery.zen.ping.unicast.hosts: ["master-ip"]

The difference from the primary node configuration is the following:

Node.name: node-data-1node.master: falsenetwork.publish_host: data-ip

Node.name is the name of the data node, and node.master is set to false,network.publish_host as the machine ip of the data node.

Start the service

The startup steps are the same as the master node.

After both the primary node and the data node are started, you can see the status of the nodes in the cluster by executing the curl http://master-ip:9200/_cat/nodes command on the primary node server (changing the master-ip in the command to the machine ip of the primary node).

At this point, I believe you have a deeper understanding of "how to use docker to build elasticsearch clusters". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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: 0

*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

Servers

Wechat

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

12
Report