Implementation of Docker deployment of ElasticSearch and ElasticSearch-Head

Implementation of Docker deployment of ElasticSearch and ElasticSearch-Head

This article mainly explains how to deploy ElasticSearch: version 6.8.4 using Docker. It explains how to pull from Docker to finally run ElasticSearch and install ElasticSearch-Head, a small tool for managing ElasticSearch-related information. The search on the homepage of this blog system is implemented using ElasticSearch. Since ElasticSearch updates so quickly that SpringData-ElasticSearch cannot keep up with the updates of Es, I also downloaded version 8.x at the beginning, which caused SpringData-ElasticSearch to report an error. In the end, I chose 6.8.4. Record it here

1. Docker deployment of ElasticSearch: version 6.8.4

1.1 Pull the image

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.8.4

1.2 Run the container

The default port of ElasticSearch is 9200. We map the host environment port 9200 to the Docker container port 9200, and then we can access the ElasticSearch service in the Docker container. At the same time, we name this container es.

docker run -d --name es -p 9200:9200 -p 9300:9300 
-e "discovery.type=single-node" 
-e ES_JAVA_OPTS="-Xms=256m -Xms=256m" 
docker.elastic.co/elasticsearch/elasticsearch:6.8.4

illustrate:

-e discovery.type=single-node: indicates single-node startup

-e ES_JAVA_OPTS="-Xms=256m -Xms=256m" : Indicates setting the memory size for es startup. This really needs to be set, otherwise there will be insufficient memory later, such as my own crappy server!

1.3 Insufficient memory

After centos downloads elasticsearch and modifies the configuration, run the docker command:

It was found that the startup was not successful. After removing the -d in the command, the error printed was as follows

Java HotSpot(TM) 64-Bit Server VM warning: INFO:
os::commit_memory(0x0000000085330000, 2060255232, 0) failed;
error='Cannot allocate memory' (errno=12)

After some searching, I found that this was because the default JVM space size allocated by elasticsearch6.0 was 2g, and the memory was insufficient for allocation.

The solution is to modify the jvm space allocation run command:

find /var/lib/docker/overlay/ -name jvm.options

Find the jvm.options file and use the vi command to open the jvm.options file as follows:

-Xms2g 
-Xmx2g
Modified to -Xms512m 
-Xmx512m

Just save and exit. Run the create and run elasticsearch command again and it will start successfully.

2. Docker deployment ElasticSearch-Heard

2.1 Pull the image

docker pull mobz/elasticsearch-head:5

2.2 Run the container

docker create --name elasticsearch-head -p 9100:9100 mobz/elasticsearch-head:5

2.3 Start the container

docker start elasticsearch-head

2.4 Open the browser: http://IP:9100

I found that I couldn't connect because there was a cross-domain problem. Because the front-end and back-end were developed separately, I needed to set up es

2.5 Enter the es container that has just been started, container name = es

docker exec -it es /bin/bash

2.6 Modify the elasticsearch.yml file

vi config/elasticsearch.yml

Add to

http.cors.enabled: true
http.cors.allow-origin: "*"

In fact, SpringBoot's yml file adds cross-domain support

2.7 Exit the container and restart

exit
docker restart es

2.8 Visit http://localhost:9100

Summarize:

This article simply explains how to install ElasticSearch with Docker and the pitfalls you may encounter, including insufficient memory or too high a version, as well as the installation and cross-domain configuration of ElasticSearch-Heard. The next article will explain how to install the Chinese word segmenter in ElasticSearch.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Problems and solutions for installing ElasticSearch and Kibana in Docker
  • How to install Elasticsearch7.6 cluster in docker and set password
  • How to install ElasticSearch on Docker in one article
  • Tutorial on installing Elasticsearch 7.6.2 in Docker
  • Teach you how to install elasticsearch and head plug-ins using docker

<<:  Specific operations of MYSQL scheduled clearing of backup data

>>:  Vue two fields joint verification to achieve the password modification function

Recommend

Install MySQL5.5 database in CentOS7 environment

Table of contents 1. Check whether MySQL has been...

Docker builds cluster MongoDB implementation steps

Preface Due to the needs of the company's bus...

Detailed explanation of CSS margin overlap and solution exploration

I recently reviewed some CSS-related knowledge po...

UCenter Home site adds statistics code

UCenter Home is an SNS website building system rel...

Vue encapsulation component upload picture component

This article example shares the specific code of ...

Get the calculated style in the CSS element (after cascading/final style)

To obtain the calculated style in a CSS element (t...

Detailed explanation of non-parent-child component value transfer in Vue3

Table of contents App.vue sub1.vue sub2.vue Summa...

js to realize payment countdown and return to the home page

Payment countdown to return to the home page case...

Vue custom v-has instruction, steps for button permission judgment

Table of contents Application Scenario Simply put...

Installation of CUDA10.0 and problems in Ubuntu

The correspondence between tensorflow version and...

MySQL 8.0.20 installation and configuration tutorial under Win10

MySQL 8.0.20 installation and configuration super...

Learn the black technology of union all usage in MySQL 5.7 in 5 minutes

Performance of union all in MySQL 5.6 Part 1:MySQ...

Provides helpful suggestions for improving website design

<br />Scientifically Design Your Website: 23...