在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"