My problem is with Mongo eating up space on the disk.
Reading a few blogs no the web - I was certain - a repair
would save me time as this would free up mongo's reserved space. But attempting a repair throws this error because I am at 90% disk usage :
db.repairDatabase()
{
"ok" : 0,
"errmsg" : "Cannot repair database my_d_b having size: 347673198592 (bytes) because free disk space is: 42874580992 (bytes)"
}
Then I tried the next step which is compacting every collection in the database using :
db.getCollectionNames().forEach(function (collectionName) {
print('Compacting: ' + collectionName);
db.runCommand({ compact: collectionName });
});
This reduced my disk usage by just 1%.
Now I can easily pause my apps from writing to this mongo database. I don't want to use any replset approach etc. I want to just move it to a bigger disk and move forward. I have already mounted an extra disk which 2.5times the size. I am not finding concrete steps to move the data and change mongo configuration and then start mongo process.
My repairs and compactions may be failing because they need space to operate as per my understading. If I can move this data to new disk and point mongo to the new disk, I will be good.
This is what I want to achieve - would appreciate a little direction.
mongod
? If so, the most direct approach would be to copy the contents of your currentdbPath
to the a directory on the new disk: stopmongod
, copy the contents of yourdbPath
to a new directory, updatedbPath
in your configuration file to point to this new directory, and finally restartmongod
. As far as trying to reduce existing storage usage: can you confirm the specific version of MongoDB and storage engine are you using?