Mongo DB Data Migration - mongodb

We have Sharded Mongo Cluster.
However some documents are sharded and others are unsharded.
We are planning to migrate these databases to new cluster.
Please update if there is any process or steps to migrate the data from one sharded cluster to the other.
We have two secondaries and 1 primary for each shard,MongoS,3 Config Servers,2 Arbitors.
I understood that copydb can not be used on the sharded collection.
Please suggest if there is any other way.

Related

Does Mongo DB write everyting into oplog

In Oracle developers can run sqls in nologging mode. Is it possible on Mongo DB or Mongo DB writes all operations into the oplog(operations log)?
A standalone server (not part of replica set or sharded cluster) does not employ the oplog.

Import documents to a particular/targeted shard in Mongo Shard Cluster

I'm new to MongoDB, however I have setup a shard cluster with 3 replica sets. Each replica set has 2 mongod instances. I have a separate config server and 1 mongos instance.
I wanted to try whether it's possible to import documents to a particular/targeted shard, when the collection is not shard enabled. (As far as I know, we can't control in which shard the collection will get saved when importing is done via mongos instance)
Hence, I imported the documents using below command, and it was successful (followed this);
mongoimport --db NormalTestDB --collection TestDams --host <replSetName>/<hostname1><:port>,<hostname2><:port> --jsonArray --file “<path_to_json>”
(I used a particular replica set name in <replSetName>)
Now when I try this simple query db.TestDams.find().count() in mongos shell (by connecting to NormalTestDB), it returns 0. But if I try the same query by directly connecting to the Primary of the relevant replicaSet, I get 14603.
Is there any way that I could sync? or is there a way to use mongoimport targeting a particular shard??
(Aside: You should generally have 3 nodes in a replica set rather than 2.)
When you enable sharding on a database you can specify the primary shard. Unsharded collections will be stored on that shard. So, you can define one database per shard with each configured to have a distinct shard as the primary shard.
Alternatively if you set up zones you can specify which values of shard keys are to be stored on each shard. Then by inserting appropriate values you'd have the data stored on the shards you want.
You should be performing all operations on your sharded cluster through one of the mongos nodes, not like you have done writing directly to shard mongods.

How can I convert a Shard mongo cluster to a Replica Set mongo cluster? real-time migrations

I have a shard mongo cluster(shard node has no replica set), and some applications are using it, I want to real-time migrations to a replica set mongo cluster. Does anyone know how to do it? Thanks

How i can backup mongodb shard no downtime?

I want to backup data in mongo shard. How i can backup no downtime because they're in production. I can't do from mongodb official manual.
Back Up a Sharded Cluster with Database Dumps

How to create mongodb oplog for database?

Recently I purchased cluster account from MongoDB atlas. I had checked UI and MongoDB documentation but don't know create oplog db. And how to create a connection string for oplog?
Oplog collection is automatically created and maintained by mongoDB and is created under the local database. It is used internally by mongoDB to maintain the various nodes in sync in a replica set. Assume you have a three node replica set, one primary and two secondary. When a write operation happens in the primary, the event is logged in oplog collection and is used internally to replicate the same change in the secondary nodes.
So to use oplog you will need a MongoDB server configured as a replica set. Standalone instances of mongoDB do not have oplog as there is no need for replication in this case.
However, you may start a standalone instance as a replica set by using the command,
Start Mongo server in replica mode.
mongod --dbPath <path_to_data_file> --replSet rs0
Initiate the replica set.(Execute from mongo shell)
rs.initiate();
oplog is a mongodb replication feature. If you have choose replication cluster, you have it in the database named "local". See the collections in "local" database.