在elasticsearch.yml中配置端口
http.port: 59200
在elasticsearch.yml中添加如下内容并重启
xpack.security.enabled: true
执行设置用户名和密码的命令,这里需要为4个用户分别设置密码,elastic, kibana, logstash_system,beats_system
elasticsearch-setup-passwords interactive
密码:6yhn&ujM
验证:curl http://localhost:59200 -u elastic:6yhn&ujM
修改密码命令如下
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://localhost:59200/_xpack/security/user/elastic/_password' -d '{"password":"6yhn&ujM"}'
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://localhost:59200/_security/user/elastic/_password' -d '{"password":"6yhn&ujM"}'
spring yml配置
elasticsearch:
rest:
uris: ["http://localhost:59200"]
username: "elastic"
password: "6yhn&ujM"
本文介绍了如何在Elasticsearch中配置端口,并启用安全性,通过设置xpack.security.enabled为true来保护端口。接着,详细说明了如何使用命令行工具elasticsearch-setup-passwords为默认用户设置密码,以及验证密码设置是否成功。此外,还展示了如何使用curl命令修改用户密码。最后,提供了Spring YML配置中关于Elasticsearch的用户名和密码设置。
1766

被折叠的 条评论
为什么被折叠?



