记录es配置密码踩的坑 以及解决方案。

es版本号:7.10

java版本 8
在linux上搭建。

哎,一把辛酸泪啊。本来以为简简单单配置个密码。谁知道会这么多的坑。

根据网上的文档,修改各节点配置文件。

xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true

然后各节点重启。

重启后 找一台机器输入。

./bin/elasticsearch-setup-passwords interactive

配置各个用户的密码。

然后出现错误 apm_system 用户创建密码失败。

ERROR: Failed to set password for user [apm_system].

使用./bin/elasticsearch-setup-passwords auto 自动创建也是不行。

重试多次依旧不行。

然后加入身份验证

https://www.elastic.co/cn/blog/getting-started-with-elasticsearch-security

根据上面链接操作,我的环境中启动时异常

ElasticsearchSecurityException[failed to load SSL configuration [xpack.security.transport.ssl]]; nested: ElasticsearchException[failed to initialize SSL KeyManager]; nested: IOException[keystore password was incorrect]; nested: UnrecoverableKeyException[failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.];
Likely root cause: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

使用另外的方式创建

./bin/elasticsearch-certutil ca --pem --out ca.zip --days 36500 -s  

在elasticsearch 目录下生成ca.zip 然后解压

unzip ca.zip

./bin/elasticsearch-certutil cert --ca-cert ca/ca.crt --ca-key ca/ca.key --pem --name za-test --out za-test.zip --days 36500 -s

在elasticsearch 目录下生成za-test.zip 解压

unzip za-test.zip

将解压后的文件放入 config中certs文件夹中

mkdir config/certs

cp ca/* za-test/* config/certs

拷贝 certs文件夹 到其他服务器config目录下

配置文件修改

所有节点重启es 

../bin/elasticearch -d

启动没有报错了T.T 

然后执行

./bin/elasticsearch-setup-passwords interactive

也没有apm_system 用户密码创建失败了。

网页登陆试试,成功弹出输入密码head,输入密码成功登陆!

结下来 kibana 配置文件中加入密码。重启。kibana 启动成功!

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐