Update: This guide actually works with migrating from ANY version to ANY version (including latest v3.4) on a MongoDB supported Ubuntu version.
If you have installed MongoDB with the default version from package maintainer version (for example Ubuntu 14.04), then you are using v2.4 which is pretty much an archaic version and MongoDB has improved greatly particularly with WiredTiger or RocksDB storage engines since then. If you read the upgrade instructions on the official documentation, you would have seen that you need to follow this version chain 2.4 -> 2.6 -> 3.0 -> 3.2 to upgrade. Wait, what? In practice, it just does not work out. In this post, I will put my tested way of upgrading directly from 2.4 to 3.2 (or latest) AND switch to WiredTiger storage engine also.
- Dump whole database with
- Backup log, data and config files (for being extra careful)
- Purge (remove) old version packages and everything from the system
- Install the newest version via package manager
- Restore data using