Install the ES

  1. Search for MySQL images on Docker Hub

  2. Find the corresponding version in Tags, copy the command, and execute it

    Docker pull elasticsearch: 6.8.0Copy the code
  3. 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
  4. 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

    1. Modify the configuration on the host

      vim /etc/sysctl.conf
      Copy the code
    2. Modify the following configuration:

      vm.max_map_count=262144
      Copy the code

      The default size in CentOS 7 is 65530.

    3. To enable the configuration

      sysctl -p
      Copy the code
  5. 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
  6. 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
  7. Zip to the /var/lib/docker/volumes/ data volume name 3/_data specified in the preceding command.

  8. 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
  9. Unpack the elasticsearch – analysis – ik – 6.8.0.zip

    Unzip elasticsearch - analysis - ik - 6.8.0.zipCopy the code
  10. Delete the elasticsearch – analysis – ik – 6.8.0.zip

    Rm - rf elasticsearch - analysis - ik - 6.8.0. ZipCopy the code
  11. Restart the current container to load the IK splitter automatically

    Docker restart Specifies the container nameCopy the code

Install Kibana

  1. Search for Kibana images on Docker Hub

  2. 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.

  3. 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.

  4. 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”.

  5. 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.

    1. 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
    2. 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 “]

    3. Restart Kibana

      Docker restart Specifies the container nameCopy the code

      The container name corresponds to point 1 above.