当前位置:   article > 正文

Docker安装ElasticSearch/ES 7.10.0_docker安装elasticsearch7.10

docker安装elasticsearch7.10

前言

  • TencentOS Server 3.1
  • Docker version 19.03.14, build 5eb3275d40
  • elasticsearch: 7.10.0

安装ElasticSearch/ES

安装步骤1:准备

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]       
     
```
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3. 也可从docker hub上搜索镜像。

docker hubdocker hub-stage

4. 选择合适的redis镜像。

版本拉取命令
最新版本docker pull elasticsearch:latest
7.4.0docker pull elasticsearch:7.4.0
7.10.0docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.0
7.12.0docker pull elasticsearch:7.12.0
8.0.0docker pull elasticsearch:8.0.0
8.9.0docker pull docker.elastic.co/elasticsearch/elasticsearch:8.9.0

安装步骤2:拉取ElasticSearch镜像

1 拉取镜像

shell> docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.0
  • 1

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
  • 1
  • 2
  • 3
  • 4

安装步骤3:创建容器

创建容器方式1:快速创建容器

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
  • 1
  • 2
  • 3
  • --ulimit nofile=65536:65536
  • --privileged=true

安装步骤4:运行容器

shell> docker start elasticsearch1
  • 1

安装步骤5:检查是否安装成功

浏览器访问http://localhost:9200, 如果出现以下界面就是安装成功:
在这里插入图片描述

ElasticSearch 配置

工作目录/WorkingDir

"WorkingDir": "/usr/share/elasticsearch" 
  • 1

设置跨域请求

shell> docker exec -it elasticsearch1 /bin/bash
shell> vi /usr/share/elasticsearch/config/elasticsearch.yml
  • 1
  • 2

增加如下配置:

http.cors:
  enabled: true
  allow-origin: "*"
  • 1
  • 2
  • 3

设置 JVM 内存参数

shell> docker exec -it elasticsearch1 /bin/bash
shell> vi /usr/share/elasticsearch/config/jvm.options
  • 1
  • 2

修改如下配置:

################################################################
## 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

设置密码

启用密码访问

shell> docker exec -it elasticsearch1 bash
shell> vi /usr/share/elasticsearch/config/elasticsearch.yml
  • 1
  • 2

修改配置:

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

设置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]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

容器设置

容器随 docker 自动启动

设置容器的重启策略

shell> docker update --restart=always elasticsearch1
  • 1
  • 每次docker启动时,容器也会自动启动

容器设置IP

向网络中添加容器

shell> docker network connect --ip 172.19.0.2  mynetwork elasticsearch1 
  • 1
  • docket ip : 172.19.0.2

安装elasticsearch-head

Docker安装 elasticsearch-head

其它

参考

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/128049
推荐阅读
相关标签
  

闽ICP备14008679号