How to execute mongo cloneCollection command to copy a collection to a remote server

I would like to copy a collection from one database to an instance on another server. From https://stackoverflow.com/a/3159605/212660/ ... questions , I understand that the correct way to do this is with this command:

{ cloneCollection: "<collection>", from: "<hostname>", query: { <query> } }

via http://docs.mongodb.org/manual/reference/command/cloneCollection/

However, I do not understand where should I enter this command? This is not accepted as ...

$ mongod { cloneCollection: "remote", from: "ec2-whatever-amazon.com"}

How to copy a remote collection from db.remote.collnameto db.local.collnameusing this cloneCollection syntax via the command line?

+4
source share
1 answer

MongoDB db.runCommand() mongo. . http://docs.mongodb.org/manual/tutorial/use-database-commands/.

- ( ):

$ mongo
 > db.runCommand({ isMaster: 1})
 {
    "ismaster" : true,
    "maxBsonObjectSize" : 16777216,
    "localTime" : ISODate("2014-02-18T22:30:04.417Z"),
    "ok" : 1
 }
 > 
+5

Source: https://habr.com/ru/post/1527595/


All Articles