Question

I have a mongodb v2.4.6 running on ubuntu 13.04. It is known that mongodb store all data in /var/lib/mongodb. Now the mongodb is running out of the hard disk. Fortunately, I got a new hard disk which is installed, fdisked, formated and got a name /dev/sda3. Unfortunately I don't know how to let the mongodb make use of the new hard disk because my knowledge on ubuntu and mongodb is very limited. After some research in internet, it seems that I should execute the following command

sudo mount /dev/sda3 /var/lib/mongodb

Is this what I need to do to let mongodb use the new disk? If so, will mongodb automatically and intelligently increase its data to this disk? Is there any othere things I should do? Thank you.

Was it helpful?

Solution

Unfortunately this one will not be that straightforward. Even if you succeed with the mounting it will not move the files at all. What you can do is to

  • mount the disk elsewhere (mkdir /var/lib/mongodb1, mount /dev/sda3 /var/lib/mongodb1)
  • stop mongo
  • copy the files from /var/lib/mongodb to /var/lib/mongodb1 (only helps if the new disk is bigger)
  • reconfigure mongo to use as db dir the new directory or swap the names with mv commands
  • start mongo
  • if everything went fine, mongo started and so on,(check it first!!!) you can delete the old data.

If you have a disk which is the same size so with moving the data you will run into the same problem, if you need larger space then a single disk you should play around with RAID and/or LVM and more disks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top