ElasticSearch 添加用户访问权限
首选进入 elasticsearch.yml 配置文件中加上这句代码:xpack.security.enabled: true
docker exec -it elasticsearch /bin/bash
然后cmd 定位到bin文件夹,执行 ./elasticsearch-setup-passwords interactive
执行设置用户名和密码的命令,需要设置:elastic ,kibana,logstash_system,beats_system
然后重启一下ES服务,重新运行一下ES,出现的用户名和密码的认证了。
如果安装了 kibana 来管理的话还的进入配置文件 kibana.yml
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.username: "elastic"
elasticsearch.password: "密码"
elasticsearch.hosts: [ "http://IP:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"
同理 logstash.yml 里也增加
http.host: "0.0.0.0"
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.username: "elastic"
xpack.monitoring.elasticsearch.password: "密码"
同步配置依然也添加output {
elasticsearch {
user => "elastic"
password => "密码"
然后需要连接的业务
http://用户名:密码@ip:端口
这样就可以了,当然可能还会有其它问题,需要查看日志解决,一般情况这样就OK了