How to migrate MongoDB 2.6 to 3.0 with WiredTiger

Solution 1:

In default installations, the configuration file is at /etc/mongod.conf. What the MongoDB docs don't mention is that when migrating to WiredTiger we also need to update the configuration file to the new YAML format introduced in 2.6.
As far as I can tell the engine option is only available in the new configuration format.
Migrating from the old storage engine consists in creating a database dump, shutting down mongodb, changing settings and then importing the dump into the new storage engine.

  1. Create a backup. Seriously. We need a database dump which we'll then import to the new database engine:

    mongodump -d db_name /backup/path/  
    
  2. Stop the mongodb service

    sudo service mongod stop  
    
  3. Move data from the current location to somewhere else (MongoDB will not startup if the data directory contains files generated by the old storage engine).

    sudo mv /var/lib/mongodb /var/lib/mongodb_26/
    
  4. Upgrade MongoDB to version 3.0 (from http://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-ubuntu/):

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10  
    echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list  
    sudo apt-get update  
    sudo apt-get install mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools  
    
  5. Convert the configuration file from old (pre 2.6) to the current YAML format. The bare minimum is:

    storage:  
        dbPath: "/var/lib/mongodb"  
        engine: wiredTiger  
    
    systemLog:  
       destination: file  
       path: "/var/log/mongodb/mongod.log"  
       logAppend: true  
    
    net:  
        bindIp: 127.0.0.1  
        port: 27017  
        # Enable the HTTP interface (Defaults to port 28017).  
        http:  
            enabled: false  
    

    Make sure no lines in the old format remain, or MongoDB won't start.

    The full documentation for the configurtion file is at: http://docs.mongodb.org/v3.0/reference/configuration-options/

  6. Optionally make a backup of the log:

    sudo mv /var/log/mongodb/mongod.log /var/log/mongodb/mongod_26.log
    
  7. Restart mongodb

    sudo service mongod start
    
  8. Load the backup to convert data to new storage engine

    mongorestore /backup/location
    

After checking that all your data is ok, you can delete the directory with the old data format

sudo rm -r /var/lib/mongodb_26/

Note that for replica sets and sharded clusters there are some aditional steps: http://docs.mongodb.org/v3.0/release-notes/3.0-upgrade/?_ga=1.86531032.1131483509.1428671022#change-replica-set-storage-engine-to-wiredtiger

Solution 2:

Using the old configuration file format, I had success with:

storageEngine=wiredTiger