OpenSearch Docker Image无法建立一个新连接:[ERRNO 111]连接拒绝)
我正在使用Docker Desktop(Windows)中的OpenSearch。
使用docker-compose.yml file- file-
https://opensearch.org/down.org/downloads.html
code-
!pip install opensearch-py
from opensearchpy import OpenSearch
host = 'localhost'
port = 9200
auth = ('admin', 'admin') # For testing only. Don't store credentials in code.
# ca_certs_path = '/full/path/to/root-ca.pem' # Provide a CA bundle if you use intermediate CAs with your root CA.
# Optional client certificates if you don't want to use HTTP basic authentication.
# client_cert_path = '/full/path/to/client.pem'
# client_key_path = '/full/path/to/client-key.pem'
# Create the client with SSL/TLS enabled, but hostname verification disabled.
client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_compress = True, # enables gzip compression for request bodies
http_auth = auth,
# client_cert = client_cert_path,
# client_key = client_key_path,
use_ssl = True,
verify_certs = True,
ssl_assert_hostname = False,
ssl_show_warn = False,
# ca_certs = ca_certs_path
)
# Create an index with non-default settings.
index_name = 'python-test-index'
index_body = {
'settings': {
'index': {
'number_of_shards': 4
}
}
}
response = client.indices.create(index_name, body=index_body)
print('\nCreating index:')
print(response)
error-
---------------------------------------------------------------------------
ConnectionRefusedError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/urllib3/connection.py in _new_conn(self)
158 conn = connection.create_connection(
--> 159 (self._dns_host, self.port), self.timeout, **extra_kw)
160
16 frames
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f1f3be83690>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/opensearchpy/connection/http_urllib3.py in perform_request(self, method, url, params, body, timeout, ignore, headers)
262 if isinstance(e, ReadTimeoutError):
263 raise ConnectionTimeout("TIMEOUT", str(e), e)
--> 264 raise ConnectionError("N/A", str(e), e)
265
266 # raise warnings if any from the 'Warnings' header.
ConnectionError: ConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1f3be83690>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1f3be83690>: Failed to establish a new connection: [Errno 111] Connection refused)
在另一个站点上找到类似的查询 -
在Docker桌面上运行的OpenSearch Instances。
我在互联网上搜索,但没有找到答案,请告诉我。
snap-
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我试图使用Google Colab笔记本电脑连接连接OpenSearch Docker实例。
在Python Virtual Env中运行脚本后,我能够连接Docker实例。
ref link- docker:opensearch拒绝与与示例的连接Docker中的OpenSearch文档
工作代码 -
Issue was I was trying to connect connect opensearch docker instance using google colab notebooks.
After running the script in python virtual env, I am able to connect docker instance.
Ref link- Docker : Opensearch refuses connection with the example in opensearch documentation in docker
Working code-