エロサイトの作り方

2013年11月から勉強しながらエロサイトを作っています。

再びRiver out of sync with oplog.rs collection

追記:本エラーが何度も出てきて四苦八苦した上での結論としては、 MongoDB River Pluginサイトに記載のバージョン(River Plugin 2.0.0、ElasticSearch 1.0.0、MongoDB 2.4.9)に合わせないと安定動作しないということが分かりました。マイナーバージョン含めて上のバージョンのものを使うのはおすすめしません。

前回mongorestoreをしたら出たわけですが、今回はいつの間にかに発生するようになっていた。

[2014-06-22 00:40:06,690][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] Starting river mongodb
[2014-06-22 00:40:07,354][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] MongoDB River Plugin - version[2.0.0] - hash[a0c23f1] - time[2014-02-23T20:40:05Z]
[2014-06-22 00:40:07,354][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] starting mongodb stream. options: secondaryreadpreference [false], drop_collection [false], include_collection [], throttlesize [5000], gridfs [false], filter [null], db [test], collection [pages], script [null], indexing to [test]/[pages]
[2014-06-22 00:40:07,910][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] MongoDB version - 2.4.10
[2014-06-22 00:40:08,120][WARN ][org.elasticsearch.river.mongodb.Slurper] Exception in slurper
org.elasticsearch.river.mongodb.Slurper$SlurperException: River out of sync with oplog.rs collection
    at org.elasticsearch.river.mongodb.Slurper.isRiverStale(Slurper.java:618)
    at org.elasticsearch.river.mongodb.Slurper.oplogCursor(Slurper.java:603)
    at org.elasticsearch.river.mongodb.Slurper.run(Slurper.java:119)
    at java.lang.Thread.run(Thread.java:722)

もう、何なのか。

調べる

SlurperException · Issue #233 · richardwilly98/elasticsearch-river-mongodb · GitHub

When the river is out of sync with MongoDB the only option is to reindex all data. So you will need to:

  • Delete the index
  • Delete the river
  • Recreate the river.

この手順をすればいいらしい。しかし、具体的なAPIコールはどうすれば?

Delete the index

$ curl -XDELETE 'http://localhost:9200/test'

index名はtestで作ったので、たぶんこれで消える。

Delete the river

$ curl -XDELETE 'http://localhost:9200/_river'

Riverは_riverでいいのかな?

Recreate the river.

$ elasticsearch

再作成ってどうやるんだと思いつつElasticsearchを再起動させたら、勝手に作られたみたい。

エラーが消えた!

あとは、インデックスを作ってあげれば動くはず。