ElasticSearch索引随机变为空

时间:2014-11-21 16:55:04

标签: ruby-on-rails amazon-ec2 elasticsearch searchkick

ElasticSearch索引随机变为空,但大多数情况下,它是在部署使用Rails构建的应用程序之后发生的。

这里有一些关于ElastiSearch的信息:

curl -XGET 'http://localhost:9200/_nodes?pretty'

curl -XGET 'http://localhost:9200/_cluster/health?pretty'

curl 'localhost:9200/_cat/indices?v'

/var/log/elasticsearch/elasticsearch.log中的重复堆栈跟踪:

[2014-11-21 16:46:05,204][WARN ][cluster.service          ] [Joe Cartelli] failed to reconnect to node [Joe Cartelli][AvwiuMNRRUywfTyii7gI0A][ip-172-31-19-137][inet[/172.31.19.137:9300]]
org.elasticsearch.transport.ConnectTransportException: [Joe Cartelli][inet[/172.31.19.137:9300]] connect_timeout[30s]
    at org.elasticsearch.transport.netty.NettyTransport.connectToChannels(NettyTransport.java:727)
    at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:656)
    at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:624)
    at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:146)
    at org.elasticsearch.cluster.service.InternalClusterService$ReconnectToNodes.run(InternalClusterService.java:518)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.net.ConnectException: Connection refused: /172.31.19.137:9300
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    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:318)
    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)
    ... 3 more

Obs:172.31.19.137 IP地址是AWS上EC2实例的私有IP。

修改

错误仍然发生,我有关于这个问题的新信息。

'数据消失'后,我查看了elasticsearch.log并且多次打印Stack Trace。我不知道这个错误是在“数据消失”之前还是之后发生的。请注意,索引名称为products_production_20141130122307375

运行命令列出所有Elasticsearch索引curl 'localhost:9200/_cat/indices?v',打印产品索引但编号不同:products_production_20141XXXXXXXXXX(我没记下确切的数字)。

那么,为什么索引的名称不相同?

由于一些奇怪的原因,Rails / Searchkick可能会重新创建索引并丢失数据吗?

编辑2

ElasticSearch记录此问题后会出现此问题:

[2014-12-02 00:47:10,698][INFO ][cluster.metadata         ] [Tyr] [products_production_20141202004040313] update_mapping [product] (dynamic)
[2014-12-02 00:58:02,173][INFO ][cluster.metadata         ] [Tyr] [products_production_20141202005801257] creating index, cause [api], shards [5]/[1], mappings [_default_]
[2014-12-02 00:58:46,064][INFO ][cluster.metadata         ] [Tyr] [products_production_20141202005801257] update_mapping [product] (dynamic)
[2014-12-02 00:58:48,371][INFO ][cluster.metadata         ] [Tyr] [products_production_20141202004040313] deleting index

看起来searchkick重新创建索引并丢失旧索引的产品。

1 个答案:

答案 0 :(得分:3)

也许这个问题可能与您的问题有关:

https://github.com/ankane/searchkick/issues/307