使用 docker 图片在 Rally 中创建轨道时出现连接错误

ConnectionError while creating track in Rally with docker image

我正在尝试使用 Rally 文档页面中的说明从现有 Elasticsearch 集群创建自定义轨道。

我运行集会作为Docker形象。我是 运行 elasticsearch:7.12.0 和 docker 同一个主机中的图像。 docker 容器是 运行 并且可以使用基本身份验证访问主机。

$ sudo docker container ls
CONTAINER ID   IMAGE                                                  COMMAND             CREATED             STATUS             PORTS                                                 NAMES
a60bca4121c6   docker.elastic.co/elasticsearch/elasticsearch:7.12.0   "/bin/tini -- /usr/l…"   About an hour ago   Up About an hour   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 9300/tcp   es01
2241695bdfa7   docker.elastic.co/elasticsearch/elasticsearch:7.12.0   "/bin/tini -- /usr/l…"   About an hour ago   Up About an hour   9200/tcp, 9300/tcp                                    es02


$ curl -XGET http://localhost:9200 -u elastic:esbackup-password
{
  "name" : "es01",
  "cluster_name" : "es-docker-cluster",
  "cluster_uuid" : "04EdIVB_QC2il_3iJCarkw",
  "version" : {
    "number" : "7.12.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
    "build_date" : "2021-03-18T06:17:15.410153305Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

当我尝试使用 --client-options 执行 create-track 命令时,出现下面提到的 ConnectionError。

$ sudo docker run elastic/rally create-track --track=mytrack --target-hosts=localhost:9200 --client-options="timeout:60,use_ssl:false,verify_certs:false,basic_auth_user:'elastic',basic_auth_password:'esbackup-password'" --indices="my-index-local-*" --output-path=~/tracks

    ____        ____
   / __ \____ _/ / /_  __
  / /_/ / __ `/ / / / / /
 / _, _/ /_/ / / / /_/ /
/_/ |_|\__,_/_/_/\__, /
                /____/

[ERROR] Cannot create-track. ConnectionError(<urllib3.connection.HTTPConnection object at 0x7fdc8ca93220>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7fdc8ca93220>: Failed to establish a new connection: [Errno 111] Connection refused).

Getting further help:
*********************
* Check the log files in /rally/.rally/logs for errors.
* Read the documentation at https://esrally.readthedocs.io/en/2.2.0/.
* Ask a question on the forum at https://discuss.elastic.co/tags/c/elastic-stack/elasticsearch/rally.
* Raise an issue at https://github.com/elastic/rally/issues and include the log files in /rally/.rally/logs.

-------------------------------
[INFO] FAILURE (took 1 seconds)
-------------------------------

从错误中可以清楚地看出 docker 容器中的 Rally 运行 无法在单独的容器中创建与 Elasticsearch 运行 的连接。我在 --client-options 中传递凭据,但似乎没有获取这些凭据。

不确定,我在这里做错了什么!任何指针将不胜感激!

感谢 Elastic 团队在他们的官方讨论频道上回答这个问题:

设置需要在 Elasticsearch 和 Rally 容器之间配置和共享 docker 网络,以便它们进行通信。

我们不会在这里说明您的 Elasticsearch 容器是怎样的 运行,但是一旦我们使用网络执行它,我们就可以 运行 使用以下内容(前提是您更换网络和容器)名称占位符):

$ docker run --network <es-network-name> elastic/rally create-track --track=mytrack --target-hosts=<es-container-name>:9200 --client-options="timeout:60,use_ssl:false,verify_certs:false,basic_auth_user:'elastic',basic_auth_password:'esbackup-password'" --indices="my-index-local-*" --output-path=~/tracks

参考 - https://discuss.elastic.co/t/connectionerror-while-creating-track-in-rally-with-docker-image/272448?u=akm