mongo db not starting up on ubuntu - mongodb

I have a mongodb on a remote machine. I restarted the machine the other day without closing the mongodb service first, when I try to restart it today using command sudo service mogod start, nothing happened. I checked the log file /var/log/mongodb/mongod.log there was no error message but a message that seems to be a succesfful restart atempt today. Further restart, stop, start commands are not logged to the log file. And there are no error message on either the log file or terminal window.
2018-06-11T22:47:50.191+0800 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2018-06-11T22:47:50.697+0800 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2018-06-11T22:47:56.309+0800 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2018-06-11T22:47:57.269+0800 I CONTROL [signalProcessingThread] now exiting
2018-06-11T22:47:57.269+0800 I CONTROL [signalProcessingThread] shutting down with code:0
2018-06-19T11:48:33.985+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-06-19T11:48:34.115+0800 I CONTROL [initandlisten] MongoDB starting : pid=6614 port=27017 dbpath=/var/lib/mongodb 64-bit host=ubuntu
2018-06-19T11:48:34.115+0800 I CONTROL [initandlisten] db version v3.6.4
2018-06-19T11:48:34.115+0800 I CONTROL [initandlisten] git version: d0181a711f7e7f39e60b5aeb1dc7097bf6ae5856
When I tried sudo mongod it comes up with exception in initAndListen: NonExistentPath: Data directory /data/db not found. error. When I tried sudo mongod --dbpath=/var/lib/mongodb the database start successfully.
What should I check or do to start the process using sudo service mogod start again?

You will have to create map "data/db" in at your disk.
Usually on Windows there should be path C://data/db. I am guessing that you should create same map on disk even though it is Ubuntu. You can try with that

Related

loading docker container from existing project, mongo will not connect to database Ubuntu 18.04

At first I had a problem where the mongod service stopped working altogether. Thereupon I completely uninstalled mongodb and reinstalled it and followed instructions per this thread: https://askubuntu.com/questions/921753/failed-to-start-mongod-service-unit-mongod-service-not-found
This caused the mongod service to finally start.
In order for it to work, I also had to follow instructions from this thread:
mongo - couldn't connect to server 127.0.0.1:27017
So far this configuration has worked only 1 time and that was after I followed the instructions to remove the .lock file in the mongod directory and then repair mongod.
I also tried to remove the sock file like stated here: MongoDB Failing to Start - ***aborting after fassert() failure
Full project reset
Then I tried just disconnecting the project entirely; close nodemon for backend, exit ng serve on frontend, stop and remove mongo docker container... And tried again. Here is my step-by-step process after everything should have been fixed:
Restart mongod service
sudo service mongod restart
Restart frontend (executed from frontend directory)
ng serve frontend
Restart backend (executed from backend directory)
npx nodemon backend
Restart mongo container (executed from deploy directory, mongo is the docker container name, I'm building it from existing provided deploy script)
sudo docker-compose up -d mongo
sudo docker ps -a # check container was created and is running
Debugging information:
sudo service mongod status
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset:
Active: active (running) since Thu 2020-01-09 11:21:43 CET; 3min 40s ago
Docs: https://docs.mongodb.org/manual
Main PID: 17242 (mongod)
CGroup: /system.slice/mongod.service
└─17242 /usr/bin/mongod --config /etc/mongod.conf
janv. 09 11:21:43 junior-LIFEBOOK-E752 systemd[1]: Started MongoDB Database Server
sudo mongod2020-01-09T11:25:45.983+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] MongoDB starting : pid=17727 port=27017 dbpath=/data/db 64-bit host=junior-LIFEBOOK-E752
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] db version v4.2.2
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] allocator: tcmalloc
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] modules: none
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] build environment:
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] distmod: ubuntu1804
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] distarch: x86_64
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] target_arch: x86_64
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] options: {}
2020-01-09T11:25:45.987+0100 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] now exiting
2020-01-09T11:25:45.987+0100 I CONTROL [initandlisten] shutting down with code:48
sudo mongo
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("8e813fc2-049c-440d-83ce-0b1d8516c4d0") }
MongoDB server version: 4.2.2
Server has startup warnings:
2020-01-09T11:21:43.352+0100 I STORAGE [initandlisten]
2020-01-09T11:21:43.352+0100 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-01-09T11:21:43.352+0100 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-01-09T11:21:44.848+0100 I CONTROL [initandlisten]
2020-01-09T11:21:44.848+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-01-09T11:21:44.848+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-01-09T11:21:44.848+0100 I CONTROL [initandlisten]
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
So something weird is happening here, it doesn't find the database from the project and I have no clue why. As far as I can see, it creates a new database including my system details.
How can I fix this please and connect to the project database? I can't move further until I do.
it's been resolved. First I found out I didn't need to have the mongod service running locally because mongo was already included in the docker container. But actually this wasn't a database issue at all. There were a few things going wrong like there was a proxy but the command had been changed to execute the connection, endpoints were on localhost but weren't supposed to be, and the content I was expecting to see had been hidden by a careless push from another developer. Fun times! But we can move on now. Thanks to the people who tried to help!

Connect failed to mongodb shell

I have installed mongo, run the shell success in couple of time, then I try to add:
security:
authorization: disabled
because I want to add user Admin to admin db. After that, I can not access the mongo shell, this error show up when run command mongo
MongoDB shell version v3.6.2
connecting to: mongodb://127.0.0.1:27017
2018-02-09T09:34:48.769+0700 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-02-09T09:34:48.769+0700 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
And here is few last lines of the log file after disable authorization, even when enable it again, thing doesn't work /var/log/mongodb/mongod.log
2018-02-09T09:33:00.843+0700 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-09T09:33:00.843+0700 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-02-09T09:33:00.843+0700 I CONTROL [initandlisten]
2018-02-09T09:33:00.847+0700 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
2018-02-09T09:33:00.847+0700 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-02-09T09:33:00.847+0700 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2018-02-09T09:33:00.847+0700 I REPL [initandlisten] shutdown: removing all drop-pending collections...
2018-02-09T09:33:00.847+0700 I REPL [initandlisten] shutdown: removing checkpointTimestamp collection...
2018-02-09T09:33:00.848+0700 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2018-02-09T09:33:00.848+0700 I STORAGE [initandlisten] shutdown: final commit...
2018-02-09T09:33:00.849+0700 I JOURNAL [initandlisten] journalCleanup...
2018-02-09T09:33:00.849+0700 I JOURNAL [initandlisten] removeJournalFiles
2018-02-09T09:33:00.876+0700 I JOURNAL [initandlisten] old journal file /var/lib/mongodb/journal/j._0 will be reused as /var/lib/mongodb/journal/prealloc.0
2018-02-09T09:33:00.899+0700 I JOURNAL [initandlisten] Terminating durability thread ...
2018-02-09T09:33:00.950+0700 I JOURNAL [journal writer] Journal writer thread stopped
2018-02-09T09:33:00.950+0700 I JOURNAL [durability] Durability thread stopped
2018-02-09T09:33:00.950+0700 I STORAGE [initandlisten] shutdown: closing all files...
2018-02-09T09:33:00.953+0700 I STORAGE [initandlisten] closeAllFiles() finished
2018-02-09T09:33:00.953+0700 I STORAGE [initandlisten] shutdown: removing fs lock...
2018-02-09T09:33:00.953+0700 I CONTROL [initandlisten] now exiting
2018-02-09T09:33:00.953+0700 I CONTROL [initandlisten] shutting down with code:62
I tried to run sudo service mongod restart but doesn't work.
So can you give me some advices for this problem, thanks
Is seems that mongod can't start because your system has updated mongodb from version < 3.4 to 3.6 as it stated in the log: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6
You need to downgrade mongodb to 3.4, then sudo service mongod start to trigger the db migration to 3.4.
I just try to run this command and it works for me brew services start mongodb
Cheers.

Having trouble installing and using mongodb. on my macosx and a readonly /data/db

I want to install Mongodb for my next online web course but the thing is I'm having so much issues. I have been installing and uninstall mongodb so many times I think it's conflicting with temp ... Can someone guide me to the process please, really would appreciate it.
The error when running mongodb:
017-07-02T10:31:41.547-0400 I STORAGE [initandlisten] exception in
initAndListen: 20 Attempted to create a lock file on a read-only
directory: /data/db, terminating 2017-07-02T10:31:41.547-0400 I
NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-07-02T10:31:41.547-0400 I NETWORK [initandlisten] shutdown: going
to flush diaglog... 2017-07-02T10:31:41.547-0400 I CONTROL
[initandlisten] now exiting 2017-07-02T10:31:41.547-0400 I CONTROL
[initandlisten] shutting down with code:100 –
I tried installing it on homebrew , nothing happen, I tried installing it manually still having troubles.. I know my basic like cd,ls,rm,pwd,touch, when using the terminal, If theres process that i can wipe everything associate with mangodb in my Macbook and install it again i have no problem.
found out that /data/db is readonly
MongoDB is already installed but you have some issue launching it.
017-07-02T10:31:41.547-0400 I STORAGE [initandlisten] exception in
initAndListen: 20 Attempted to create a lock file on a read-only
directory: /data/db, terminating 2017-07-02T10:31:41.547-0400 I
NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-07-02T10:31:41.547-0400 I NETWORK [initandlisten] shutdown: going
to flush diaglog... 2017-07-02T10:31:41.547-0400 I CONTROL
[initandlisten] now exiting 2017-07-02T10:31:41.547-0400 I CONTROL
[initandlisten] shutting down with code:100 –
Change the permission of /data/db
sudo chown -R `id -un` /data/db
Now you should start the daemon without problem:mongod
then connect with your mongo client by typing. mongo
ok.. then got this. 2017-07-02T10:50:39.069-0400 I CONTROL
[initandlisten] options: { repair: true, storage: { dbPath: "/data/db"
} } 2017-07-02T10:50:39.069-0400 W - [initandlisten] Detected unclean
shutdown - /data/db/mongod.lock is not empty.
2017-07-02T10:50:39.069-0400 E NETWORK [initandlisten] Failed to
unlink socket file /tmp/mongodb-27017.sock Permission denied
2017-07-02T10:50:39.069-0400 I - [initandlisten] Fatal Assertion 28578
at src/mongo/util/net/listen.cpp 195 2017-07-02T10:50:39.070-0400 I -
[initandlisten] ***aborting after fassert() failure
your /tmp is maybe not readable, try:
chmod 1777 /tmp

The MongoDB service terminated with service-specific error Cannot create another system semaphore

I am using MongoDB version 3.0. I have installed mongodb as windows service which was working all this while. Now suddenly, the service does not start & the event logs shows this error The MongoDB service terminated with service-specific error Cannot create another system semaphore.
I am not sure how can I handle this error message.
I am not sure if its helpful but some of other services on my windows 2008 server also stopped to start on their own.
One of the windows service gives Not enough storage is available to proceess this request error.
First find your mongod.cfg file (for me in C:\Program Files\MongoDB 2.6 Standard)
#where to log
logpath=D:\MongoDatas\log\mongod.log
Then have a look at the last lines of you log file.
As suggested by JPBlanc, I looked at the log and found following entries:
2015-10-06T11:17:48.403-0400 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data files
2015-10-06T11:17:48.403-0400 I CONTROL Trying to start Windows service 'MongoDB'
2015-10-06T11:17:48.403-0400 I STORAGE Service running
2015-10-06T11:17:48.423-0400 I JOURNAL [initandlisten] journal dir=C:\Program Files\MongoDB\data\db\journal
2015-10-06T11:17:48.424-0400 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-10-06T11:17:48.425-0400 I JOURNAL [initandlisten]
2015-10-06T11:17:48.425-0400 E JOURNAL [initandlisten] Insufficient free space for journal files
2015-10-06T11:17:48.425-0400 I JOURNAL [initandlisten] Please make at least 3379MB available in C:\Program Files\MongoDB\data\db\journal or use --smallfiles
2015-10-06T11:17:48.425-0400 I JOURNAL [initandlisten]
2015-10-06T11:17:48.428-0400 I STORAGE [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2015-10-06T11:17:48.429-0400 I CONTROL [serviceStopWorker] now exiting
2015-10-06T11:17:48.429-0400 I NETWORK [serviceStopWorker] shutdown: going to close listening sockets...
2015-10-06T11:17:48.429-0400 I NETWORK [serviceStopWorker] shutdown: going to flush diaglog...
2015-10-06T11:17:48.429-0400 I NETWORK [serviceStopWorker] shutdown: going to close sockets...
2015-10-06T11:17:48.429-0400 I STORAGE [serviceStopWorker] shutdown: waiting for fs preallocator...
2015-10-06T11:17:48.429-0400 I STORAGE [serviceStopWorker] shutdown: final commit...
2015-10-06T11:17:48.429-0400 I STORAGE [serviceStopWorker] shutdown: closing all files...
2015-10-06T11:17:48.429-0400 I STORAGE [serviceStopWorker] closeAllFiles() finished
2015-10-06T11:17:48.429-0400 I CONTROL [serviceStopWorker] dbexit: rc: 49
It looks like space issue on the drive I was using
I have encountered a similar issue as bellow:
The Apache Tomcat 8.5 Tomcat8 service terminated with service-specific error Incorrect function.
And I found there is a error message in tomcat log:
[error] [ 3304] Failed creating java C:\Program Files\Java\jre1.8.0_101\bin\server\jvm.dll
After fixing this error, we can start tomcat normally.
Just FYI.
Make sure data directories and log directories are created as specified in mongodb.cfg file or mongo DB configuration file. In my case, I was missing one of the files. For more information please visit : https://www.mongodb.com/docs/manual/reference/configuration-options/

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.