MongoDB not working in Vagrant Centos Box - mongodb

I cant seem to fork off an instance of the MongoDB daemon when I am logged in to a Centos 7.1 Box. I have created the data/db folder and everytime I try to run
./bin/mongod --dbpath data/db
I get a mess of errors
2016-01-26T00:44:23.820+0000 I CONTROL [initandlisten] MongoDB starting : pid=2735 port=27017 dbpath=data/db 64-bit host=localhost.localdomain
2016-01-26T00:44:23.820+0000 I CONTROL [initandlisten] db version v3.2.1
2016-01-26T00:44:23.820+0000 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] modules: none
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] build environment:
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] distarch: x86_64
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "data/db" } }
2016-01-26T00:44:23.842+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-01-26T00:44:23.853+0000 E STORAGE [initandlisten] WiredTiger (22) [1453769063:853352][2735:0x7f09f2eddcc0], connection: data/db/WiredTiger.wt: fsync: Invalid argument
2016-01-26T00:44:23.856+0000 I - [initandlisten] Fatal Assertion 28561
2016-01-26T00:44:23.856+0000 I - [initandlisten]
***aborting after fassert() failure
The strange thing is I did it earlier and it worked. What could be the problem?

It turns out that putting the downloaded mongodb database in the synced folder between the host machine and the virtual machine caused some type of permissions issue or configuration issue.
When you take it out of the synced folder - which most likely has the Vagrantfile - and put it in a folder thats not synced/shared it seems to work just fine. Thought id save someone the 5 hours I wasted :-)

Related

MongoDB has suddently shut down with "code 100" after months of running

I have an ubuntu server running MongoDB and it has successfully been running for over a year now without any problems. Today suddenly it crashed throwing me a code 100.
ubuntu#ip-172-26-6-171:~/project$ mongod
2021-10-21T17:14:23.214+0000 I CONTROL [initandlisten] MongoDB starting : pid=868751 port=27017 dbpath=/data/db 64-bit host=ip-172-26-6-171
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] db version v3.6.8
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] git version: 8e540c0b6db93ce994cc548f000900bdc740f80a
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1f 31 Mar 2020
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] allocator: tcmalloc
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] modules: none
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] build environment:
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] distarch: x86_64
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] target_arch: x86_64
2021-10-21T17:14:23.215+0000 I CONTROL [initandlisten] options: {}
2021-10-21T17:14:23.220+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2021-10-21T17:14:23.220+0000 I CONTROL [initandlisten] now exiting
2021-10-21T17:14:23.220+0000 I CONTROL [initandlisten] shutting down with code:100
Why is it out of nowhere while running smoothly suddenly face this error? No changes has been made or anything. It hasn't been touched. It just stopped working out of the blue...
And has I lost the database?
How do I get it up and running again? And without data loss.
EDIT FOR SOLUTION
I made the directory /data/db and moved the database files to this destination. Why it has worked for over a year and then suddenly do this, is still unknown. But fixed with this solution.

My MongoDB isnt working when I type mongod in the terminal

I type in mongod to create a new db but I get this error, any idea what's going on here?
mongod
2018-08-28T18:06:36.824+0100 I CONTROL [initandlisten] MongoDB starting : pid=41812 port=27017 dbpath=/data/db 64-bit host=Ruairidhs-MacBook-Pro.local
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] db version v3.6.3
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] allocator: system
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] modules: none
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] build environment:
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] distarch: x86_64
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] options: {}
2018-08-28T18:06:36.825+0100 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] now exiting
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] shutting down with code:100
Open a new terminal window, and execute top, according to the error, you already have an instance of mongod running, so you need to find it and terminate it.

How to run same db folder

I am running mongod --storageEngine=mmapv1 in console
and everything is fine. It uses by standard the C:\data\db folder.
But after I reload my computer and try same command it throws an error.
C:\mongodb\bin>mongod --storageEngine=mmapv1
2018-05-18T10:53:45.491+0300 I CONTROL [main]
2018-05-18T10:53:45.491+0300 W CONTROL [main] 32-bit servers don't have journal
ing enabled by default. Please use --journal if you want durability.
2018-05-18T10:53:45.491+0300 I CONTROL [main]
2018-05-18T10:53:45.491+0300 I CONTROL [main] Hotfix KB2731284 or later update
is not installed, will zero-out data files
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] MongoDB starting : pid=2
396 port=27017 dbpath=C:\data\db\ 32-bit host=yaposhytiil-ara
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] targetMinOS: Windows Vis
ta/Windows Server 2008
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] db version v3.2.20
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] git version: a7a144f40b7
0bfe290906eb33ff2714933544af8
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] allocator: tcmalloc
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] modules: none
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] build environment:
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] distarch: i386
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] target_arch: i386
2018-05-18T10:53:45.506+0300 I CONTROL [initandlisten] options: { storage: { en
gine: "mmapv1" } }
2018-05-18T10:53:45.506+0300 W - [initandlisten] Detected unclean shutdow
n - C:\data\db\mongod.lock is not empty.
2018-05-18T10:53:45.528+0300 I STORAGE [initandlisten] **************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
2018-05-18T10:53:45.531+0300 I STORAGE [initandlisten] exception in initAndList
en: 12596 old lock file, terminating
2018-05-18T10:53:45.532+0300 I CONTROL [initandlisten] dbexit: rc: 100
As I understand it's locks the data from access.
I wouldn't waste your time, but I didn't know how to google it...
Is it because of 32bit Windows, or some user access settings, or I have to repair/delete db folder every time?

mongodb no such file or directory wiredtiger_kv_engine

what I did :
went to the database directory and
mongod --dbpath .
then I got this:
2017-02-16T23:51:51.965+0800 I CONTROL [initandlisten] MongoDB starting : pid=31656 port=27017 dbpath=. 64-bit host=WIN-01604161705
2017-02-16T23:51:51.966+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-02-16T23:51:51.968+0800 I CONTROL [initandlisten] db version v3.4.1
2017-02-16T23:51:51.969+0800 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
2017-02-16T23:51:51.970+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t-fips 3 May 2016
2017-02-16T23:51:51.971+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-02-16T23:51:51.972+0800 I CONTROL [initandlisten] modules: none
2017-02-16T23:51:51.973+0800 I CONTROL [initandlisten] build environment:
2017-02-16T23:51:51.974+0800 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-02-16T23:51:51.975+0800 I CONTROL [initandlisten] distarch: x86_64
2017-02-16T23:51:51.975+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-02-16T23:51:51.978+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "." } }
2017-02-16T23:51:51.982+0800 I - [initandlisten] Detected data files in . created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-02-16T23:51:51.982+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3519M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-02-16T23:51:51.992+0800 I - [initandlisten] Assertion: 28595:2: No such file or directory src\mongo\db\storage\wiredtiger\wiredtiger_kv_engine.cpp 267
2017-02-16T23:51:51.992+0800 I STORAGE [initandlisten] exception in initAndListen: 28595 2: No such file or directory, terminating
2017-02-16T23:51:51.993+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-02-16T23:51:51.994+0800 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-02-16T23:51:51.996+0800 I CONTROL [initandlisten] now exiting
2017-02-16T23:51:51.998+0800 I CONTROL [initandlisten] shutting down with code:100
I don't know what's going on at all.
all that I have done is just common things like revising my files in other directories, merge the branch 'master' into 'b2' using github client.
I doubt that something went wrong when I did the 'merge' operation.
I have tried using git revert to make it roll back, still getting the same error.
Should I reinstall mongodb? I'm doing so.

sudo service mongod start : mongod: unrecognized service

I'm testing learning locker which is based on MongoDB it's all inside a ubuntu14.04 docker https://hub.docker.com/r/hadyrashwan/learninglocker-ubuntu14.04/ . I got it to work but I can't start Mongodb automatically tried the repair command and changing the name in start service command to Mongodb or mongo but not working. but running Mongodb just make it start but I want to start it automatically not opening a terminal and leave it open so the system continues to work
root#bd1997365c3a:/# mongodb
2016-09-06T07:41:51.816+0000 I CONTROL [initandlisten] MongoDB starting : pid=197 port=27017 dbpath=/data/db 64-bit host=bd1997365c3a
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] db version v3.2.9
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] modules: none
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] build environment:
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] distarch: x86_64
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] options: {}
2016-09-06T07:41:51.823+0000 I - [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
2016-09-06T07:41:51.867+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
2016-09-06T07:41:51.867+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-09-06T07:41:52.027+0000 I JOURNAL [durability] Durability thread started
2016-09-06T07:41:52.027+0000 I JOURNAL [journal writer] Journal writer thread started
2016-09-06T07:41:52.101+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-06T07:41:52.101+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.111+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-09-06T07:41:52.112+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-09-06T07:41:52.112+0000 I NETWORK [initandlisten] waiting for connections on port 27017
If already you install the mongodb just uninstall based on mongodb config
Before going do all stuff first install mongodb server.
sudo apt install mongodb-server
Then continue to install what mongodb config suggest you.
Once done your mongodb configuration you can go
sudo service mongodb start
Note: Its not mongod its mongodb
I had same problem. It seems there is some mis-configuration if you install via source code.
Re-installing mongoDB using apt-get activated mongod as a service for
me.