我正在尝试为我的 ES 云启用安全性。我正在遵循以下说明:
https://www.elastic.co/guide/en/elasticsearch/reference/7.5/configuring-security.html
我被困在第 6 点。当我尝试运行 bin/elasticsearch-setup-passwords interactive
时出现错误:
Failed to determine the health of the cluster running at http://XXX:9200
Unexpected response code [503] from calling GET http://XXX:9200/_cluster/health?pretty
Cause: master_not_discovered_exception
It is recommended that you resolve the issues with your cluster before running elasticsearch-setup-passwords.
It is very likely that the password changes will fail when run against an unhealthy cluster.
Do you want to continue with the password setup process [y/N]
我尝试检查我的 ES 实例状态:
curl http://XXX:9200/_cluster/health?pretty
并得到
{
"error" : {
"root_cause" : [
{
"type" : "security_exception",
"reason" : "missing authentication credentials for REST request [/_cluster/health?pretty]",
"header" : {
"WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type" : "security_exception",
"reason" : "missing authentication credentials for REST request [/_cluster/health?pretty]",
"header" : {
"WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status" : 401
}
所以,看起来我无法设置密码,因为我无法进行身份验证:)?
最佳答案
这是为 Elasticsearch 设置安全性的官方 doc
步骤1:cd /usr/share/elasticsearch/
第2步:
sudo bin/elasticsearch-setup-passwords auto
或者sudo bin/elasticsearch-setup-passwords interactive
auto - Uses randomly generated passwords interactive - Uses passwords entered by a user
以上命令可以帮助您设置密码
关于elasticsearch - 如何为elasticsearch用户设置密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59644348/