mongodump with replica set transferred from secondary.

1,138 views
Skip to first unread message

Isamu SUZUKI

unread,
Apr 4, 2014, 5:47:53 AM4/4/14
to mongod...@googlegroups.com
Hello guys,

My replica set is three mongods.


Now. the primary is 10.0.0.1:27017.
All of the versions is 2.4.5.
The replicaset name is replname.

Well, we've tried mongodump with --host and replicaset name option.

mongodump --host replname/10.0.0.1:27017,10.0.0.2:27017,10.0.0.3:27017 --out ./output_directory_name

The mongodump said,

Fri Apr  4 09:31:10.652 starting new replica set monitor for replica set replname with seed of 10.0.0.1:27017,10.0.0.2:27017,10.0.0.3:27017
Fri Apr  4 09:31:10.655 successfully connected to seed 10.0.0.1:27017 for replica set replname
Fri Apr  4 09:31:10.658 changing hosts to { 0: "10.0.0.1:27017", 1: "10.0.0.2:27017", 2: "10.0.0.3:27017" } from replname/
Fri Apr  4 09:31:10.658 trying to add new host 10.0.0.1:27017 to replica set replname
Fri Apr  4 09:31:10.660 successfully connected to new host 10.0.0.1:27017 in replica set replname
Fri Apr  4 09:31:10.660 trying to add new host 10.0.0.2:27017 to replica set replname
Fri Apr  4 09:31:10.661 successfully connected to new host 10.0.0.2:27017 in replica set replname
Fri Apr  4 09:31:10.661 trying to add new host 10.0.0.3:27017 to replica set replname
Fri Apr  4 09:31:10.662 successfully connected to new host 10.0.0.3:27017 in replica set replname
Fri Apr  4 09:31:10.672 Primary for replica set replname changed to 10.0.0.1:27017
Fri Apr  4 09:31:10.679 replica set monitor for replica set replname started, address is replname/10.0.0.1:27017,10.0.0.2:27017,10.0.0.3:27017
Fri Apr  4 09:31:10.680 [ReplicaSetMonitorWatcher] starting

I think that the data from primary server.
But the mongodump transferred data from secondary server what we've captured the IP packets.

I have two questions.

1. Is this mongodump spec?
2. The data from secondary, no problem?

Thank you.

Eoin Brazil

unread,
Apr 4, 2014, 10:46:06 AM4/4/14
to mongod...@googlegroups.com
Hi Isamu,

The MongoDB docs have a nice write up on how to restore a replicaset from a backup that might be of interest - http://docs.mongodb.org/manual/tutorial/restore-replica-set-from-backup/

Are you aware that you can also use filesystem snapshots as an alternative to mongodump ? A snapshot approaches includes the indexes and is typically faster than mongodump.

Q1 -
When you connect mongodump and provide a replicaset string in the host field, it will take the data from the primary in the replicaset (see http://docs.mongodb.org/manual/reference/program/mongodump/#cmdoption--host).

The mongodump command you are running should also include the --oplog field (http://docs.mongodb.org/manual/reference/program/mongodump/#cmdoption--oplog) to create a point in time snapshot of the mongod by including a partial oplog for the operations that occur during your mongodump. You also need to ensure that your oplog length is x3 times the length of your oplog, you can find this using the db.printReplicationInfo() command - http://docs.mongodb.org/manual/reference/method/db.printReplicationInfo/ This prevents the oplog from rolling over during your mongodump which could result in the dump missing critical data. 

I would recommend filesystem snapshots and the MongoDB procedure here (http://docs.mongodb.org/manual/tutorial/restore-replica-set-from-backup/) and also testing the procedure in practice. 

Q2 -
Without the oplog field then the data could have missed important data so I would take a new copy for your backup to be sure you have a point in time snapshot.

Hope this helps!
Eoin

Asya Kamsky

unread,
Apr 4, 2014, 11:56:35 PM4/4/14
to mongodb-user
When you connect to a replica set, the driver(s) will always try to
find the primary.

However, mongodump always attempts to read from a secondary
preferentially. I think that matches your observations.

Eoin's point about --oplog option is a good one, as is the one about
using file system snapshots.

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/23e4c5ef-7acb-4174-a4c7-dae3ec98af9f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages