Docker installation

1. Download the image file

Download the elasticsearch

Docker pull ElasticSearch :7.4.2 # Store and retrieve dataCopy the code

Download kibana

Docker Pull Kibana :7.4.2 # Visually retrieve dataCopy the code

Note: ElasticSearch should be the same as Kibana!

2. Create an instance

1. ElasticSearch

Mkdir -p/mydata/elasticsearch/config # in mydata folder to create es config folder, will the docker es configuration mounted in the outside, when we modify the configuration files of the es in the Linux virtual machine, Will also modify the docker es in the configuration of the mkdir -p/mydata/elasticsearch/data # in mydata folder create es echo data folder "HTTP. Host: 0.0.0.0" > > / mydata/elasticsearch/config/elasticsearch. Yml # [HTTP. Host: 0.0.0.0] to allow any remote machines to visit es, Chmod -r 777 /mydata/ elasticSearch / #Copy the code

docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms64m -Xmx128m" \ -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \ -v / mydata/elasticsearch/plugins: / usr/share/elasticsearch/plugins \ - d elasticsearch: 7.4.2
#Docker run --name ElasticSearch creates an es container and gives it a name;
#-p 9200:9200 Maps the Linux port 9200 to the Docker container port 9200, which is used to send HTTP requests to ES
#-p 9300:9300 9300 is the communication port of ES between nodes in distributed cluster state
# -eSpecify an argument that es is currently running in single-node mode
#* Note that ES_JAVA_OPTS is important to specify a minimum and maximum memory footprint of 64M and 128M for the ES runtime at development time, otherwise all available memory will be consumed
#-v Mount command to associate paths in the VM with paths in the Docker
# -dBackground Startup Service
Copy the code

Docker ps does not find es, because the es configuration file has permissions, so we need to modify the es configuration file permissions:

[root@10 config]# cd .. / [root@10 elasticsearch]# ls config data plugins [root@10 elasticsearch]# cll bash: cll: command not found [root@10 elasticsearch]# ll total 0 drwxr-xr-x. 2 root root 31 May 21 14:55 config drwxr-xr-x. 2 root root 6 May 21 14:52 data drwxr-xr-x. 2 root root 6 May 21 15:14 plugins [root@10 elasticsearch]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 53C0e82DED18 redis "docker-entryPoint.s..." 6 weeks ago Up 4 hours 0.0.0.0:6379->6379/ TCP redis e1C1b5a6012e mysql:5.7 "docker-entrypoint.s..." 7 weeks ago Up 4 hours 0.0.0.0:3306->3306/ TCP, 33060/tcp mysql [root@10 elasticsearch]# chmod -R 777 /mydata/elasticsearch/ [root@10 elasticsearch]# ll total 0 drwxrwxrwx. 2 root root 31 May 21 14:55 config drwxrwxrwx. 2 root root 6 May 21 14:52 data drwxrwxrwx. 2 root root 6 May  21 15:14 pluginsCopy the code

Docker ps docker ps docker ps ps docker ps ps We use docker logs elasticSearch to look at the es startup log:

[root@10 elasticsearch]# docker logs elasticsearch
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
2020-05-21 15:14:13,179 main ERROR No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]];
        at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1097)
        at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1070)
        at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:83)
        at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:95)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]]
        at org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken(XContentParserUtils.java:78)
        at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:617)
        at org.elasticsearch.common.settings.Settings.access$400(Settings.java:82)
Copy the code

[error] [k-v key pair] [k-v key pair] [k-v key pair] [K-v key pair] [K-v key pair] [K-v key pair]

HTTP. Host: 0.0.0.0Copy the code

In fact, there should be Spaces between k-V key-value pairs. Note that the colon in the key: value format in the YML configuration file is followed by a space. Otherwise it will cause the error above. / / elasticSearch. yml file

HTTP. Host: 0.0.0.0Copy the code

Docker start elasticSearch (es)

Visit http://192.168.56.10:9200/ in your browser’s address bar, you can see after the success of the es start return similar to the following data:

Note 192.168.56.10 is the address of my Linux VM. You need to access the VM based on your own VM address


Reference:

Elasticsearch Reference

elastic

Full text Search Engine Elasticsearch tutorial