I have MongoDB running in replication mode, with 3 instances, on AWS. The setup has been up and running for over a year. With periodic updates to the application server (running Node.js code). The application server has been running the same code for several months. Last night all calls to the DB started failing, when I logged in to the AWS EC2 Instance running the primary MongoDB, I could not find any of the collections from the mongo shell. This is the same mongo shell that's been up and running for months (I use tmux to connect).
Based on the size consumption on the filesystem, from what I remember, I think the data is there, but I'm not sure how to access it now.
sudo /usr/bin/mongod --replSet ReplicaSet --port 27017 --dbpath /data/db
The above command was used to start the mongo db, nothing has been changed, but the data simply disappeared last night. The same is true on all 3 servers (Primary and 2 Secondaries)
Any help is extremely welcomed...
See mongodb log if any dropDatabase command has been executed or not. Generally its /var/log/mongo/mongo.log. Or see /etc/mongo.conf for log file location.
Recently some exposed mongoDB has been hacked for ransom.
For debian/ubuntu
$ mongo
> use admin
> db.shutdownServer()
and then
mongod --fork --logpath /var/log/mongodb.log --dbpath /var/lib/mongodb
I imagine you solved this by now. I am going to give an answer for anyone with similar issues. I am not sure of your experience level with MongoDB, so I will try to layout more information than you probably need. Anyway,I have had a similar issue as you are experiencing. I love MongoDB, but it has a learning curve with it, mine was with what happens with "unconfined documents". If like me, you have MongoDB set to auto-restart in the event of a crash, then unless you check your logs, you may never be aware of a crash. If a crash occurs, or even a reset, there are times when documents that are there, but fall into the "unconfirmed" category are lost. So...
Understand "write concerns" and how they relate to data durability. An article that helped me a lot with this is:
https://www.percona.com/blog/2016/07/14/mongodb-data-durability/
Make sure conf file is being loaded. Perhaps it is not seeing your data for some reason. You can, for a test, load mongod.exe and specify the path directly to your db for a test, i.e.:
mongod --dbpath c:\mongo\data\db