python-3.x - Elasticsearch 嗅探失败

标签 python-3.x elasticsearch elasticsearch-py

我正在使用 flex 搜索python客户端。当我在客户端中传递嗅探参数时,它将为后续调用返回ConnectionRefused错误。奇怪的是它从本地主机调用get all nodes,我认为这可能是问题。请让我知道我在想什么?

码:

elastic_search_client = elasticsearch.Elasticsearch(['host1:port', 'host2:port'],
                                                    sniff_on_start=True,
                                                    sniff_on_connection_fail=True,
                                                    sniffer_timeout=60)

堆栈跟踪:
  GET http://127.0.0.1:9200/ [status:N/A request:0.001s] Traceback (most recent call last):   File "/env/lib/python3.7/site-packages/urllib3/connection.py", line 160, in
_new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw   File "/env/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err   File "/env/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/env/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 229, in perform_request
    method, url, body, retries=Retry(False), headers=request_headers, **kw   File "/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]   File "/env/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)   File "/env/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value   File "/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,   File "/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1298, in
_send_request
    self.endheaders(body, encode_chunked=encode_chunked)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1026, in
_send_output
    self.send(msg)   File "/opt/python3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()   File "/env/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()   File "/env/lib/python3.7/site-packages/urllib3/connection.py", line 172, in
_new_conn
    self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x3e6d58342c10>: Failed to establish a new connection: [Errno 111] Connection refused

最佳答案

在elasticsearch.yml中,需要将network.host值更改为节点的ip而不是localhost的ip

关于python-3.x - Elasticsearch 嗅探失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61904758/

相关文章:

elasticsearch - Logstash:TypeError:没有将nil隐式转换为字符串

python - Elasticsearch HTTP API 或 python API

python - O(logN) 中的排序列表计数元素

python - python 上的 tic tac toe

python - 计算从给定日期算起固定天数的日期

python - 通过 ElasticSearch DSL python 包装器创建索引时如何在索引级别设置 ignore_malformed?

elasticsearch - 使用 Elasticsearch py批量更新无类型

python - QTableWidget 当前选择改变信号

ruby-on-rails - 无法打开与本地主机 :9200 - Rails on Docker 的 TCP 连接

elasticsearch - Elasticsearch-匹配嵌套对象数组中的所有子项