MongoDB 3.0 introduces a new storage engine called wiredTiger which results in greatly reduced memory and disk space usage.
Since my DB is currently at ~20 million objects and using up ~70GB of RAM, this update comes in at just the right time to postpone a hardware update.
How do you migrate an existing installation of MongoDB 2.6 to 3.0 and at the same time get the benefits of wiredTiger?
The Documentation refers to options which result in startup errors which prevent MongoDB from starting up. Also, file locations don't match the ones in Ubuntu (Server 14.04 LTS).
12 Answers
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.
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/Stop the mongodb service
sudo service mongod stopMove 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/Upgrade MongoDB to version 3.0 (from ):
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 echo "deb "$(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-toolsConvert 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: falseMake sure no lines in the old format remain, or MongoDB won't start.
The full documentation for the configurtion file is at:
Optionally make a backup of the log:
sudo mv /var/log/mongodb/mongod.log /var/log/mongodb/mongod_26.logRestart mongodb
sudo service mongod startLoad 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:
1Using the old configuration file format, I had success with:
storageEngine=wiredTiger1