我正面临一个奇怪的问题,使用 Django Haystack 和 ElasticSearch ,所以我无法重建_index。
ElasticSearch正在机器上正常运行:
$ curl -X GET 'http://localhost:9200'
{
"status" : 200,
"name" : "Ziggy Pig",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.7.2",
"build_hash" : "e43676b1385b8125d647f593f7202acbd816e8ec",
"build_timestamp" : "2015-09-14T09:49:53Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
但这是ElasticSearch的日志:
[2017-11-29 18:25:22,723][INFO ][node] [Ziggy Pig] initialized
[2017-11-29 18:25:22,724][INFO ][node] [Ziggy Pig] starting ...
[2017-11-29 18:25:22,913][INFO ][transport] [Ziggy Pig] bound_address
{inet[/127.0.0.1:9300]}, publish_address {inet[/10.142.0.2:9300]}
[2017-11-29 18:25:22,937][INFO ][discovery] [Ziggy Pig] .
elasticsearch/HWEvbIkAR3mFwcGeHIa7Cg
[2017-11-29 18:25:26,710][INFO ][cluster.service] [Ziggy Pig]
new_master [Ziggy Pig][HWEvbIkAR3mFwcGeHIa7Cg][stagelighted]
[inet[/10.142.0.2:9300]], reason: zen-disco-join(elected_as_master)
[2017-11-29 18:25:26,734][INFO ][http] [Ziggy Pig] bound_address
{inet[/127.0.0.1:9200]}, publish_address {inet[/10.142.0.2:9200]}
[2017-11-29 18:25:26,734][INFO ][node] [Ziggy Pig] started
[2017-11-29 18:25:26,762][INFO ][gateway] [Ziggy Pig] recovered [1]
indices into cluster_state
[2017-11-29 18:26:22,946][WARN ][cluster.service] [Ziggy Pig] failed to
reconnect to node [Ziggy Pig][HWEvbIkAR3mFwcGeHIa7Cg]
[stagelighted][inet[/10.142.0.2:9300]]
org.elasticsearch.transport.ConnectTransportException: [Ziggy Pig][inet[/10.142.0.2:9300]] connect_timeout[30s]
at org.elasticsearch.transport.netty.NettyTransport.connectToChannels(NettyTransport.java:825)
at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:758)
at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:731)
at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:216)
at org.elasticsearch.cluster.service.InternalClusterService$ReconnectToNodes.run(InternalClusterService.java:584)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused: /10.142.0.2:9300
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
我使用此tutorial
安装了JAVA和Elastisearch我的应用在Google Compute Engine中运行
如果有人可以帮助我。
我的设置:
ELASTICSEARCH_INDEX_SETTINGS = {
'settings': {
"analysis": {
"analyzer": {
"synonym_analyzer" : {
"type": "custom",
"tokenizer" : "standard",
"filter" : ["synonym"]
},
"ngram_analyzer": {
"type": "custom",
"tokenizer": "lowercase",
"filter": ["haystack_ngram", "synonym"]
},
"edgengram_analyzer": {
"type": "custom",
"tokenizer": "lowercase",
"filter": ["haystack_edgengram"]
}
},
"tokenizer": {
"haystack_ngram_tokenizer": {
"type": "nGram",
"min_gram": 3,
"max_gram": 15,
},
"haystack_edgengram_tokenizer": {
"type": "edgeNGram",
"min_gram": 2,
"max_gram": 15,
"side": "front"
}
},
"filter": {
"haystack_ngram": {
"type": "nGram",
"min_gram": 3,
"max_gram": 15
},
"haystack_edgengram": {
"type": "edgeNGram",
"min_gram": 2,
"max_gram": 15
},
"synonym" : {
"type" : "synonym",
"ignore_case": "true",
"synonyms_path" : "synonyms.txt"
}
}
}
}
}
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'elasticstack.backends.ConfigurableElasticSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 100
答案 0 :(得分:1)
我认为你的settings.py文件中有拼写错误:当端口9200上运行elasticsearch时,你正试图连接到端口9300:
Caused by: java.net.ConnectException: Connection refused: /10.142.0.2:9300
如果没有解决问题,您可以发布settings.py文件的相关部分吗?
修改强> 通过一些相关的帖子,似乎节点通过端口9300和端口9200相互通信。您的ping是否也在端口9300上工作?如果没有,那也可能需要打开。
可能相关:https://discuss.elastic.co/t/elasticsearch-port-9200-or-9300/72080