我正试图使用Rally文档页面中的说明从现有的Elasticsearch集群创建一个自定义轨道。
我以Docker Image的身份运行Rally。我正在运行elasticsearch:7.12.0以及同一主机中的docker映像。docker容器正在运行,可以使用基本的auth访问主机。
$ 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选项执行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的连接。我正在传递凭据--客户端选项,但这些选项似乎没有被选中。
不确定,我在这里做错了什么!任何建议都将不胜感激!
感谢Elastic团队在他们的官方讨论频道上回答了这个问题
该设置需要配置一个docker网络,并在Elasticsearch和Rally容器之间共享,以便它们进行通信。
我们在这里没有说明您的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