Install the ES
-
Search for MySQL images on Docker Hub
-
Find the corresponding version in Tags, copy the command, and execute it
Docker pull elasticsearch: 6.8.0Copy the code
-
Create a separate bridge for ES and Kibana
Because ES and Kibana propose to exist as a separate service.
Docker network create Specifies the name of the bridgeCopy the code
-
Start the basic service instance
ES has two ports:
- 9200: Web port for communication with RESTful clients.
- 9300: TCP port to communicate with Java.
Docker run -d --name Host name --network bridge name -p Host port 1:9200 -p host port 2:9300-e"discovery.type=single-node"Elasticsearch: 6.8.0Copy the code
The -e configuration in the preceding command indicates that ES is started in single-node mode. Although it is named single-node, it is started in cluster mode.
So we started the cluster by default and there was no problem
Docker run - d - name container name name - p - network Bridges hosting ports 1:9 200 - p hosting 300 elasticsearch 2:9:6.8.0Copy the code
When you start ES for the first time, a message may be displayed indicating that the CentOS virtual memory is insufficient
-
Modify the configuration on the host
vim /etc/sysctl.conf Copy the code
-
Modify the following configuration:
vm.max_map_count=262144 Copy the code
The default size in CentOS 7 is 65530.
-
To enable the configuration
sysctl -p Copy the code
-
Data volumes are used to persist ES data and configuration to the host machine
Enter the container for known, ES in all the data is stored in a container in the Docker/usr/share/elasticsearch/data; ES in all the configuration of the Docker stored in containers/usr/share/elasticsearch/config.
Docker run - d - name container name name - p - network Bridges hosting ports 1:9 200 - p hosting 2:9 data volume name 1:300 - v/usr/share/elasticsearch/data - v The name of the data volume 2: / usr/share/elasticsearch/config elasticsearch: 6.8.0Copy the code
-
Use data volumes to persist ES plug-ins to the host machine
Into the container view, ES in the Docker all plug-ins are stored in the container in the/usr/share/elasticsearch/plugins.
Docker run - d - name container name name - p -.net Bridges hosting ports 1:9 200 - p hosting 2:9 data volume name 1:300 - v/usr/share/elasticsearch/data - v The name of the data volume 2: / usr/share/elasticsearch/config - v data volume name 3: / usr/share/elasticsearch/plugins elasticsearch: 6.8.0Copy the code
-
Zip to the /var/lib/docker/volumes/ data volume name 3/_data specified in the preceding command.
-
Create a directory ik to store elasticSearch-analysis-IK-6.8.0.zip
Mkdir ik mv ElasticSearch-analysis-IK-6.8.0.zip ik/cd ik/ Copy the code
-
Unpack the elasticsearch – analysis – ik – 6.8.0.zip
Unzip elasticsearch - analysis - ik - 6.8.0.zipCopy the code
-
Delete the elasticsearch – analysis – ik – 6.8.0.zip
Rm - rf elasticsearch - analysis - ik - 6.8.0. ZipCopy the code
-
Restart the current container to load the IK splitter automatically
Docker restart Specifies the container nameCopy the code
Install Kibana
-
Search for Kibana images on Docker Hub
-
Find the corresponding version in Tags, copy the command, and execute it
Docker pull kibana: 6.8.0Copy the code
The Kibana and ES versions must be strictly consistent.
-
Start the basic service instance
Docker run -d --name container name --net bridge name -p host host port :5601 kibana:6.8.0Copy the code
The network bridge name is the same as that of ES.
-
Kibana connection ES
Docker run -d --name Container name --net bridge name -p ELASTICSEARCH_URL= http://host IP address: host port 1 kibana:6.8.0Copy the code
Host port 1 corresponds to point 5 of “Installing ES”.
-
To optimize the
If -e ELASTICSEARCH_URL= http://host IP: host port 1 is too redundant, you can write this to the Kibana configuration file and let Kibana read the information from the configuration file at load time, which is more convenient.
All Kibana configurations in Docker are stored in /usr/share/kibana/config.
-
Use data volumes to persist the Kibana configuration to the host machine
Docker run - d - name container name name - p -.net Bridges the host port: 5601 - v data volume name: / usr/share/kibana/config kibana: 6.8.0Copy the code
-
Go to /var/lib/docker/volumes/ Data volume name /_data to modify the kibana.yml configuration file.
elasticsearch.hosts: [ "Http://host IP address: host port 1" ] Copy the code
Host port 1 corresponds to point 5 of “Installing ES”.
Kibana. Yml in default for elasticsearch. Hosts: [” http://elasticsearch:9200 “]
-
Restart Kibana
Docker restart Specifies the container nameCopy the code
The container name corresponds to point 1 above.
-