If you re running out of disk, you obviously need to get a bigger disk.
There are several ways to migrate your data, it really depends on the type of up-time you need. First steps of course involve bundling the machine and creating the new volume.
These tips go from easiest to hardest.
Can you take the database completely off-line for several minutes?
If so, do this (migration by copy):
- Mount new EBS on the server.
- Stop your app from connecting to Mongo.
- Shut down mongod and wait for everything to write (check the logs)
- Copy all of the data files (and probably the logs) to the new EBS volume.
- While the copy is happening, update your mongod start script (or config file) to point to the new volume.
- Start mongod and check connection
- Restart your app.
Can you take the database off-line for just a few minutes?
If so, do this (slaving and switch):
- Start up a new instance and mount the new EBS on that server.
- Install / start mongod as a --slave pointing at the current database. (you may need to re-start the current as --master)
- The slave will do a fresh synchronization. Once the slave is up-to-date, you ll do a "switch" (next steps).
- Turn off writes from the system.
- Shut down the original mongod process.
- Re-start the "new" mongod as a master instead of the slave.
- Re-activate system writes pointing at the new master.
Done correctly those last three steps can happen in minutes or even seconds.
Can you not afford any down-time?
If so, do this (master-master):
- Start up a new instance and mount the new EBS on that server.
- Install / start mongod as a master and a slave against the current database. (may need to re-start current as master, minimal down-time?)
- The new computer should do a fresh synchronization.
- Once the new computer is up-to-date, switch the system to point at the new server.
I know it seems like this last version is actually the best, but it can be a little dicey (as of this writing). The reason is simply that I ve honestly had a lot of issues with "Master-Master" replication, especially if you don t start with both active.
If you plan on using this method, I highly suggest a smaller practice run first. If something bombs here, Mongo might simply wipe all of your data files which will have the effect of taking more stuff down.
If you get a good version of this please post the commands, I d like to see it in action.