【问题标题】:Can't get the list of indexes of aws elasticsearch无法获取aws elasticsearch的索引列表
【发布时间】:2018-12-10 18:26:42
【问题描述】:

我有这个 python 脚本:

from requests_aws4auth import AWS4Auth
from elasticsearch import Elasticsearch, RequestsHttpConnection

session = boto3.session.Session()
credentials = session.get_credentials()
awsauth = AWS4Auth(credentials.access_key,
         credentials.secret_key,
         session.region_name, 'es',
         session_token=credentials.token)



es_client = Elasticsearch(
                        "vpc-mydomain-elasticsearch-xxxxxxxxx.region.es.amazonaws.com:9200",
                        http_auth=awsauth,
                        use_ssl=False,
                        verify_certs=False,
                        connection_class=RequestsHttpConnection)

print(es_client.info())

当我运行脚本时出现此错误:

    raise ConnectionTimeout('TIMEOUT', str(e), e)
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeout(HTTPConnectionPool(host='10.0.2.2', port=3128): Read timed out. (read timeout=10))

集群的安全组为 0.0.0.0/0 开放了 9200 端口。 (10.0.2.2是我的vagrant机器的ip,3128端口是cntlm的监听端口) 如何获得这项工作?

编辑

我也试过了,但是没用:

 curl -XGET https://vpc-mydomain-elasticsearch-xxxxxxxxx.region.es.amazonaws.com:9200/_cat/indices?v
curl: (56) Received HTTP code 403 from proxy after CONNECT

【问题讨论】:

  • 这些host='10.0.2.2', port=3128是什么?您似乎收到此 ip 和端口的错误。
  • 10.0.2.2是我的vagrant机器的ip,3128端口是cntlm的代理端口

标签: python elasticsearch indexing


【解决方案1】:

尝试以下解决方案:

  • 将默认超时 10 秒更改为 request_timeout=n,其中 n 可以是大于 10 的数字,理想情况下为 30。如果错误仍然存​​在,请增加。
  • 检查您的 config/elasticsearch.yml 以确保 http.proxy 变量指向正确的地址。
  • 尝试将端口从 9200 更改为 443。
  • 将 use_ssl 更改为 True。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2016-01-11
    • 2019-05-24
    • 2020-12-29
    • 2015-11-02
    • 2014-06-07
    • 2023-02-26
    • 1970-01-01
    • 1970-01-01
    • 2018-10-01
    相关资源
    最近更新 更多