1. 问题

elasticsearch 突然出现问题

Authentication of [elastic] was terminated by realm [reserved] -
failed to authenticate user [elastic]

2. 网上找答案

在网上找解决方案,根据如下操作(可行方案的网址 https://elasticsearch.cn/question/11517)可以将es密码重新设置,使其恢复正常,但是我是单节点部署的,数据最后有点问题,最后删除索引了,重建索引

***重点生成新的证书
***重点生成新的证书
***重点生成新的证书 问题处理流程:

  1. 停止es
  2. xpack取消
  3. 启动,以无密码形式登录
  4. 删除.security
  5. 停es
  6. xpack开启
  7. 删除elasticsearch/config目录下elasticsearch.keystore、elastic-certificates.p12
  8. bin目录下执行 ./elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass “”
    如果是集群,需要把config/elastic-certificates.p12拷贝到其他节点的config目录下
  9. es节点依次启动
  10. 设置密码,等待cluster health is currently RED.变为green在下一步

3.执行步骤细化

3.1 停止es

用netstat -ntlp 查询es启动进程,用kill 744449 干掉对应的es进程
在这里插入图片描述

3.2 注释xpack密码设置的配置信息

进入elasitcsearch的config目录,找到elasticsearch.yml配置文件,vim打开,注释掉下面两项配置
,配置注释后,es就不需要密码也可以登录

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

在这里插入图片描述

3.3 启动es

./bin/elasticsearch -d 启动es

./bin/elasticsearch -d

3.4 删除.security索引

在这里插入图片描述

3.5 重新停止es

同步骤3.1

3.6 打开注释xpack密码设置的配置信息

将elasticsearch.yml配置文件中两项注释掉的配置重新打开注释

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

3.7 删除elasticsearch/config目录下elasticsearch.keystore、elastic-certificates.p12

如标题描述

3.8 bin目录下执行 ./elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass “”

如标题描述

3.9 es启动

同步骤3.3

3.10 重新设置密码

在bin目录下执行如下命令,设置es密码,设置完成后即可正常使用带用户名和密码的es

./elasticsearch-setup-passwords interactive
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐