如何设置ElasticSearch用户的密码?

8ljdwjyq  于 5个月前  发布在  ElasticSearch
关注(0)|答案(5)|浏览(107)

我正在尝试为我的ES云启用安全性。我正在按照以下说明操作:
https://www.elastic.co/guide/en/elasticsearch/reference/7.5/configuring-security.html
当我尝试运行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
}


所以,看起来我不能设置密码,因为我不能验证:)?

4ioopgfo

4ioopgfo1#

下面是为Elasticsearch设置安全性的官方doc
步骤1:cd /usr/share/elasticsearch/
第二步:

sudo bin/elasticsearch-setup-passwords auto

字符串

sudo bin/elasticsearch-setup-passwords interactive


auto -使用随机生成的密码交互式-使用用户输入的密码
以上命令可以帮助您设置密码

rbpvctlc

rbpvctlc2#

以下是我在Windows中的工作。
确保弹性节点已启动并正在运行。

  • elasticsearch-setup-passwords auto -u“http://localhost:9200”*

Elastic将要求您继续设置自动生成的密码。一旦您继续进行,您将获得弹性/kibana/beats等的密码。

xsuvu9jc

xsuvu9jc3#

对于windows,在cmd中运行elk
打开其他cmd和过去的命令,其中文件夹中的麋鹿

bin/elasticsearch-setup-passwords auto

字符串

k4emjkb1

k4emjkb14#

经过一些研究,我发现Magento将凭据存储在XML文件中,可以在基本目录中找到:

+\magento\vendor\magento\module-elasticsearch-7\etc\config.xml. Please update your elastic password instead of XXXXXX and also in case you have chosen a different version of elastic, the location would be different.
    -->
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
        <default>
            <catalog>
                <search>
                    <engine>elasticsearch7</engine>
                    <elasticsearch7_server_hostname>localhost</elasticsearch7_server_hostname>
                    <elasticsearch7_server_port>9200</elasticsearch7_server_port>
                    <elasticsearch7_index_prefix>magento2</elasticsearch7_index_prefix>
                    <elasticsearch7_enable_auth>1</elasticsearch7_enable_auth>
                    <elasticsearch7_username>elastic</elasticsearch7_username>
                    <elasticsearch7_password>XXXXXXXXXXX</elasticsearch7_password>nfog              
                    <elasticsearch7_server_timeout>15</elasticsearch7_server_timeout>
                    <elasticsearch7_minimum_should_match/>
                </search>
            </catalog>
        </default>
    </config>

字符串

lo8azlld

lo8azlld5#

在你的bin文件夹D:\software\elasticsearch-8.8.0\bin中打开cmd并点击>elasticsearch.bat
在你的bin文件夹D:\software\elasticsearch-8.8.0\bin中打开另一个cmd并点击>elasticsearch-reset-password -u elastic

相关问题