1
votes

It is development environment, Ubuntu 12.04 . Usually I start my mongodb server using the following command.

sudo mongod --dbpath /data/db/ --fork --logpath /var/log/mongodb.log --logappend

Today I tried starting it using

sudo mongod --fork

and then

sudo mongod --fork --logpath /var/log/mongodb.log --logappend

It was not starting.

Then I gave the full command. Still it did not start.

I realized that the directory /data/db was missing(It was existing till yesterday). So I had to create it, and all my data was lost. Other developers in my team has experienced similar problems earlier. I am not sure why the problem is occurring. Is this not the proper way of starting the server?(Even then the data should not be lost).

How to ensure that this will not repeat on the production environment.

1
99.99999% MongoDB is not in charge for any data loss here..99.9999% you have been running MongoDB with a different dbpath or you removed the data yourself for whatever reason. The human factor is the problem here. Side note: why are you running as root???Andreas Jung
Starting mongo as a service should be preferred when possible sudo service mongodb start. (the configuration file is /etc/mongodb.conf)Eric
I have no idea about this but mongodb can't, even in sudo mode: a, create the db directory and b, remove it. There is something else on your server. Maybe it is an im memory server built from an image that starts a fresh every so often, or on restart?Sammaye

1 Answers

1
votes

Are you sure it was lost?

I also thought mine was lost, but I started checking around and found it in the area where you will find the folders:

  • /bin
  • /boot
  • /etc
  • /media
  • ...

Basically, it looks like it exists where "File System" is.

I also see that you're using the "--fork..." command, although I'm not sure it will affect it.

Tell me if you find it where I specified and we can take things from there.