0

Our's is a small application. Every day we do mongodump and take DB backup to Amazon Glacier. Instead of this I would like to use MongoDB replication that will copy actual database on another different server. So that on failure of main server There will be no actual data loss.

I don't want secondary server to take over automatically which we can handle manually later. But the goal is to have the latest data ready on another server.

0

1 Answer 1

1

You could create a ReplicaSet and configure the second server as delayed hidden member. Could be like this:

rs.initiate(
   {
      _id: "myReplSet",
      members: [
         { _id: 0, host : "mongodb0.example.net:27017" },
         { 
            _id: 1, 
            host : "mongodb1.example.net:27017", 
            hidden: true, 
            priority: 0, 
            votes: 0, 
            secondaryDelaySecs: 60 * 30
         }        
      ]
   }
)

Such member will hold a copy of the primary data with a delay of 30 Minutes. You cannot run any CRUD operations on it and it never becomes the PRIMARY.

I would suggest a delayed member, because if one does a bad command by accident, (e.g. drop collection) then you have half an hour to shutdown the database. Then you can restore from secondary.

MongoDB Document on Hidden Replica Set Members

1
  • Thank you @wernfried-domscheit
    – user10
    Commented Aug 19 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.