1.需要在配置文件中开启x-pack验证, 修改config目录下面的elasticsearch.yml文件,在里面添加如下内容,并重启.
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled:true
2,执行设置用户名和密码的命令,这里需要为4个用户分别设置密码,elastic, kibana, logstash_system,beats_system
切换用户 sudo su – elastic
如果遇到:elasticsearch.keystore 权限不够 chmod 777 elasticsearch.keystore
./elasticsearch-setup-passwordsinteractive
成功后 一直按y
修改所有用户的密码
3.修改项目配置application.properties
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=123456