我已经启动了ElasticSearch服务,并且在我执行ps aux --sort -rss
时可以看到它正在运行。但是,当我使用Python3.4 manage.py loaddata backup.json
更新我的数据库时,Haystack和ElasticSearch会从以下开始引发连接错误:
GET http://www.example.com:9200/haystack/_mapping [status:N/A request:0.173s]
Traceback (most recent call last):
File "/home/myuser/lib/python3.4/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/home/myuser/lib/python3.4/urllib3/connectionpool.py", line 349, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.4/http/client.py", line 1090, in request
self._send_request(method, url, body, headers)
File "/usr/local/lib/python3.4/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/usr/local/lib/python3.4/http/client.py", line 1086, in endheaders
self._send_output(message_body)
File "/usr/local/lib/python3.4/http/client.py", line 924, in _send_output
self.send(msg)
File "/usr/local/lib/python3.4/http/client.py", line 859, in send
self.connect()
File "/home/myuser/lib/python3.4/urllib3/connection.py", line 155, in connect
conn = self._new_conn()
File "/home/myuser/lib/python3.4/urllib3/connection.py", line 134, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/myuser/lib/python3.4/urllib3/util/connection.py", line 88, in create_connection
raise err
File "/home/myuser/lib/python3.4/urllib3/util/connection.py", line 78, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
是什么导致这个?我在某处读到了相互矛盾的Java版本可能导致这种情况,并且我确实有多个Java版本,但是当我运行java -version
和javac -version
时,它们都会根据需要返回1.8.0_45。
settings.py
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://www.example.com:9200/',
'INDEX_NAME': 'haystack',
},
}
答案 0 :(得分:0)
看起来Java Elasticsearch守护程序不活动。您可以通过以下方式查看:
nmap localhost -p 9200
端口状态必须为open
。如果它是closed
,则您的Java Elasticsearch守护程序现在不起作用。您可以在/var/log/elasticsearch
中查看日志中的错误。
此时(2016年11月)在Ubuntu 16.04服务器上运行Elasticsearch守护进程,您需要:openjdk-8-jre
和elasticsearch v.2.3.1
守护进程。使用openjdk-9-jre
Elasticeasrch守护程序将无法启动,Elasticsearch守护程序版本> = 5也将无法启动。