AWS 弹性搜索错误“[Errno 8] 节点名称或服务名称已提供,或未知。”
AWS elastic search error "[Errno 8] nodename nor servname provided, or not known."
我创建了一个 AWS elasticsearch 实例。我想使用 python 脚本访问它。我指定了我的 AWS 配置(访问密钥、密钥、区域)。我正在使用以下代码访问 AWS ES 实例:
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
AWS_ACCESS_KEY = '**************'
AWS_SECRET_KEY = '*****************'
region = 'us-east-1'
service = 'es'
awsauth = AWS4Auth(AWS_ACCESS_KEY, AWS_SECRET_KEY, region, service)
host = 'https://kbckjsdkcdn.us-east-1.es.amazonaws.com' # For example, my-test-domain.us-east-1.es.amazonaws.com
es = Elasticsearch(
hosts = [{'host': host, 'port': 443}],
http_auth = awsauth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection
)
print es.info()
当我运行上面的代码时,出现以下错误:
elasticsearch.exceptions.ConnectionError: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))) caused by: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)))
我该如何解决这个错误?
谢谢
Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
似乎表明 elasticsearch 客户端无法解析主机名。这可能是因为您包含了主机中指定的协议 https://
。
将该行更改为 host = 'kbckjsdkcdn.us-east-1.es.amazonaws.com'
以查看它是否有效。另外,您在那里的示例评论似乎表明该协议不应包含在主机变量中。
我创建了一个 AWS elasticsearch 实例。我想使用 python 脚本访问它。我指定了我的 AWS 配置(访问密钥、密钥、区域)。我正在使用以下代码访问 AWS ES 实例:
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
AWS_ACCESS_KEY = '**************'
AWS_SECRET_KEY = '*****************'
region = 'us-east-1'
service = 'es'
awsauth = AWS4Auth(AWS_ACCESS_KEY, AWS_SECRET_KEY, region, service)
host = 'https://kbckjsdkcdn.us-east-1.es.amazonaws.com' # For example, my-test-domain.us-east-1.es.amazonaws.com
es = Elasticsearch(
hosts = [{'host': host, 'port': 443}],
http_auth = awsauth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection
)
print es.info()
当我运行上面的代码时,出现以下错误:
elasticsearch.exceptions.ConnectionError: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))) caused by: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)))
我该如何解决这个错误?
谢谢
Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
似乎表明 elasticsearch 客户端无法解析主机名。这可能是因为您包含了主机中指定的协议 https://
。
将该行更改为 host = 'kbckjsdkcdn.us-east-1.es.amazonaws.com'
以查看它是否有效。另外,您在那里的示例评论似乎表明该协议不应包含在主机变量中。