Can you have downtime? Just shut your mongod down, manually move the data from /var/lib/mongo to /data, edit the config to point to the new data, and restart mongod.
Can't have downtime? Start a new mongod instance pointed to /data on a different port, create a replica set on the primary and add your new secondary to the replica set(oh and start a 3rd mongod as an arbiter on a 3rd port). Wait for the recovery to be finished, shut down the first mongod and your new secondary will become primary, pointing to new data.
On Saturday, October 13, 2012 11:41:15 PM UTC-6, Justin Meltzer wrote:
A couple months ago I followed the guide here: http://www.mongodb.org/display/DOCS/Amazon+EC2+Quickstart#AmazonEC2Quickstart-StartingMongoDB to get a single MongoDB database up and running.
I followed the guide strictly, first creating EBS volumes, converted them to RAID 10, created a volume group and logical volumes for logs, journaling, and data, made filesystems from each of the partitions and then mounted the file systems.
Then under "Install and Configure MongoDB"
http://www.mongodb.org/display/DOCS/Amazon+EC2+Quickstart#AmazonEC2Quickstart-InstallandConfigureMongoDB it states if you created a MongoDB instance from the AWS Marketplace, then you can skip ahead to "Starting MongoDB". Since I did create a MongoDB instance from the marketplace, I did just this. However, I just now realized that the mongod.conf file automatically created from the marketplace does not have a dbpath set to /data, but rather to /var/lib/mongo. Setting the correct dbpath was in the part that I was told to skip.
Unfortunately since I now have data in the wrong directory, how can I safely switch over to the right directory while copying over my data?