赞
踩
以下步骤都是基于centos7、elasticsearch-6.8.6.tar.gz版本下的集群已经正确启动后的操作。
1.生成ca文件,bin/elasticsearch-certutil ca,可以指定文件名,配置密码
2.生成节点秘钥文件,bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12,可以指定文件名,配置密码
3.复制节点秘钥文件到各节点的指定目录下,具体哪个目录是由elasticsearch.yml中的配置项xpack.security.transport.ssl.keystore.path、xpack.security.transport.ssl.truststore.path指定
3.1.如果指定了秘钥文件密码,需要执行以下两条命令(不执行启动会报错,所有节点都要执行)
- bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
- bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
4.增加elasticsearch.yml配置
- xpack.security.enabled: true
- xpack.security.transport.ssl.enabled: true
- xpack.security.transport.ssl.verification_mode: certificate
- xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
- xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
5.重启es集群
6.设置密码bin/elasticsearch-setup-passwords interactive
7.测试访问
- # 不加密访问(失败)
- curl 192.168.113.197:9202/_cluster/health?pretty
- # 加密访问(成功)
- curl -u elastic:elastic 192.168.113.197:9202/_cluster/health?pretty
参考:https://blog.csdn.net/u011271894/article/details/99626711
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。