如何在Azure Cosmos DB中克隆/复制数据库 [英] How to clone/copy a database in Azure Cosmos DB
问题描述
如何将Azure Cosmos DB中的数据库克隆到在localhost:27001上运行的mongod
?
How do I clone a database in Azure Cosmos DB to a mongod
running on localhost:27001?
我尝试了以下操作,但无法正常工作:
I've tried the following, but I can't get it working:
db.cloneDatabase("mycosmosdb:mypassword@username.documents.azure.com:10255/MyDatabase?ssl=true&replicaSet=globaldb")
在运行mongod
的本地计算机上运行命令时,这将返回以下内容:
This returns the following when running the command from my local machine where mongod
is running :
{
"clonedColls" : [ ],
"ok" : 0,
"errmsg" : "connect failed to replica set mycosmosdb:mypassword@username.documents.azure.com:10255/Mydatabase?ssl=true&replicaSet=globaldb:27017",
"code" : 6,
"codeName" : "HostUnreachable"
}
尝试此变体也会失败:
db.copyDatabase("NameOfAzureDB", "NameOfLocalDB", "username.documents.azure.com:10255", "username", "password")
{
"ok" : 0,
"errmsg" : "couldn't connect to server username.documents.azure.com:27017, connection attempt failed"
}
Cosmos DB不支持
推荐答案
cloneDatabase,因为它包装的克隆命令不够灵活,无法允许SSL连接以及副本集的名称.它仅接受主机名和端口号,不接受其他任何内容,因此不支持该问题中使用的连接字符串(也没有"mycosmosdb"之类的绰号).
cloneDatabase is not supported on Cosmos DB as clone command that it wraps around is not flexible enough to allow SSL connection and the name of the replica set. It only accepts the hostname and port number and nothing else, so the connection string used in the question is not supported (and there's no such moniker as "mycosmosdb" either).
这篇关于如何在Azure Cosmos DB中克隆/复制数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!