首页 > 解决方案 > 我可以使用没有 url 的数据库名称在 CouchDB 中开始复制吗?

问题描述

当我创建两个数据库 'foo' 和 'bar' 然后创建一个文档

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

_replicator数据库中,这应该启动从“foo”到“bar”的同步。但是,我在日志中收到此错误:

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"

如果我使用源/目标数据库的完整 url(例如http://localhost:5984/foo),同样的工作,但是将我的复制文档耦合到 CouchDB 实例的(当前)url 似乎非常错误和不必要,如果我愿意,我将不得不全部更新它们更改端口等。文档还指出,对于源/目标,可以使用数据库名称或 url。

是否不能使用(相对)数据库名称,如果我只使用名称,为什么会出现上述错误?

我在 Ubuntu 16.04 下使用 CouchDB 2.1.1。

标签: couchdbreplication

解决方案


在 CouchDB 1.x 时代,您可以仅使用源/目标数据库名称的本地名称来指定复制。在 CouchDB 2.0 的集群世界中,_replicator 数据库需要源和目标中的完整 URL,即使您是从本地复制 -> 本地。

在这个表单的 _replicator 中插入一个文档:

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

文档在这里


推荐阅读