Unable to start mongod with one missing collection wt file - mongodb

I have a working mongod instance (v3.2.21).
But suddenly it stopped working. When i run mongo command it is throwing me following error:
2019-06-04T13:52:41.725+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
When i checked log its showing:
2019-06-04T13:36:43.388+0000 E STORAGE [initandlisten] WiredTiger (2) [1559655403:388180][8404:0x7fb74e904c80], file:collection-1-1305830686620002691.wt, WT_SESSION.open_cursor: /mnt/volume-fra1-01//collection-1-1305830686620002691.wt: handle-open: open: No such file or directory
2019-06-04T13:36:43.388+0000 E STORAGE [initandlisten] no cursor for uri: table:collection-1-1305830686620002691
2019-06-04T13:36:43.388+0000 F - [initandlisten] Invalid access at address: 0x58
2019-06-04T13:36:43.398+0000 F - [initandlisten] Got signal: 11 (Segmentation fault).
The collection which was earlier there is now missing in data directory
I tried to use --repair but the process gets stop at this collection.
I have looked at various resources but couldn't figure out how to make it working? Is there way so that wiredtiger escape this collection?

MongoD 4.0.3 and newer has better repair facilities as per SERVER-19815.
One thing you can try:
Copy your original dbpath so if the attempt is not successful, you don't clobber your original data
Download the 4.0.3 binaries (or newer, currently the latest is 4.0.10)
mongod --repair using the 4.0.3 binaries to attempt to repair the copied dbpath
If the repair is successful, try to run the 3.2.21 binaries pointing to the repaired dbpath
Please note that this repair attempt is best-effort and there's no guarantee of success. Having an up-to-date backup is still recommended. You might also want to investigate how the dbpath is missing a file to begin with.

Related

How to repair MongoDb when someone deleted one database directory from the db directory?

One guy deleted one Database directory from the dbpath of MongoDb as we configured --directoryperdb.
Is there any option to ignore that database and I can start the server. Currently mongod --repair giving
2020-04-22T15:19:56.118+0000 E STORAGE [initandlisten] WiredTiger error (2) [1587568796:118648][22758:0x7fd9688ad580], file:Test/collection-556-3480094503407958
80.wt, WT_SESSION.salvage: /home/dbdir/db/Test/collection-556-348009450340795880.wt: handle-open: open: No such file or directory
2020-04-22T15:19:56.121+0000 I - [initandlisten] Invariant failure rs.get() src/mongo/db/catalog/database.cpp 195
And when trying to start the server It is giving segmentation fault. Is there any way I can fix the database.
Test is the database that was deleted?
After making a backup, grep the remaining tree for other files that reference it and try to delete those as well.

Error repairing MongoDB database - Verify failed on uri table

Suddenly my mongodb server has stopped working on my Mac and I just try to start it again It'll throw me an error described here https://jira.mongodb.org/browse/WT-4135.
So run a database repair and I keep getting this error,
2018-06-19T13:18:38.428+0530 I STORAGE [initandlisten] repairDatabase pdg_db
2018-06-19T13:18:38.428+0530 I STORAGE [initandlisten] Repairing collection ipd_db.app_sessions
2018-06-19T13:18:38.428+0530 I STORAGE [initandlisten] Verify failed on uri table:collection-1--4208304830224804148. Running a salvage operation.
2018-06-19T13:18:38.428+0530 F - [initandlisten] Invariant failure rs.get() src/mongo/db/catalog/database_impl.cpp 226
So I can't even start the server. As my understanding if I drop pdg_db this issue will be solved. But how to drop database without running the mongodb server? Is there any other way to do this?
Thanks

Mongod starting error (errno 45) : Unable to lock file

When I try to start mongod with the following command:
mongod --dbpath data/db
I get the following error:
[initandlisten] exception in initAndListen: 98 Unable to lock file:
data/db/mongod.lock errno:45 Operation not supported. Is a mongod instance
already running?, terminating
but when I use the ps command line, I don't see any running mongod instance.
I have tried to:
delete the whole directory data/ and recreate the path data/db
change the rights of the file mongod.lock
But none of these worked.
Any idea of what I should do? Thanks
Not All File systems support locking, Are you by any chance using NFS?
could you add FS type, mount options and permissions for your data folder?

Mongodb service not running

I'm working on this automatic drink dispenser and ran into an issue when I downloaded the Mongo 3.0.7 I tried to run it but I keep getting this error:
I got the idea from this website. http://yujiangtham.com/2014/05/30/build-your-very-own-drink-mixing-robot-part-2/
2016-02-02T15:56:42.585-0500 E NETWORK [initandlisten] listen():
bind() failed errno:48 Address already in use for socket:
0.0.0.0:27017
2016-02-02T15:56:42.585-0500 E NETWORK [initandlisten] addr already
in use 2016-02-02T15:56:42.593-0500 W - [initandlisten]
Detected unclean shutdown - /data/db/mongod.lock is not empty.
2016-02-02T15:56:42.593-0500 I STORAGE [initandlisten] exception in
initAndListen: 98 Unable to lock file: /data/db/mongod.lock errno:35
Resource temporarily unavailable. Is a mongod instance already
running?, terminating
2016-02-02T15:56:42.593-0500 I CONTROL [initandlisten] dbexit: rc:
100
I need help on how to run this. The website I'm using as a reference is
http://yujiangtham.com/2014/05/30/build-your-very-own-drink-mixing-robot-part-2/
It is stating that Mongo is already running. If you are certain it is not, then the lock file still exists from a previous unclean shutdown.
ps aux | grep mongo
if that returns nothing, it will mean the lock file still exists. looking at your error, the file is /data/db/mongod.lock
rm /data/db/mongod.lock
Should get rid of it so you'll be able to start the mongo service running again.
Try running pkill mongod to kill the process

MongoDB learning issue

Greetings I am learning mongodb and have encountered with following issue. I am pretty newbie in all of that and dived to into meanstack development after spending some hours messing with setups, I decided to spend some time learning first before doing something and found great corse of mongodb on their official website, following their lessons I cant start mongo server as it says I have already started it somewhere... :)
Error message:
2015-10-13T21:55:01.900+0200 E NETWORK [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2015-10-13T21:55:01.900+0200 E NETWORK [initandlisten] addr already in use
2015-10-13T21:55:01.912+0200 W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
2015-10-13T21:55:01.935+0200 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2015-10-13T21:55:01.935+0200 I CONTROL [initandlisten] dbexit: rc: 100
Can you please explain how can I find and remove that one or at least shut it down?
There may be already a mongodb instance running. Check it with below command.
ps -ef | grep 'mongo'
You can shutdown existing mongod instance using: http://docs.mongodb.org/master/tutorial/manage-mongodb-processes/#use-shutdown
mongod --shutdown
If no instance is running then go to the data location and remove the lock file.
cd /data/db/
sudo rm mongod.lock
Note: This is only for learning / local machine. This process might not be suitable for production.