Preface
Recently, Huawei Cloud Yaoyun Server L instance was released, and I also built one to play with. During the process, I encountered various problems and learned a lot about operation and maintenance in the process of solving the problems.
This blog introduces the installation and parameter settings of the Docker version of Elasticsearch, port opening and browser access.
The list of other related Huawei Cloud Yaoyun Server L instance evaluation articles is as follows:
Article directory
lead out
1. Installation and parameter settings of the Docker version of Elasticsearch;
2. Port opening and browser access;
1. Query and download ES (docker)
https://www.elastic.co/cn/elasticsearch/
Elasticsearch is a distributed, RESTful search and data analysis engine capable of solving a variety of emerging use cases. At the heart of the Elastic Stack, Elasticsearch centralizes your data so you can search quickly, fine-tune relevance, perform powerful analytics, and scale easily.
Inquire
docker search elasticsearch
Pull image
docker pull elasticsearch: version number
docker pull elasticsearch:7.17.7
2. Create es container
1. Create a folder
Create the elasticsearch folder and create subfolders data and config below
2. Modify the access permissions of the folder
chmod 777 elasticsearch/**
elasticsearch.yml
Create the elasticsearch.yml file in the config folder and modify it to read, write and execute permissions.
touch elasticsearch/config/elasticsearch.yml
chmod 777 elasticsearch/config/elasticsearch.yml
Modify the contents of elasticsearch.yml
xpack.security.enabled: Configure es security, but it is only free for 1 month. This machine uses no security module.
http:
host: 0.0.0.0
cors:
enabled: true
allow-origin: "*"
xpack:
security:
enabled: false
3. Configure the environment
Adjust max_map_count
The max_map_count file contains limits on the number of VMAs ( virtual memory areas) a process can have . The default value is 65536.
root@hcss-ecs-52b8:~# sysctl -a | grep vm.max_map_count
vm.max_map_count = 65530
root@hcss-ecs-52b8:~# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
root@hcss-ecs-52b8:~# sysctl -a | grep vm.max_map_count
vm.max_map_count = 262144
4. Create a running container
docker run -itd \
--name es \
--privileged \
-p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /usr/local/software/es/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /usr/local/software/es/elasticsearch/data:/usr/share/elasticsearch/data \
-v /usr/local/software/es/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
elasticsearch:7.17.7
port
9200
9200, as HTTP protocol, is mainly used for external communication. It is generally used for tools to connect to ElasticSearch. This port is also needed for java to connect to ES.
9300
It is a custom binary protocol used for communication between nodes in the cluster. Used for matters such as cluster changes, master node election, node joining/leaving, shard allocation, etc.
ES_JAVA_OPTS
Specify the JVM memory configuration in the container. It is recommended to be greater than 512M.
3. Modification of es related parameters
5. Modify ES memory size
Enter the container
[root@localhost config]# docker exec -it es bash
Enter the config folder
Modify jvm.options default memory size
root@6fa12b7a6ddb:/usr/share/elasticsearch/config# echo "-Xms4g" >> jvm.options
root@6fa12b7a6ddb:/usr/share/elasticsearch/config# echo "-Xmx4g" >> jvm.options
Exit and restart the container
root@6fa12b7a6ddb:/usr/share/elasticsearch/config# exit
exit
[root@localhost config]# docker restart es
4. Port opening and access
1. Open port
2. Browser access
Appendix: Installation commands in docker containers
How to install command in docker container?
apt update && apt -y install tree
#在容器内
root@af35113d7d48:/usr/share/elasticsearch/plugins/ik# apt update && apt -y install tree
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Summarize
1. Installation and parameter settings of the Docker version of Elasticsearch;
2. Port opening and browser access;