Elasticsearch7.7设置账号密码时的逻辑矛盾问题和文章相关评论

一、Elasticsearch7.7设置账号密码时的逻辑矛盾问题

    publish:June 19, 2020 -Friday  2019年1月30日,外媒又报道了一起Elasticsearch数据泄露事件!2019年1月份的至少有6起Elasticsearch数据泄露事件了。原因何在,很简单,开发者在服务启动之后总是懒得去修改,哪怕是添加个密码,不信?你去看看你们公司的REDIS服务器,看看有多少设置了密码,至少我公司不相关的部门的业务,他们的REDIS我都能远程登录(因对接关系我知道了redis服务器IP)。

    好吧,回到Elasticsearch7.7的密码设置问题上来吧,说说我遇到的Elasticsearch设置账号密码时的矛盾问题,很扯蛋。不过也不要上纲上线,因为这问题肯定是可以解决的,但我在写这篇笔记的时候还没有找到方法,而我又想基于此留下点笔记。操作过程如下:

#1.开始给elasticsearch设置密码
tiger@n21-045-025:/usr/share/elasticsearch$ sudo bin/elasticsearch-setup-passwords interactive
It doesn't look like the X-Pack security feature is enabled on this Elasticsearch node.
Please check if you have enabled X-Pack security in your elasticsearch.yml configuration file.
ERROR: X-Pack Security is disabled by configuration.
#提示没有在配置文件中开启X-Pack,OK
#2.开启X-Pack配置
tiger@n21-045-025:/opt/elasticsearch$ sudo vim /etc/elasticsearch/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
#新增加了以下两行配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
#3.增加完配置之后要重启elasticsearch不?你说不重启能行吗?不重启就还是没有配置啊。
#重启elasticsearch之后,然后我们再来配置密码
#修改完配置重启es之后使用elasticsearch-setup-passwords interactive
tiger@n21-045-025:/usr/share/elasticsearch$ sudo bin/elasticsearch-setup-passwords interactive
#Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana]: 
Reenter password for [kibana]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Unexpected response code [503] from calling PUT http://192.21.15.25:9200/_security/user/apm_system/_password?pretty
Cause: Cluster state has not been recovered yet, cannot write to the [null] index
Possible next steps:
* Try running this tool again.
* Try running with the --verbose parameter for additional messages.
* Check the elasticsearch logs for additional error details.
* Use the change password API manually. 
ERROR: Failed to set password for user [apm_system]
#看设置报错:
tiger@n21-045-025:/usr/share/elasticsearch$ sudo bin/elasticsearch-setup-passwords interactive --verbose
Running with configuration path: /etc/elasticsearch
Testing if bootstrap password is valid for http://192.21.15.25:9200/_security/_authenticate?pretty
Checking cluster health: http://192.21.15.25:9200/_cluster/health?pretty
{
  "error" : {
    "root_cause" : [
      {
        "type" : "master_not_discovered_exception",
        "reason" : null
      }
    ],
    "type" : "master_not_discovered_exception",
    "reason" : null
  },
  "status" : 503
}
Failed to determine the health of the cluster running at http://192.21.15.25:9200
Unexpected response code [503] from calling GET http://192.21.15.25:9200/_cluster/health?pretty
Cause: master_not_discovered_exception
It is recommended that you resolve the issues with your cluster before running elasticsearch-setup-passwords.
It is very likely that the password changes will fail when run against an unhealthy cluster.
Do you want to continue with the password setup process [y/N]ERROR: User cancelled operation

        看上面的报错,这时提示9200服务报503错误,什么原因呢?我设置了要要账号密码啊。现在从浏览器访问9200端口也是需要账号密码才能登录的,请求 http://192.21.15.25:9200/_cluster/health?pretty 接口也会阻塞一直不响应,因为在等待账号密码呢。

        这就矛盾了:我没启用xpack.security.enabled时,不能进入设置密码。但我启动了之后设置密码时它会调用_cluster/health?pretty检查集群状态然后就有问题了。这不矛盾了吗?
网上找了一些资料,包括google,但也都没有解决:比如 elasticsearch - Apply security on ELK Cluster - authentication issue - Stack Overflow 这里说把所有的节点都加上上面的X-pack配置重启,然后使用auto进行密码设置。一样会出现无法检查集群健康状态的问题。Failed to determine the health of the cluster running at http://192.21.15.25:9200 Unexpected response code [503] from calling GET ​http://192.21.15.25:9200/_cluster/health?pretty​

        这个肯定不能是个问题!这个也一定能解决的,暂时挺脑火,留个笔记在这里!

二、Elasticsearch7.7设置账号密码时的逻辑矛盾问题文章评论

Level : 1.    User:us20200621125549-604    Time:2020-06-21 13:10:47
N年老友链来访,博主可好?我还没失联,只是博客懒得更新。

Level : 2.    User:us20200621125549-604    Time:2020-06-21 13:11:23
噢 对了 我是回味依旧博客博主

Level : 3.    User:us20200403115246-946    Time:2020-06-21 14:16:29
[04007]我也只是把这当作我的在线笔记,好搜索。

Level : 4.    User:us20200714213936-170    Time:2020-07-14 21:40:44
我也遇到这个问题,请问博主解决了没

Level : 5.    User:us20200716173241-723    Time:2020-07-22 15:04:12
开个普通用户操作,问题解决

Level : 6.    User:us20200724112955-542    Time:2020-07-24 13:29:16
楼主解决这个问题了么

Level : 7.    User:us20201110183802-281    Time:2020-11-10 18:40:19
楼主解决这个问题了么

Level : 8.    User:us20201117095144-969    Time:2020-11-17 09:55:11
没解决写在这里干嘛,晕死

Level : 9.    User:us20190316202924-932    Time:2020-11-18 21:25:54
[04007]不好意思,我后来没怎么用ES了,没再研究

Level : 10.    User:us20201222175155-687    Time:2020-12-22 18:21:54
我也遇到了,各种研究破案了,需要先制作证书,然后在各个节点上添加,集群起来后才能修改,完美解决。

Level : 11.    User:us20201223090022-836    Time:2020-12-23 19:20:40
[04007]感谢:User:us20201222175155

Level : 12.    User:us20210713161623-531    Time:2021-07-13 17:22:43
可参考这篇文章。已解决 https://blog.csdn.net/zhanremo3062/article/details/118703994

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林戈的IT生涯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值