问小白 wenxiaobai
资讯
历史
科技
环境与自然
成长
游戏
财经
文学与艺术
美食
健康
家居
文化
情感
汽车
三农
军事
旅行
运动
教育
生活
星座命理

使用Docker安装部署ES8+kibana,以及HTTPS配置生成

创作时间:
作者:
@小白创作中心

使用Docker安装部署ES8+kibana,以及HTTPS配置生成

引用
CSDN
1.
https://m.blog.csdn.net/weixin_48043634/article/details/145679434

本文将详细介绍如何使用Docker部署Elasticsearch 8(ES8)和Kibana,并配置HTTPS。文章内容包括容器拉取、部署容器、生成SSL证书、完成部署初始化以及Kibana配置等步骤。

1.容器拉取

ES8拉取

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.15.0

Kibana拉取

docker pull docker.elastic.co/kibana/kibana:8.15.0

2.部署容器

ES8部署

docker run --name es0 \
  -p 9200:9200 \
  -e "ES_JAVA_OPTS=-Xms2048m -Xmx2048m" \
  -e "discovery.type=single-node" \
  -v 路径/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
  -v 路径/data:/usr/share/elasticsearch/data \
  -v 路径/backup:/usr/share/elasticsearch/backup \
  docker.elastic.co/elasticsearch/elasticsearch:8.15.0

注意:请将"路径"替换为实际的持久化路径。在运行前,请确保已经创建好相应的文件夹,并创建好以下yml配置文件:

cluster.name: "docker-cluster"
network.host: 0.0.0.0
path.repo: ["/usr/share/elasticsearch/backup"]
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: X-Requested-With,Content-Type,Content-Length,Authorization
xpack.security.enrollment.enabled: true
xpack.security.http.ssl.enabled: false

Kibana部署

docker run --name kib01 \
  -p 5601:5601 \
  -e I18N_LOCALE=zh-CN \
  docker.elastic.co/kibana/kibana:8.15.0

3.生成SSL证书并完成部署初始化

进入ES8容器

docker exec -it es0 /bin/bash

使用ES8自带工具生成SSL证书

./bin/elasticsearch-certutil http

执行过程中需要回答以下问题:

  1. 是否生成CSR?(N)
  2. 是否使用现有证书?(N)
  3. 是否修改生成证书配置?(N)
  4. 输入证书的密码
  5. 生成证书有效时长(5Y)
  6. 是否单点证书?(Y)
  7. 输入内网IP
  8. 再次输入确认
  9. 是否修改配置?(N)
  10. 输入生成的路径(/usr/share/elasticsearch/data/ssl.zip)

解压并配置SSL

生成完成后到指定的路径/data进行解压:

unzip ssl.zip -d ssl

修复错误:
如果遇到以下错误:

ERROR: Unable to create an enrollment token. Elasticsearch node HTTP layer SSL configuration Keystore doesn't contain any PrivateKey entries where the associated certificate is a CA certificate

可以使用以下命令修复:

keytool -importkeystore -destkeystore 路径/data/ssl/ca/ca.p12 -srckeystore 路径/data/ssl/elasticsearch/http.p12

修改yml配置

cluster.name: "docker-cluster"
network.host: 0.0.0.0
path.repo: ["/usr/share/elasticsearch/backup"]
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: X-Requested-With,Content-Type,Content-Length,Authorization
xpack.security.enrollment.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: /usr/share/elasticsearch/data/ssl/ca/ca.p12
xpack.security.http.ssl.keystore.password: "设置的密码"

然后重启ES8的docker容器。

4.获取令牌和重置初始密码

获取令牌(注意先进入容器)

bin/elasticsearch-create-enrollment-token -s kibana

重置密码

bin/elasticsearch-reset-password -u elastic

5.完成Kibana配置

  1. 将先前获取的令牌填入
  2. 输入账号密码登录

© 2023 北京元石科技有限公司 ◎ 京公网安备 11010802042949号