AWS elasticsearch インスタンスを 1 つ作成しました。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',)))
このエラーを解決するにはどうすればよいですか?
ありがとう
ベストアンサー1
Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
https://
elasticsearch クライアントがホスト名を解決できないことを示しているようです。ホストに指定されたプロトコルが含まれていることが原因である可能性があります。
その行を に変更して、host = 'kbckjsdkcdn.us-east-1.es.amazonaws.com'
動作するかどうかを確認してください。また、そこにあるサンプルコメントは、プロトコルをホスト変数に含めるべきではないことを示しているようです。