问题
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")
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"
}
Trying this variant also fails:
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"
}
回答1:
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).
回答2:
With the new Cosmic Clone tool, you can
- To clone collections for any environments
- Create collections with similar settings(indexes, partition, TTL etc)
- Anonymize data through scrubbing or shuffling of sensitive data in documents.
Read my blog on the same.
来源:https://stackoverflow.com/questions/49155167/how-to-clone-copy-a-database-in-azure-cosmos-db