无法将s3存储库注册到aws弹性搜索

时间:2017-11-11 02:42:56

标签: amazon-web-services elasticsearch elasticsearch-plugin elasticsearch-5 amazon-cloudsearch

我在向弹性搜索注册存储库时遇到问题。 这是我用来做的链接:

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 个答案:

答案 0 :(得分:1)

search-weblogs-etrt4mbbu254nsfupy6oiytuz4.us-east-1.es.example.com不存在。它中有example.com个。那个是从哪里来的?您应该使用实际的搜索域。