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:
|
<<: Specific operations of MYSQL scheduled clearing of backup data
>>: Vue two fields joint verification to achieve the password modification function
Table of contents 1. Check whether MySQL has been...
Preface Due to the needs of the company's bus...
I recently reviewed some CSS-related knowledge po...
UCenter Home is an SNS website building system rel...
This article example shares the specific code of ...
Use profile to analyze slow SQL The main purpose ...
To obtain the calculated style in a CSS element (t...
Table of contents App.vue sub1.vue sub2.vue Summa...
Payment countdown to return to the home page case...
Table of contents Application Scenario Simply put...
The correspondence between tensorflow version and...
MySQL 8.0.20 installation and configuration super...
Performance of union all in MySQL 5.6 Part 1:MySQ...
【SQL】SQL paging query summary The need for paging...
<br />Scientifically Design Your Website: 23...