我遇到了一个奇怪的问题,使用 Django Haystack ElasticSearch ,所以我无法rebuild_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

最佳答案

我认为您的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

关于django - Elasticsearch端口9300 Django,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47560039/

10-09 17:11