无法通过基本身份验证从URL存储库恢复快照

问题描述

问题:

我正在尝试在ES实例 ES1 上创建快照,并将其还原到另一个实例 ES2 。当远程URL需要基本身份验证时,它无法恢复。

ES版本:6.5.4

成功案例和失败案例:

成功案例:当公开了 ES1 存储库文件夹的网站向互联网开放(不进行身份验证)时,列表/恢复正常运行。例如,当回购URL为“ http://snapshots.example-server.com”

失败情况:将基本身份验证添加到同一URL时,它不起作用。例如,当回购URL为:“ http:// 用户名:密码 @ snapshots.example-server.com”

当我尝试使用基本身份验证列出URL存储库中的快照时,出现的错误是:

{
  "error": {
    "root_cause": [
      {
        "type": "repository_exception","reason": "[remote-repo] could not read repository data from index blob"
      }
    ],"type": "repository_exception","reason": "[remote-repo] could not read repository data from index blob","caused_by": {
      "type": "i_o_exception","reason": "Server returned HTTP response code: 401 for URL: http://username:password@snapshots.example-server.com/index.latest"
    }
  },"status": 500
}

设置:

设置 ES1

第1步:修改配置文件:

path.repo: ["/path/to/es1_repo"]

第2步:创建存储库:

PUT /_snapshot/es1_repo
{
  "type": "fs","settings": {
    "location": "/path/to/es1_repo"
  }
}

第3步:使存储库路径可从Internet访问: 我已经在 ES1 机器上设置了一个nginx服务器,以显示"/path/to/es1_repo”目录列表,例如:http://snapshots.example-server.com。已启用基本身份验证。例如,您可以使用http:// username:password@snapshots.example-server.com来访问该存储库,然后会看到目录列表。

第4步:创建快照:

PUT /_snapshot/es1_repo/snapshot_1?wait_for_completion=true
{
  "indices": "the_index_name","ignore_unavailable": true,"include_global_state": false
}

设置 ES2

第5步:添加到弹性配置:

repositories.url.allowed_urls: "http://username:password@snapshots.example-server.com"

第6步:注册存储库

PUT _snapshot/remote-repo
{
   "type": "url","settings": {
       "url": "http://username:password@snapshots.example-server.com"
   }
}

第7步:检查快照是否可访问:

GET _snapshot/remote-repo/_all

在此步骤中,将显示粘贴在顶部的错误。如果我禁用基本身份验证,则可以正常工作。

这里可能是什么问题?

解决方法

你应该做这些:

  1. 在 elasticsearch.yaml 或 docker 环境中将存储库添加到白名单
repositories.url.allowed_urls: "http://snapshots.example-server.com"
  1. 创建快照存储库
PUT _snapshot/remote-repo
{
   "type": "url","settings": {
       "url": "http://snapshots.example-server.com","client": "your_client",}
}
  1. 将用户名和密码添加到 Elasticsearch 密钥库
    bin/elasticsearch-keystore add url.client.your_client.username
    bin/elasticsearch-keystore add url.client.your_client.password

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...