elasticsearch:8.6.2 docker 集群(安全

2023-03-05  本文已影响0人  廖全磊LesterLiao

docker 单机搭建请移步官方文档

第一台机器启动命令

docker run --name es1 --net elastic -p 9200:9200 -p 9300:9300 \
-e "network.bind_host=0.0.0.0" -e "network.publish_host=172.16.49.91"  \
-v /es-data/data:/usr/share/elasticsearch/data \
-it docker.elastic.co/elasticsearch/elasticsearch:8.6.2

启动成功会生成token如下



通过方框内的token,继续创建第二台机器

docker run --name es2 -e ES_JAVA_OPTS="-Xms1g -Xmx1g" -p 9200:9200 -p 9300:9300 --net elastic \
-e "network.bind_host=0.0.0.0" -e "network.publish_host=172.16.49.86"  \
-e ENROLLMENT_TOKEN="eyJ2ZXIiOiI4LjYuMiIsImFkciI6WyIxNzIuMTYuNDkuOTE6OTIwMCJdLCJmZ3IiOiI5ZDEyNmVkYWQxNjMzYmI3MGY5MmVkZmMzN2ExMGQ5MzFmNjhlMWE3N2QzZDY1OWFjNDgxZTE0MzI0MzJjYTA3Iiwia2V5IjoiTGZyTHRZWUJURzJmOHNURWdYN3g6OURWRGlFQWlUT1NBNVNWOXdYTE9MZyJ9" \
-it docker.elastic.co/elasticsearch/elasticsearch:8.6.2

踩坑记录

es集群从节点重启报错

ERROR: Skipping security auto configuration because it appears that the node is not starting up for the first time. The node might already be part of a cluster and this auto setup utility is designed to configure Security for new clusters only.

此错误,需要删除容器中的环境变量ENROLLMENT_TOKEN

方法如下

# 找到容器目录
docker inspect es2 | grep ResolvConfPath
# 暂停 docker 服务
systemctl stop docker
#  找到 resolv.conf 同级目录下的 config.v2.json 并移除其文件中的"ENROLLMENT_TOKEN" key
# 启动docker 服务
systemctl start docker
# 启动 容器(完美解决)
docker start es2

metricbeat 安装完成后有两个地方需要修改,才能顺利采集es数据

1、配置 /etc/metricbeat/metricbeat.yml 如下,主要用于向es中发送数据



2 、配置 /etc/metricbeat/modules.d/elasticsearch-xpack.yml 如下,主要用于收集es数据


上一篇 下一篇

猜你喜欢

热点阅读