1、docker部署es
2、docker默认无密码,现在需求需要增加安全性,需要增加密码
1、启动es镜像,参考
https://blog.csdn.net/myloverisxin/article/details/1270753872、修改es配置
vi /opt/elasticsearch/config/elasticsearch.yml3、开启安全验证
xpack.security.enabled: true xpack.security.transport.ssl.enabled: true
3、重启docker
docker restart 332098b1879d说明: 容器ID
4、进入到容器
docker exec -it 332098b1879d /bin/bash5、生成证书1
./bin/elasticsearch-certutil ca说明: 一直回车即可
6、生成证书2
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p127、将证书移动到config
mv elastic-certificates.p12 ./config8、生成密码
./bin/elasticsearch-setup-passwords auto
说明: 一路回车,回车完后会打印生成的密码
9、退出容器,增加配置并保存
vi /opt/elasticsearch/config/elasticsearch.ymlxpack.security.transport.ssl.keystore.type: PKCS12 xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.type: PKCS12 xpack.security.audit.enabled: true10、增加文件可访问权限
chmod +777 /opt/elasticsearch/config/elastic-certificates.p1211、重启镜像
docker restart 332098b1879d12、如果报错了,可能需要查看日志并解决
docker logs -f 332098b1879d13、重启结果
netstat -anp | grep 920014、验证密码设置
~~