Skip to content

Migrating Sharded Cluster Offline Individual Shards

doluiscontreras edited this page Jul 9, 2015 · 3 revisions

Migrating from MongoDB: Sharded cluster (offline, individual shards)

This guide explains how to do an offline data migration from MongoDB to TokuMX, for a sharded cluster, converting the existing data in MongoDB to TokuMX on a shard-by-shard basis.

For other migration strategies, start with Migrating from MongoDB and Migrating from MongoDB: Sharded clusters.

  1. Shut down the existing MongoDB servers on each machine in the sharded cluster (shards, config servers, and routers) to make sure you get a consistent backup.

  2. Migrate each shard to TokuMX offline, following the guide Migrating from MongoDB: Replica set (offline). You can do this for each shard in parallel.

  3. Back up one of the MongoDB config servers with mongodump. You will need the dbpath from /etc/mongodb.conf (this is often /var/lib/mongodb) and you will need to choose a location for the backup (here, /var/lib/configdb.backup).

    One config server only:

    $ sudo mongodump --dbpath /var/lib/mongodb --out /var/lib/configdb.backup
    
    - MongoDB latest version -
    
    $ sudo mongodump --out /var/lib/mongodb.backup
    
  4. Uninstall MongoDB from the config servers. You can also remove the old dbpath since you have a backup.

  5. Install TokuMX for your distribution on the config servers (instructions) and make sure it starts properly. Migrate any relevant configuration from /etc/mongodb.conf to /etc/tokumx.conf and restart the config servers if necessary.

  6. Import the backup to each config server with mongorestore. If you are running with the configsvr option, remember that this makes the port 27019 instead of the default.

    $ mongorestore --host localhost:27019 /var/lib/configdb.backup
    $ mongorestore --host cfg2.domain:27019 /var/lib/configdb.backup
    $ mongorestore --host cfg3.domain:27019 /var/lib/configdb.backup
    
  7. Copy any relevant configuration from /etc/mongodb.conf to /etc/tokumx.conf on all mongos router machines.

  8. If your config servers have different hostnames now, you will need to update the configdb settings for all your mongos configurations. See Migrate Config Servers with Different Hostnames for more details.

  9. If your shard servers have different hostnames now, you will need to update their hostnames in the config servers' databases. Connect to the config servers and update the shards' metadata.

    $ mongo localhost:27019,cfg2.domain:27019,cfg3.domain:27019/config
    > db.shards.update({_id: <shard name>},
                       {$set: {host: "<replset name>/<hostnames>"}})
    
  10. Start the TokuMX mongos server on all router machines, and start your application.

Clone this wiki locally