top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

If you wanted to copy over the mongo database using mongos oplog, how would you do it?

0 votes
263 views

If you wanted to copy over the mongo database using mongos oplog, how would you do it? Suppose we start copying the database at time T and we finish the copying at time U. We have to read from the oplog from time T onward and apply oplog changes (which also may have been applied between time T and U). Do the oplog transactions have timestamps in them so we can discard records before time T? Are the operations idempotent if we apply them twice (because we are applying an operation already executed between time T and U)? Guess I am confused how to get the initial data before reading from the oplog to continue the real time updates.

posted Mar 23, 2016 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

I am in the process of migrating a replica set from a data center to AWS, but when I checked the settings, I noticed that the Sharding is not enabled, yet they are using 3 MongoS / Routers and 3 MongoC / Config servers - So since Sharding is not used in the current system, would it be safe to migrate the replica sets and not use MonogoS nor MongoC ? Can the users connect directly to Mongo database replica set without using MongoS ?
Or should I use at least 1 MongoS and 1 MongoC config server ?

+1 vote

I am new to Node and Mongo, I was trying to connect to a mongo database in one file and export the database handler to many other files, so that I need not to connect to the database in all files which need a connection to it. Here is how I attempted to do it

// db.js
var client = require(mongodb).MongoClient
var assert = require(assert)
var url = mongodb://localhost:27017/test

client.connect(url, (err, db) => {
  assert.equal(err, null)
  module.exports = db
})

After exporting the db handler, I tried to access methods on it in another file as follows

var db = require(./db)
console.log(db.collection(col))

but it throws a TypeError, saying that db.collection is not a function. How can I access the methods on db handler in other files?

...