我正在尝试ping我的Elasticsearch实例(通过Bonsai an Heroku插件部署)。我遵循了他们的指导原则,并尝试在我的计算机上执行以下代码:
from elasticsearch import Elasticsearch
from settings import BONSAI_URL
import re, logging
# Log transport details (optional):
logging.basicConfig(level=logging.INFO)
# Parse the auth and host from env:
bonsai = BONSAI_URL
print(bonsai)
auth = re.search('https\:\/\/(.*)\@', bonsai).group(1).split(':')
host = bonsai.replace('https://%s:%s@' % (auth[0], auth[1]), '')
# Connect to cluster over SSL using auth for best security:
es_header = [{
'host': host,
'port': 443,
'use_ssl': True,
'http_auth': (auth[0],auth[1])
}]
# Instantiate the new Elasticsearch connection:
es = Elasticsearch(es_header)
# Verify that Python can talk to Bonsai (optional):
es.ping()
我收到以下错误消息:
^{pr2}$我相信这个错误是由于我没有https证书,所以我使用了HTTP,删除了URL和regex中的s
,并将{
如何将计算机中的数据插入Heroku上的elasticsearch?在
你可能在用Python3。 问题在于您的python版本和urlib的行为方式。在
快速解决办法可以是:
但这条路不安全。一个更明确的解决办法是在要求.txt公司名称:
^{pr2}$输入终端:
在实例化elasticsearch的文件中:
然后启动与您之前启动的代码完全相同的代码,它应该可以工作并将是安全的。在
问题是客户端找不到根证书(这些证书位于运行代码的计算机上)。正如异常所提到的,您应该能够使用},并且它应该在没有问题as described here的情况下运行。在
pip
安装certifi
,然后在脚本中只安装{相关问题 更多 >
编程相关推荐