Table of contents
1. Check whether docker is installed
1. Pull the elasticsearch image
2. Configure elasticsearch port
4. Verify whether elasticsearch starts successfully
4. Kibana server is not ready yet error message
5. Restart the docker container
6. Supplement: Commonly used shortcut keys:
1. Check whether docker is installed
1. First check whether docker has been installed before
yum list installed | grep docker
2. Uninstall docker
yum remove docker -y
3. docker startup
Start systemctl start docker or service docker start
Stop: systemctl stop docker or service docker stop
Restart: systemctl restart docker or service docker restart
Check the running status of the docker process: systemctl status docker or service docker status
2. ElasticSearch installation
Reference: Docker installation of ElasticSearch and Kibana_ThinkWon's blog-CSDN blog , and many blogs have written the following article.
1. Pull the elasticsearch image
Pull the latest version of elasticsearch
docker pull elasticsearch
What I use here is the following method:
Pull the specified version of elasticsearch, such as pulling the 7.11.1 version of elasticsearch
docker pull elasticsearch:7.11.1
2. Configure elasticsearch port
docker run --name elasticsearcha -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d elasticsearch:7.11.1
Description of parameters for running docker image:
-p: port mapping
-e: Set environment variables, discovery.type=single-node (stand-alone operation), ES_JAVA_OPTS="-Xms512m -Xmx512m" (set JVM parameters)
-d: background startup
–name: container name
54d1c07bc236: image id
elasticsearch: corresponding version number
3. Directory structure
Table of contents | configuration file | describe |
---|---|---|
bin | Script files, including starting Elasticsearch, installing plugins, running statistics, etc. | |
config | elasticsearch.yml | Cluster configuration file |
JDK | Java runtime environment | |
data | path.data | data file |
lib | Java class library | |
logs | path.logs | log file |
modules | Contains all ES modules | |
plugins | Contains all installed plugins |
4. Verify whether elasticsearch starts successfully
Use curl to access in Linux: curl http://localhost:9200. Enter information similar to the following to indicate successful installation.
curl http://localhost:9200
windows access: use your own ip address and domain name
3. kibana installation
1. docker install kibana
The installed kibana version is consistent with the elasticsearch version, which is 7.11.1
docker pull kibana:7.11.1
docker images view docker installation content
2. Start kibana
After the installation is complete, you need to start the kibana container and use –link to connect to the elasticsearch container. The command is as follows:
Note that the elasticsearcha:elasticsearcha here should be consistent with the above:
docker run --name kidnapping --link=elasticsearch:elasticsearch -p 5601:5601 -d kidnapping:7.11.1
An error will be reported here:
4. Kibana server is not ready yet error message
Solution:
1. Therefore, execute the following command to check the internal IP address of the elasticsearch container. It is found that the es container IP in the kibana.yaml configuration file is inconsistent with the actual es container IP.
docker inspect --format '{ { .NetworkSettings.IPAddress }}' 68fd078012b1
docker inspect --format '{ { .NetworkSettings.IPAddress }}' 容器id
// View es container id
docker ps
2. Enter the kibana container and update the kibana.yaml configuration file . Execute the following command to enter and edit kibana.yaml,
docker exec - it kidnap_id/bin/bash
docker exec -it 3bb6b5c07faf /bin/bash
cd config
vi kibana.yml
3. Replace the ip address of the selected part in the figure below with the actual es container ip address, save and exit kibana.
4. Restart the container
docker restart container id
5. Access successful
6. Plug-in installation
1. Install IK word segmenter
docker enters the container command, the container id is 7272c3b28e81
docker exec -it 7272c3b28e81 /bin/bash
2.plugins installation steps
cd /usr/share/elasticsearch/plugins/
3. Install the plug-in, the elasticsearch-analysis-ik version is consistent with elasticsearch, ie 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
4.Exit the container
exit
5. Restart the docker container
docker restart 7272c3b28e81
6. Verification of word segmenter usage
ik_smart: intelligent word segmentation, minimum segmentation, rather shortage than excess, guarantee accuracy rate
ik_max_word: Maximize word segmentation method, the finest granular division, as many meaningful word segmentations as possible to ensure recall rate, ik_max_word word segmentation includes ik_smart
Postman post request word segmentation test: http://your own ip address: 9200/_analyze
Test Data:
{ "tokenizer": "ik_smart", "text": "Flower City Guangzhou" }
result:
6. Supplement: Commonly used shortcut keys:
First stop the docker container
docker stop [container id or container name]
Remove container after stopping
docker rm [container id or container name]
If you forget the container ID or name, use the following command to view it (-a is to view all containers)
docker ps -a
Delete the image after deleting the container . Delete first and then pull it.
docker rmi [image id]
View image
docker images
pull image
ocker pull elasticsearch:[version number]
docker starts kibana
Initialize a container: docker run -d -p xxx.xx/imagesId name
Start, restart, stop: docker start/restart/stop container name, container id
View logs: docker logs container name, container id
Delete: docker rm -f container name, container id
Enter the container: docker exec -it container name, container id bash
View all containers: docker ps -a
docker start 2bfaad611b0a