修改ElasticSearch的密码

1. 添加配置

vi /usr/share/elasticsearch/config/elasticsearch.yml
# 配置X-Pack

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

2. 重启es服务

# 如果是docker就重启容器
systemctl restart elasticsearch

3. 设置密码

/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

4. 修改密码

示例修改elastic账号的密码为123456

curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

5. 验证

访问 127.0.0.1:9200 具体根据自己IP