如何为elasticsearch用户设置密码?

pro*_*int 4 elasticsearch

我正在尝试为我的 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]
Run Code Online (Sandbox Code Playgroud)

我尝试检查我的 ES 实例状态:

curl http://XXX:9200/_cluster/health?pretty
Run Code Online (Sandbox Code Playgroud)

并得到

{
  "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
}
Run Code Online (Sandbox Code Playgroud)

所以,看起来我无法设置密码,因为我无法进行身份验证:)?

小智 7

这是为 Elasticsearch 设置安全性的官方文档

第1步: cd /usr/share/elasticsearch/

第2步:

sudo bin/elasticsearch-setup-passwords auto

         
Run Code Online (Sandbox Code Playgroud)

或者

sudo bin/elasticsearch-setup-passwords interactive
Run Code Online (Sandbox Code Playgroud)

auto - 使用随机生成的密码交互 - 使用用户输入的密码

以上命令可以帮助您设置密码

  • 正如我上面所描述的 - 它无法设置密码 (2认同)
  • 对于其他人``/usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto```但它不起作用。```原因:集群状态尚未恢复,无法写入 [null] 索引``` (2认同)