1

When I create two databases 'foo' and 'bar' and then create a document

{
    "_id": "whatever",
    "source": "foo",
    "target": "bar"
}

in the _replicator database this should initiate the syncing from 'foo' to 'bar'. However, I am getting this error in the logs:

Could not open file ./data/foo.couch: no such file or directory
open_result error {not_found,no_db_file} for foo
Replication <hash> failed to start "foo" -> "bar"

The same works if I use the full url of the source/target databases (e.g. http://localhost:5984/foo), but coupling my replication documents to the (current) url of the CouchDB instance seems very wrong and unnecessary, I would have to update them all if I would change the port etc.. The docs also state that for source/target the database name OR url can be used.

Is it not possible to use the (relative) database names and why do I get the above error if I just use the name ?

I am using CouchDB 2.1.1 under Ubuntu 16.04.

abc123
  • 11
  • 1

1 Answers1

2

In the CouchDB 1.x days, you could specify replications with just the local names of the source/target database names. In the clustered world of CouchDB 2.0, the _replicator database needs a full URL in the source and target, even if you are replicating from local-->local.

Insert a document into the _replicator of this form:

{
    "_id": "whatever",
    "source": "http://U:P@localhost:5984/source",
    "target": "http://U:P@localhost:5984/target"
}

Documentation here

Glynn Bird
  • 5,507
  • 2
  • 12
  • 21
  • Ok, I think I will use a special admin user, for which I won't change the credentials and won't change the port either, then it should be fine :) I think in future it might be useful if the syntax allowed to refer to databases on the same instance just by name if that's possible. – abc123 Jul 09 '18 at 17:10
  • 1
    Also I think the [docs](http://docs.couchdb.org/en/latest/json-structure.html#replication-settings) should be adjusted, because they say the source/target could also be the database name (not url) – abc123 Jul 09 '18 at 17:12