-
Notifications
You must be signed in to change notification settings - Fork 97
Migrating Replica Set Offline
This guide explains how to do an offline data migration from MongoDB to TokuMX, for a replica set, converting the existing data in MongoDB to TokuMX.
For other migration strategies, start with Migrating from MongoDB and Migrating from MongoDB: Replica sets.
-
Shut down the existing MongoDB servers on each machine in the replica set to make sure you get a consistent backup.
-
Back up the primary MongoDB database with
mongodump
. You will need thedbpath
from your command-line options or/etc/mongodb.conf
(this is often/var/lib/mongodb
), and you will need to choose a location for the backup (here,/var/lib/mongodb.backup
).Primary server only:
$ sudo mongodump --dbpath /var/lib/mongodb --out /var/lib/mongodb.backup - MongoDB latest version - $ sudo mongodump --out /var/lib/mongodb.backup
-
Uninstall MongoDB from all machines. You can also remove the old
dbpath
since you have a backup. -
Install TokuMX for your distribution on all machines (instructions). If your distribution's package manager automatically starts TokuMX, stop it for now.
-
Import your backup to just the primary with
mongorestore
. You will need thedbpath
from/etc/tokumx.conf
(by default,/var/lib/tokumx
).Primary server only:
$ mongorestore --dbpath /var/lib/tokumx /var/lib/mongodb.backup
-
Add the
replSet
option to/etc/tokumx.conf
on all machines, for example,replSet = rs0
. -
Start the primary, connect to it, and run
rs.initiate()
and then shut it down, to initialize the oplog.Primary server only:
$ mongo TokuMX mongo shell v1.4.2-mongodb-2.4.10 connecting to: test > rs.initiate() { "info2" : "no configuration explicitly specified -- making one", "me" : "db1.localdomain:27017", "info" : "Config now saved locally. Should come online in about a minute.", "ok" : 1 } > rs0:PRIMARY>
-
Copy the
dbpath
to all the secondaries. The data is already compressed, so compressing withrsync
will not be faster, and it will be much faster than a normal initial sync. -
Add the
fastsync=true
option to/etc/tokumx.conf
on all secondaries. -
Start TokuMX on all servers.
-
Connect to the primary and
rs.add()
each of the secondaries. Withfastsync
they will not need to do a full initial sync.Primary server only:
$ mongo TokuMX mongo shell v1.4.2-mongodb-2.4.10 connecting to: test rs0:PRIMARY> rs.add('db2.domain:27017') { "ok" : 1 } rs0:PRIMARY> rs.add('db3.domain:27017') { "ok" : 1 }
-
Remove the
fastsync=true
option from/etc/tokumx.conf
on each of the secondaries. You do not need to restart them now.