ElasticSearch重置密码

对于新安装的ElasticSearch,可使用如下,生成密码

1.使用内置用户生成密码

bin/elasticsearch-setup-passwords interactive

2.自动生成密码

bin/elasticsearch-setup-passwords auto

以上两种方式均报错,显示无法通过默认的 elastic 用户认证

原因是:

1、密码已被修改(但您不记得新密码)

2、使用的 keystore 文件不匹配(如配置了其他位置的 keystore)

推测是已经修改了密码,便重置elastic用户密码

1.停止elasticsearch,直接将datastore整个关掉

2.临时禁用安全功能

编辑 config/elasticsearch.yml,添加或修改以下配置

xpack.security.enabled: false

3.重启Elasticsearch,确定elasticsearch已经启动

4.使用API重置密码

默认端口我这已经改变,自行确认自己的端口

curl -X POST "localhost:9301/_security/user/elastic/_password?pretty" \

-H "Content-Type: application/json" \

-d '{"password": "changeme@123"}'

5.重新启动安全功能

修改 elasticsearch.yml,恢复安全设置:

xpack.security.enabled: true

6.重启Elasticsearch

7.验证新密码

我这es的端口由默认的9200改为9201,自行确定自己的端口

curl -u elastic:changeme@123 "http://localhost:9201/_cluster/health?pretty"

如果返回 401 Unauthorized,说明密码错误。

如果返回集群状态,说明认证成功

相关推荐
transitory_truth1 天前
es-api介绍
elasticsearch
q***47181 天前
使用Canal将MySQL数据同步到ES(Linux)
linux·mysql·elasticsearch
...对方正在输入......2 天前
Elasticsearch集群部署实战指南
elasticsearch·jenkins
Hello.Reader2 天前
使用 Flink CDC 搭建跨库 Streaming ETLMySQL + Postgres → Elasticsearch 实战
大数据·elasticsearch·flink
Elasticsearch2 天前
Elastic AI agent builder 介绍(五)- 备份 tools 及 agents
elasticsearch
练习时长一年2 天前
git常用命令总结
大数据·git·elasticsearch
little_xianzhong2 天前
把一个本地项目导入gitee创建的仓库中
大数据·elasticsearch·gitee
哈__3 天前
exa 在 HarmonyOS 上的构建与适配
elasticsearch·华为·harmonyos
Hello.Reader3 天前
Flink CDC 用 Oracle CDC 实时同步数据到 Elasticsearch
elasticsearch·oracle·flink