修改配置文件
[root@mq2 conf]# vim /data/elasticsearch/conf/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
启动elasticsearch
docker run -d -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -v /data/elasticsearch/conf/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name elasticsearch elasticsearch:6.8.7
进入容器分别为4个用户设置密码,elastic, kibana, logstash_system,beats_system
[root@mq2 conf]# docker exec -it elasticsearch bash
[root@ad568f80bbb3 elasticsearch]# ./bin/elasticsearch-setup-passwords interactive
输入一个"y",然后设置密码
- 使用elasticsearch-head连接es会有一个认证弹窗,用户输入:elastic,然后输入密码即可
修改用户密码
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://192.168.0.177:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'