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
重新创建索引并丢失旧索引的产品。