启动 Elasticsearch 程序
./elasticsearch -d创建密码
$ ./elasticsearch-setup-passwords interactive Unexpected response code [500] from calling GET http://127.0.0.1:9200/_security/_authenticate?pretty It doesn't look like the X-Pack security feature is enabled on this Elasticsearch node. Please check if you have enabled X-Pack security in your elasticsearch.yml configuration file. ERROR: X-Pack Security is disabled by configuration.
需要在elasticsearch的配置文件elasticsearch.yml配置X-Pack
$ vim ../config/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
再次尝试创建密码
./elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
如果安装了kibana记得添加认证信息
vi ../config/kibana.yml
elasticsearch.username: "elastic"
elasticsearch.password: "passwd"
可以通过ES DSL进行密码修改
POST /_security/user/elastic/_password
{
"password": "123456"
}
部分内容参考
https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-security.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html
发表评论