前言
- TencentOS Server 3.1
- Docker version 19.03.14, build 5eb3275d40
- elasticsearch: 7.10.0
安裝ElasticSearch/ES
安裝步驟1:準(zhǔn)備
1. 安裝docker
安裝 docker 參考:【Centos 8】【Centos 7】安裝 docker
2. 搜索可以使用的鏡像。
```
shell> docker search elasticsearch
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
elasticsearch Elasticsearch is a powerful open source sear… 6115 [OK]
kibana Kibana gives shape to any kind of data — str… 2622 [OK]
```
3. 也可從docker hub上搜索鏡像。
docker hub,docker hub-stage。
4. 選擇合適的redis鏡像。
版本 | 拉取命令 |
---|---|
最新版本 | docker pull elasticsearch:latest |
7.4.0 | docker pull elasticsearch:7.4.0 |
7.10.0 | docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.0 |
7.12.0 | docker pull elasticsearch:7.12.0 |
8.0.0 | docker pull elasticsearch:8.0.0 |
8.9.0 | docker pull docker.elastic.co/elasticsearch/elasticsearch:8.9.0 |
安裝步驟2:拉取ElasticSearch鏡像
1 拉取鏡像
shell> docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.0
2 查看已拉取的鏡像
shell> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.elastic.co/elasticsearch/elasticsearch 7.10.0 37190fe5beea 2 years ago 774MB
mobz/elasticsearch-head 5 b19a5c98e43b 6 years ago 824MB
安裝步驟3:創(chuàng)建容器
創(chuàng)建容器方式1:快速創(chuàng)建容器
shell> docker create -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 \
-e ES_JAVA_OPTS="-Xms1g -Xmx1g" \
--name elasticsearch1 docker.elastic.co/elasticsearch/elasticsearch:7.10.0
--ulimit nofile=65536:65536
--privileged=true
安裝步驟4:運行容器
shell> docker start elasticsearch1
安裝步驟5:檢查是否安裝成功
瀏覽器訪問http://localhost:9200, 如果出現(xiàn)以下界面就是安裝成功:
ElasticSearch 配置
工作目錄/WorkingDir
"WorkingDir": "/usr/share/elasticsearch"
設(shè)置跨域請求
shell> docker exec -it elasticsearch1 /bin/bash
shell> vi /usr/share/elasticsearch/config/elasticsearch.yml
增加如下配置:
http.cors:
enabled: true
allow-origin: "*"
設(shè)置 JVM 內(nèi)存參數(shù)
shell> docker exec -it elasticsearch1 /bin/bash
shell> vi /usr/share/elasticsearch/config/jvm.options
修改如下配置:
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## which should be named with .options suffix, and the min and
## max should be set to the same value. For example, to set the
## heap to 4 GB, create a new file in the jvm.options.d
## directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.9/heap-size.html
## for more information
##
################################################################
-Xms1g
-Xmx1g
設(shè)置密碼
啟用密碼訪問
shell> docker exec -it elasticsearch1 bash
shell> vi /usr/share/elasticsearch/config/elasticsearch.yml
修改配置:
http.cors:
enabled: true
allow-origin: "*"
allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
設(shè)置6個賬戶密碼
shell> docker exec -it elasticsearch1 /bin/bash
shell> cd /usr/share/elasticsearch/bin
shell> elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
容器設(shè)置
容器隨 docker 自動啟動
設(shè)置容器的重啟策略
shell> docker update --restart=always elasticsearch1
- 每次docker啟動時,容器也會自動啟動
容器設(shè)置IP
向網(wǎng)絡(luò)中添加容器
shell> docker network connect --ip 172.19.0.2 mynetwork elasticsearch1
- docket ip : 172.19.0.2
安裝elasticsearch-head
Docker安裝 elasticsearch-head
其它
略文章來源:http://www.zghlxwxcb.cn/news/detail-763894.html
參考
https://blog.csdn.net/qq_40942490/article/details/111594267
https://www.cnblogs.com/jianxuanbing/p/9410800.html
https://blog.csdn.net/teyue87/article/details/122626499
https://blog.csdn.net/qq_44732146/article/details/120744829
https://gitee.com/mirrors/elasticsearch
https://github.com/mobz/elasticsearch-head文章來源地址http://www.zghlxwxcb.cn/news/detail-763894.html
到了這里,關(guān)于Docker安裝ElasticSearch/ES 7.10.0的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!