1、在ES的配置文件elasticsearch.yml添加
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
2、生成账号密码
/bin/elasticsearch-setup-passwords auto //自动生成密码,kibana、logstash、filebeat的密码自动生成
/bin/elasticsearch-setup-passwords interactive //交互式生成密码,每个密码自定义
3、在kibana配置文件中添加用户名和密码
在kibana.yml文件最后添加
elasticsearch.username: "elastic" //默认账号,不能修改
elasticsearch.password: "hello12345" //自定义密码
4、在logstash输出中配置用户名和密码
output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "logstash-nginx"
workers => 1
template_overwrite => true
user => "elastic"
password => "Oracle1234!"
}
stdout { codec => rubydebug }
}
https://www.yangxinghui.com/599.html
密码验证:
本地 验证 elastic 账户
curl -u elastic 'http://localhost:9200/_xpack/security/_authenticate?pretty'
重置 elastic 账户密码
curl -u elastic -XPUT 'http://localhost:9200/_xpack/security/user/elastic/_password?pretty' -H 'Content-Type: application/json' -d'{"password" : "elastic"}
参考: