Skip to content

Migrating Replica Set Offline

doluiscontreras edited this page Jul 9, 2015 · 5 revisions

Migrating from MongoDB: 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.

  1. Shut down the existing MongoDB servers on each machine in the replica set to make sure you get a consistent backup.

  2. Back up the primary MongoDB database with mongodump. You will need the dbpath 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
    
  3. Uninstall MongoDB from all machines. You can also remove the old dbpath since you have a backup.

  4. Install TokuMX for your distribution on all machines (instructions). If your distribution's package manager automatically starts TokuMX, stop it for now.

  5. Import your backup to just the primary with mongorestore. You will need the dbpath from /etc/tokumx.conf (by default, /var/lib/tokumx).

    Primary server only:

    $ mongorestore --dbpath /var/lib/tokumx /var/lib/mongodb.backup
    
  6. Add the replSet option to /etc/tokumx.conf on all machines, for example, replSet = rs0.

  7. 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>
    
  8. Copy the dbpath to all the secondaries. The data is already compressed, so compressing with rsync will not be faster, and it will be much faster than a normal initial sync.

  9. Add the fastsync=true option to /etc/tokumx.conf on all secondaries.

  10. Start TokuMX on all servers.

  11. Connect to the primary and rs.add() each of the secondaries. With fastsync 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 }
    
  12. Remove the fastsync=true option from /etc/tokumx.conf on each of the secondaries. You do not need to restart them now.

Clone this wiki locally