Docker installs ES7.14 and Kibana7.14 (no account password)

1. Docker installation ES7.14.0

1. Download the image

docker pull elasticsearch:7.14.0

2. Docker installation 7.14.0

mkdir -p /usr/local/elasticsearch/config

chmod 777 -R /usr/local/elasticsearch/

echo “cluster.name: “docker-cluster” >> /usr/local/elasticsearch/config/elasticsearch.yml

echo “network.host: 0.0.0.0” >> /usr/local/elasticsearch/config/elasticsearch.yml

echo “discovery.zen.minimum_master_nodes: 1” >> /usr/local/elasticsearch/config/elasticsearch.yml

echo “discovery.type: single-node” >> /usr/local/elasticsearch/config/elasticsearch.yml

docker run –name elasticsearch -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” -e ES_JAVA_OPTS=”-Xms64m -Xmx128m” -v /usr/local/elasticsearch/config/elasticesearch. yml:/usr/local/elasticsearch/config/elasticsearch.yml -d elasticsearch:7.14.0

  • -e “cluster.name=es-docker-cluster”: Set the cluster name
  • -e “http.host=0.0.0.0”: The listening address can be accessed from the external network
  • -e “ES_JAVA_OPTS=-Xms64m -Xmx128m”: memory size
  • -e “discovery.type=single-node”: non-cluster mode
  • -v es-data:/usr/share/elasticsearch/data: Directory mapping, binding elasticsearch data directory
  • -v es-logs:/usr/share/elasticsearch/logs: directory mapping, bound to the elasticsearch log directory
  • -v es-plugins:/usr/share/elasticsearch/plugins: Directory mapping, binding elasticsearch plug-in directory
  • -p 9200:9200: port mapping configuration

3. Visit

http://10.1.1.197:9200

2. Docker installation kibana:7.14.0

1. Download the image

Version: kibana:7.14.0 needs to correspond to the ES version
Kibana is a free and open user interface that enables you to visualize your Elasticsearch data.

docker pull kibana:7.14.0

2. Install kibana

docker run -d –name kibana714 -e ELASTICSEARCH_HOSTS=”http://10.1.1.74:9200″ -p 5601:5601 kibana:7.14.0

  • -e ELASTICSEARCH_HOSTS ES address: Be careful not to use 127.0.0.1

Access the UI interface: http://10.1.1.197:5601/

3. Docker-compose installs ES and kibana

1. Create configuration file directories and files

#Create a directory

mkdir -p /home/es-kibana/config

mkdir -p /home/es-kibana/data

mkdir -p /home/es-kibana/plugins

#Authorize the mounting directory

chmod 777 -R /home/es-kibana/config

chmod 777 /home/es-kibana/es-data/data

chmod 777 /home/es-kibana/es-data/logs

chmod 777 /home/es-kibana/es-data/plugins

1.1, Configuration file elasticesearch.yml

cluster.name: “docker-cluster”
network.host: 0.0.0.0

discovery.zen.minimum_master_nodes: 1
discovery.type: single-node

1.2, Configuration file jvm.options

## JVM configuration

################################################ ##############
## IMPORTANT: JVM heap size
################################################ ##############
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################ ##############

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1g
-Xmx1g
-XX: +IgnoreUnrecognizedVMOptions
################################################ ##############
## Expert settings
################################################ ##############
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################ ##############

## GC configuration
-XX: + UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX: + UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1GC is only supported on JDK version 10 or later.
# To use G1GC uncomment the lines below.
# 10-:-XX:-UseConcMarkSweepGC
# 10-:-XX:-UseCMSInitiatingOccupancyOnly
# 10-:-XX: + UseG1GC
# 10-:-XX:InitiatingHeapOccupancyPercent=75

## optimizations

# pre-touch memory pages used by the JVM during initialization
-XX: +AlwaysPreTouch

##basic

# explicitly set the stack size
-Xss1m

# set to headless, just in case
-Djava.awt.headless=true

# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=GBK

# use our provided JNA always versus the system one
-Djna.nosys=true

# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow

# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0

# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true

-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX: + HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## JDK 8 GC logging

8:-XX: + PrintGCDetails
8:-XX: + PrintGCDateStamps
8:-XX: + PrintTenuringDistribution
8:-XX: + PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX: + UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9 + GC logging
9-:-Xlog:gc*,gc + age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
# time/date parsing will break in an incompatible way for some date patterns and locals
9-:-Djava.locale.providers=COMPAT

# temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
10-:-XX:UseAVX=2

Mainly these three configuration items

2. #Create docker-compose.yml file (important)

version: '3'

services:
    elasticsearch:
        image: elasticsearch:7.14.0
        container_name: es7-14
        restart: unless-stopped
        volumes:
          - ./es-data/data:/usr/share/elasticsearch/data
          - ./es-data/logs:/usr/share/elasticsearch/logs
          # Directory to mount the word segmenter
          #- ./es-data/plugins:/usr/share/elasticsearch/plugins
          - ./config/jvm.options:/usr/share/elasticsearch/config/jvm.options
          - ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
        ports:
          - "9100:9100"
          - "9200:9200"

        networks:
          -es
    kibana:
        image: kibana:7.14.0
        container_name: kibana7-14
        ports:
          - "5601:5601"
        environment:
          - "ELASTICSEARCH_HOSTS=http://10.1.1.197:9200"
        depends_on:
          -elasticsearch
        networks:
          -es
        
networks:
    es:
        driver: bridge

3. #Self-check whether there are any grammatical problems in what you write

docker-compose config -q

4. #Start and stop

docker-compose up -d

docker-compose down

Restart

docker-compose restart container id

Problems encountered during installation of docker-compose:

docker logs container id

1. When docker starts es, it reports an error java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes…

Problem: When docker starts elasticsearch with a mounted configuration file, it will report the following error: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes…

When we see the error, we may think that the /usr/share/elasticsearch/data/nodes folder directory in the es container does not have read and write permissions. In fact, the prompt is misleading. In fact, the mounted directory does not have read and write permissions. permissions. For example, the configuration directory of our host host is: /home/es-kibana/es-data/data, then we need to give it read and write permissions:

Solution: Authorize the permissions of the mounted directory

chmod 777 /home/es-kibana/es-data/data

2. This exception occurs when docker starts es Unrecognized VM option ‘UseConcMarkSweepGC’

Solution: Add -XX: + IgnoreUnrecognizedVMOptions to the jvm.options file