簡體   English   中英

如何插入托管在Google Clouds上的Elasticsearch(bitnami)

[英]How to insert into Elasticsearch hosted on Google Clouds (bitnami)

抱歉,我對Google Clouds和Elasticsearch還是陌生的,但是我沒有找到任何相關文檔。 基本上,我們只是使用Bitnami在Google Clouds上部署了Elasticsearch節點。 但是我無法用Python連接到它。 我為下面的代碼嘗試了很多不同的公式(主機是Google雲節點的外部IP,用戶名和密碼是Bitnami要求連接到我的應用程序的那些)。 有人可以讓我知道它的來源和正確的語法嗎?

from elasticsearch import Elasticsearch

connection_parameters = [{'host': 'http://104.196.x.x', 'port': 80}]
    es = Elasticsearch(connection_parameters, http_auth=('user', 'password'))
print(es.info())

這是錯誤:

elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f72e757a090>: Failed to establish a new connection: [Errno -2] Name or service not known) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f72e757a090>: Failed to establish a new connection: [Errno -2] Name or service not known)

非常感謝您能幫助我!

看來問題出在您在Google Compute Engine上的防火牆規則。 您需要明確允許從Google外部到您的ES節點的流量。

您可以使用Google Cloud SDK [1]創建新的防火牆規則:

gcloud compute firewall-rules create allow-traffic-to-es --allow tcp:80,tcp:443 --source-ranges 0.0.0.0/0 --target-tags es

請注意,此規則將允許從(0.0.0.0/0)到您的ElasticSearch集群的流量,因此您可以實施更嚴格的CIDR范圍。

[1] Google Cloud SDK

我認為您應該像這樣排除連接字符串的協議部分:

connection_parameters = [{'host': '104.196.x.x', 'port': 80}]

或者這樣:

es = Elasticsearch(['http://user:f00b4r42@104.196.xx:80/elasticsearch'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM