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

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.

Related

Unable to start mongod with one missing collection wt file

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.

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 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.

MongoDB does not start after installing first time

I am trying to install MongoDB first time on my Windows 7 machine. I am installing it to default location (c:/).
When I execute the mongod.exe first time, I get the message 'the waiting for connections message in the console'. The documentation of MongoDB asks to connect on another cmd prompt and execute mongod.exe again.
When I do this I get the following message:
C:\Program Files\MongoDB\Server\3.0\bin>mongod.exe
2015-09-04T11:31:23.880+0530 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data files
2015-09-04T11:31:23.905+0530 W - [initandlisten] Detected unclean shutdown - C:\data\db\mongod.lock is not empty.
2015-09-04T11:31:23.907+0530 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file:
C:\data\db\mongod.lock errno:32 The process cannot access the file because it is being used by another process.. Is a mo
ngod instance already running?, terminating
2015-09-04T11:31:23.907+0530 I CONTROL [initandlisten] dbexit: rc: 100
C:\Program Files\MongoDB\Server\3.0\bin>mongod.exe
2015-09-04T11:33:52.437+0530 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data files
2015-09-04T11:33:52.442+0530 W - [initandlisten] Detected unclean shutdown - C:\data\db\mongod.lock is not empty.
2015-09-04T11:33:52.445+0530 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file:
C:\data\db\mongod.lock errno:32 The process cannot access the file because it is being used by another process.. Is a mo
ngod instance already running?, terminating
2015-09-04T11:33:52.445+0530 I CONTROL [initandlisten] dbexit: rc: 100
P.S.: I have created /data/db in C:/.
Well, I just faced the same issue. I installed the fix, but saw nothing but same error. So that's how I got over it: just create a folder structure in your C catalog like this one: C:\data\db. So it worked for me perfectly. I use Windows 7 x64.