0

我在註冊存儲庫以進行彈性搜索時遇到問題。 這裏是我用來做鏈接:無法註冊s3存儲庫以進行彈性搜索

http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-managedomains-snapshots.html#es-managedomains-snapshot-registerdirectory

而且在該鏈接中提到我複製下面的代碼並運行它:

from boto.connection import AWSAuthConnection 

類ESConnection(AWSAuthConnection):

def __init__(self, region, **kwargs): 
    super(ESConnection, self).__init__(**kwargs) 
    self._set_auth_region_name(region) 
    self._set_auth_service_name("es") 

def _required_auth_capability(self): 
    return ['hmac-v4'] 

if __name__ == "__main__": 

client = ESConnection(
     region='us-east-1', 
     host='search-weblogs-etrt4mbbu254nsfupy6oiytuz4.us-east-1.es.example.com', 
     aws_access_key_id='my-access-key-id', 
     aws_secret_access_key='my-access-key', is_secure=False) 

print 'Registering Snapshot Repository' 
resp = client.make_request(method='POST', 
     path='/_snapshot/weblogs-index-backups', 
     data='{"type": "s3","settings": { "bucket": "es-index-backups","region": "us-east-1","role_arn": "arn:aws:iam::123456789012:role/TheServiceRole"}}') 
body = resp.read() 
print body 

我也適應安全和帳戶ID和...我的。 當我運行它,我得到以下錯誤:

Traceback (most recent call last): 
File "C:/Users/hminaee/Documents/bni-tj-cm-Copy-Sep/test-image-repo.py", 
line 24, in <module> 
data='{"type": "s3","settings": { "bucket": "mybucket","region": "us- 
east-1","role_arn": "arn:aws:s3:::mybucket"}}') 
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site- 
packages\boto\connection.py", line 1071, in make_request 
retry_handler=retry_handler) 
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site- 
packages\boto\connection.py", line 1030, in _mexe 
raise ex 
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site- 
packages\boto\connection.py", line 943, in _mexe 
request.body, request.headers) 
File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\http\client.py", 
line 1239, in request 
self._send_request(method, url, body, headers, encode_chunked) 
File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\http\client.py", 
line 1285, in _send_request 
self.endheaders(body, encode_chunked=encode_chunked) 
File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\http\client.py", 
line 1234, in endheaders 
self._send_output(message_body, encode_chunked=encode_chunked) 
File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\http\client.py", 
line 1026, in _send_output 
self.send(msg) 
File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\http\client.py", 
line 964, in send 
self.connect() 
File 
"C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\http\client.py", 
line 936, in connect 
(self.host,self.port), self.timeout, self.source_address) 
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\socket.py", 
line 
704, in create_connection 
for res in getaddrinfo(host, port, 0, SOCK_STREAM): 
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\socket.py", 
line 
743, in getaddrinfo 
for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 
socket.gaierror: [Errno 11004] getaddrinfo failed 

什麼是我的問題?有沒有更好的教程或我可以做到的方式?

回答

1

search-weblogs-etrt4mbbu254nsfupy6oiytuz4.us-east-1.es.example.com不存在。它有example.com在裏面。那個是從哪裏來的?您應該使用您的實際搜索域。

+0

其實在我的例子中,我用我的彈性搜索的端點與此類似:https://search-test-tj-xxxxxxxxxxx.us-east-1.es.amazonaws.com –

+0

所以url是vaild –

+0

你100%確定它是有效的嗎?因爲錯誤表明它不是。 'getaddrinfo failed'意味着某些主機名無法解析,這是您在您提供的代碼示例中手動指定的唯一主機名。 – kichik