开发者

"Error starting replication" in couchdb

I am creating a "pull" replicator document in couchdb 1.1.0:

curl -X PUT http://admin:pass@localhost:5984/_replicator/maintenance -d '
{
    "_id": "maintenance",
    "source":  "http://other.host:5984/maintenance",
    "target":  "maintenance",
    "create_target":  true
}'

Now I check the replication state:

curl -X GET http://admin:pass@localhost:5984/_replicator/maintenance
{"_id":"maintenance","_rev":"2-0f25f80a2726640944d527d6035e5b80","source":"http://other.host:5984/","tar开发者_C百科get":"maintenance","create_target":true,"_replication_state":"error","_replication_state_time":"2011-09-06T02:35:10+02:00","_replication_id":"354746bf47831195261bf54f3cb6136b"}

Something is going wrong, but I do not know what. I have even created the database manually, but it is still not working. Any ideas on where the problem could be?


It turns out I was using the wrong url to start the replication. Instead of

curl -X PUT http://admin:pass@localhost:5984/_replicator/maintenance

I must do:

curl -X POST http://admin:pass@localhost:5984/_replicate -H ...

Now the replication starts as expected. It can even be triggered with create_target and continuous, and it works fine.

I still have some problems though: how can I list the active replications? They are not listed in localhost:5984/_replicator and the url localhost:5984/_replicate only acepts POST requests. How can I cancel a continuous replication?

And finally: what is the purpose of having two different URLs, one localhost:5984/_replicate and one localhost:5984/_replicator?


The source attribute is wrong, you have to add the remote database:

"source":  "http://other.host:5984/maintenance"

should work!

Cheers, Bernhard


I suspect you need to authenticate at other.host (it may have require_valid_user=true, for example) so;

"source":"http://user:pass@other.host:5984/maintenance"

You will likely wish to lock down access to the _replicator db as any reader of the database can see that password (use the _security document to lock it down).

Tightening this up is an active topic of discussion for future releases of CouchDB.


_replicator is the new format used to remember your replications after a CouchDB restart. If using this format, you can cancel replications by simply deleting the replication document.

https://gist.github.com/832610


When I encountered this error:

[Mon, 12 Sep 2011 16:45:05 GMT] [error] [<0.4323.3>] Error starting replication '045020f93f9da91e1e6b609754b32a15+create_target' (document 'maintenance'): {unauthorized, <<"unauthorized to access database maintenance">>}. Retrying in 160 seconds

The actual issue is I was specifying create_target: true in the JSON, yet the database already existed. I believe previously create_target was safe to use if the target already existed, but not in the _replicator/ model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜