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

Bootstrap+Jquery to achieve calendar effect

This article shares the specific code of Bootstra...

How to insert weather forecast into your website

We hope to insert the weather forecast into the w...

JavaScript+html implements random QR code verification on front-end pages

Share the cool front-end page random QR code veri...

Use of Linux cal command

1. Command Introduction The cal (calendar) comman...

InnoDB engine redo file maintenance method

If you want to adjust the size and number of Inno...

Solve the problem that ifconfig and addr cannot see the IP address in Linux

1. Install the Linux system on the virtual machin...

Analyze Tomcat architecture principles to architecture design

Table of contents 1. Learning Objectives 1.1. Mas...

How to set the position of the block element in the middle of the window

How to set the position of the block element in t...

Ubuntu installation cuda10.1 driver implementation steps

1. Download cuda10.1: NVIDIA official website lin...

Native js to achieve seamless carousel effect

Native js realizes the carousel effect (seamless ...

MySQL Index Detailed Explanation

Table of contents 1. Index Basics 1.1 Introductio...

mysql delete multi-table connection deletion function

Deleting a single table: DELETE FROM tableName WH...

Docker-compose installation db2 database operation

It is troublesome to install the db2 database dir...

Implementation of one-click TLS encryption for docker remote api

Table of contents 1. Change the 2375 port of Dock...