In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to deal with the problem of installing ElasticSearch and Kibana in Docker". In the daily operation, I believe many people have doubts about how to deal with the problem of installing ElasticSearch and Kibana in Docker. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "how to deal with the problem of Docker installing ElasticSearch and Kibana". Next, please follow the editor to study!
1. Install docker
Docker installation can refer to this Docker from getting started to practice series 2-Docker installation
two。 Pull elasticsearch image
Pull the latest version of elasticsearch
Docker pull elasticsearch
Pull the specified version of elasticsearch, such as elasticsearch version 7.11.1
Docker pull elasticsearch:7.11.13. Launch elasticsearchdocker run-- name elasticsearch-p 9200 ES_JAVA_OPTS= 9200-p 9300-e "discovery.type=single-node"-e ES_JAVA_OPTS= "- Xms512m-Xmx512m"-d elasticsearch:7.11.1
Or
Docker run-- name elasticsearch-p 9200 discovery.type=single-node-e ES_JAVA_OPTS= "- Xms512m-Xmx512m"-d 54d1c07bc236
Description of parameters for running docker image:
-p: Port Mappin
-e: set environment variables, discovery.type=single-node (run on a stand-alone), ES_JAVA_OPTS= "- Xms512m-Xmx512m" (set JVM parameter)
-d: start in the background
-name: container name
54d1c07bc236: mirror id
3.1Directory structure [root@node-123 systemd] # docker exec-it 54d1c07bc236 / bin/bash [root@54d1c07bc236 elasticsearch] # ls-ltotal 560 elasticsearch root 3860 Feb 15 2021 LICENSE.txt-rw-r--r-- 1 elasticsearch root 545323 Feb 15 2021 NOTICE.txt-rw-r--r-- 1 elasticsearch root 7263 Feb 15 2021 README.asciidocdrwxr-xr-x 2 elasticsearch root 4096 Feb 15 2021 bindrwxrwxr-x 1 elasticsearch root 55 Dec 23 09:40 configdrwxrwxr-x 1 elasticsearch root 19 Dec 23 08:39 datadrwxr-xr-x 1 elasticsearch root 17 Feb 15 2021 jdkdrwxr-xr-x 3 elasticsearch root 4096 Feb 15 2021 libdrwxrwxr-x 1 elasticsearch root 71 Dec 23 09:41 logsdrwxr-xr-x 57 elasticsearch root 4096 Feb 15 2021 modulesdrwxrwxr-x 1 elasticsearch root 25 Dec 23 09:40 plugins
Directory structure
The directory configuration file describes the bin script file, including starting Elasticsearch, installing plug-ins, running statistics, and so on. Configelasticsearch.yml cluster configuration file JDKJava runtime environment datapath.data data file libJava class library logspath.logs log file modules contains all ES modules plugins contains all installed plug-ins 4. Verify that elasticsearch starts successfully
Use curl to access the linux: curl http://localhost:9200. Enter information similar to the following to indicate that the installation is successful
{"name": "54d1c07bc236", "cluster_name": "docker-cluster", "cluster_uuid": "5UUvjjKKRMeQG9FZvW_mxA", "version": {"number": "7.11.1", "build_flavor": "default", "build_type": "docker", "build_hash": "ff17057114c2199c9c1bbecc727003a907c0db7a" "build_date": "2021-02-15T13:44:09.394032Z", "build_snapshot": false, "lucene_version": "8.7.0", "minimum_wire_compatibility_version": "6.8.0", "minimum_index_compatibility_version": "6.0.0-beta1"}, "tagline": "You Know, for Search"} 5. Plug-in installation 5.1 install the IK word splitter
Plug-ins can be installed with the elasticsearch-plugin install url command
For example, install: elasticsearch-analysis-ik (Separator). The Ik Separator version should be consistent with ES and Kibana versions.
Docker command to enter container. Container id is 54d1c07bc236.
Docker exec-it 54d1c07bc236 / bin/bash
Plugins installation steps
Cd / usr/share/elasticsearch/plugins/
Install the plug-in, the elasticsearch-analysis-ik version is consistent with elasticsearch, that is, 7.11.1
Elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.11.1/elasticsearch-analysis-ik-7.11.1.zip
Exit the container
Exit
Restart the docker container
Verification of docker restart 54d1c07bc2365.2 word splitter usage
Ik_smart: intelligent word segmentation, at least segmentation, preferring lack rather than abuse, ensuring accuracy
Ik_max_word: maximize word segmentation, the finest granularity division, as many meaningful word segmentation as possible, ensure recall, ik_max_word word segmentation includes ik_smart
Postman post request word Segmentation Test: http://ip:9200/_analyze
{"tokenizer": "ik_smart", "text": "Huacheng Guangzhou"}
The results are as follows:
{
"tokens": [
{
"token": "Hua Cheng"
"start_offset": 0
"end_offset": 2
"type": "CN_WORD"
"position": 0
}
{
"token": "Guangzhou"
"start_offset": 2
"end_offset": 4
"type": "CN_WORD"
"position": 1
}
]
}
6. Kibana installation 6.1 docker installation kibana
Install kibana version is the same as elasticsearch version, that is, 7.11.1
Docker pull kibana:7.11.16.2 starts kibana
After the installation, you need to start the kibana container and use-link to connect to the elasticsearch container. The command is as follows:
Docker run-- name kibana-- link=elasticsearch:elasticsearch-p 5601 link=elasticsearch:elasticsearch-d kibana:7.11.1
After startup, you can open a browser and enter http://ip:5601 to open the interface of kibana.
7. Elasticsearch-head installation
Elasticsearch-head is a plug-in for Elasticsearch monitoring
Mirror pull
Docker pull mobz/elasticsearch-head:5
View Mirror
Docker images
The output contains mobz/elasticsearch-head
REPOSITORY TAG IMAGE ID CREATED SIZEhello-world latest feb5d9fea6a5 3 months ago 13.3kBelasticsearch 7.11.1 bc3d45eba361 10 months ago 819MBkibana 7.11.1 ecf6e21a953f 10 months ago 1.01GBmobz/elasticsearch-head 5 b19a5c98e43b 4 years ago 824MB
Start the container
Docker run-d-name elasticsearch-head-p 9100V 9100 mobz/elasticsearch-head:5
Browser access (http://ip:9100/)), the result is as follows:
8. Handling of frequently asked questions
When you start to link the elasticsearch service, you will find that the link is not up. Because the front and rear ends are developed separately, there will be cross-domain problems, so you need to configure CORS on the server side.
Docker exec-it elasticsearch / bin/bashvi config/elasticsearch.yml
Add the following configuration at the end of the elasticsearch.yml file, save, exit the container, and restart
Http.cors.enabled: truehttp.cors.allow-origin: "*"
Parameter description:
The default value of the parameter indicates whether http.cors.enabledfalse supports cross-domain. The default is falsehttp.cors.allowed.originlocalhost. If it is set to allow cross-domain, default is *, which means all domain names are supported. If we only allow some websites to access, we can use regular expressions. For example, only local addresses are allowed. / https?/localhost (: [0-9] +) / http.cors.max-age1728000 (20 days) browser sends a "pre-check" OPTIONS request to determine CORS settings. The maximum age defines how long the results should be cached. Http.cors.allow-methodsOPTIONS,HEAD,GET,POST,PUT,DELETE allows cross-domain request method http.cors.allow-headersX-Requested-With,Content-Type,Content-Length cross-domain allows the header information set http.cors.allow-credentials to return the set cross-domain Access-Control-Allow-Credentials header, if set to true, it will be returned to the client.
Exit the container
Exit
Restart elasticsearch
Execute. 54d1c07bc236 is elasticsearch container id.
Docker restart 54d1c07bc236
Or
Docker restart elasticsearch
The browser visits (http://ip:9100/)) again. Remember to modify the elasticsearch address and display [Cluster Health value: green] to indicate that the connection to elasticsearch is successful.
At this point, the study on "how to deal with the problem of installing ElasticSearch and Kibana in Docker" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.