Install ElasticSearch
Pull the image and select version 6.5.0
$ docker pull elasticsearch:6.5.0
View mirroring
$ docker images
Start a container
$ docker run --name elasticsearch -d -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -p 9200:9200 -p 9300:9300 elasticsearch:6.5.0 42d639a089348b393b0cc912141ef357b6565996c5c4863e363f8729da229d7d
Then visit GET localhost:9200, find that it did not start successfully, and check the log
$ docker logs -f 42d6 [2018-12-05T06:07:06,546][INFO ][o.e.b.BootstrapChecks ] [IHubvTB] bound or publishing to a non-loopback address, enforcing bootstrap checks ERROR: [1] bootstrap checks failed [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [2018-12-05T06:07:06,630][INFO ][o.e.n.Node ] [IHubvTB] stopping ... [2018-12-05T06:07:06,939][INFO ][o.e.n.Node ] [IHubvTB] stopped [2018-12-05T06:07:06,939][INFO ][o.e.n.Node ] [IHubvTB] closing ... [2018-12-05T06:07:06,973][INFO ][o.e.n.Node ] [IHubvTB] closed
Here's a hint: vm.max map count [65530] is too low, increase to at least [262144], saying that the value of Max map count is too small and needs to be set to 262144
View the value of Max map count
$ cat /proc/sys/vm/max_map_count 65530
Reset the value of Max map count
$ sysctl -w vm.max_map_count=262144 vm.max_map_count = 262144
Start container again
$ docker start 42d6
Visit get localhost again: 9200
{ "name": "IHubvTB", "cluster_name": "docker-cluster", "cluster_uuid": "edN3o1PkTAKF5C4N-Uw7tQ", "version": { "number": "6.5.0", "build_flavor": "default", "build_type": "tar", "build_hash": "816e6f6", "build_date": "2018-11-09T18:58:36.352602Z", "build_snapshot": false, "lucene_version": "7.5.0", "minimum_wire_compatibility_version": "5.6.0", "minimum_index_compatibility_version": "5.0.0" }, "tagline": "You Know, for Search" }
Installation succeeded.
head plug in installation
5.x version head plug-in installation instructions
For version 1.x and 2.x, you can directly use the plugin command to install the head plug-in
Version 5.x or above cannot be installed through plugin command.
https://github.com/mobz/elasticsearch-head Document description:
Running as a plugin of Elasticsearch (deprecated) for Elasticsearch 5.x: site plugins are not supported. Run as a standalone server for Elasticsearch 2.x: sudo elasticsearch/bin/plugin install mobz/elasticsearch-head for Elasticsearch 1.x: sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/1.x for Elasticsearch 0.x: sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/0.9 open http://localhost:9200/_plugin/head/
Need to run a service with node
Running with built in server git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head npm install npm run start open http://localhost:9100/ This will start a local webserver running on port 9100 serving elasticsearch-head
But there is another way to install it, which is through docker. The difference is that the access address changes to http://localhost:9100/
Running with docker for Elasticsearch 5.x: docker run -p 9100:9100 mobz/elasticsearch-head:5 for Elasticsearch 2.x: docker run -p 9100:9100 mobz/elasticsearch-head:2 for Elasticsearch 1.x: docker run -p 9100:9100 mobz/elasticsearch-head:1 for fans of alpine there is mobz/elasticsearch-head:5-alpine open http://localhost:9100/
Using docker to install head plug-in
Pull image (select domestic image source here)
$ docker pull hub.c.163.com/riveryang/elasticsearch-head-5.x
Starting container
$ docker run -d -p 9100:9100 --name elasticsearch-head5 hub.c.163.com/riveryang/elasticsearch-head-5.x:5
Then the browser accesses localhost:9200
This interface appears, indicating that the head plug-in is installed successfully.
But we found that the health value was: not connected?
Open the browser for debugging and find the error message:
Access to XMLHttpRequest at 'http://localhost:9200/' from origin 'http://localhost:9100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
This is a cross domain error
ElasticSearch cross domain settings
Enter the elastic search container
$ docker exec -it 42d639a08934 /bin/bash
Locate the directory for the configuration file
$ /usr/share/elasticsearch/config $ ls elasticsearch.keystore ingest-geoip log4j2.properties roles.yml users_roles elasticsearch.yml jvm.options role_mapping.yml users
Modify elasticsearch.yml to install vim (refer to https://my.oschina.net/yimingkeji/blog/2978974)
If you are prompted that apt get does not exist, use yum to install vim
$ yum install -y vim
Edit elasticsearch.yml after installation
$ vim elasticsearch.yml # ----Add content---- # head plug in settings http.cors.enabled: true http.cors.allow-origin: "*"
Restart container
$ docker restart 42d639a08934
Access the plug-in again
Installation is complete.