MongoDB MMS replica set fails to restart - mongodb

I have a MMS replica set deployed with 3 instances. It was working fine until I shut it down this morning in order to do some changes and restarted it. From logs, it feels that there was an unclean shutdown of replica set. The mongod server on primary is failing to start now.
Here are the full logs
2015-08-20T07:08:41.389+0000 W - [initandlisten] Detected unclean shutdown - /data/XXXXXXXXX/mongod.lock is not empty.
2015-08-20T07:08:41.406+0000 I JOURNAL [initandlisten] journal dir=/data/XXXXXXXXX/journal
2015-08-20T07:08:41.406+0000 I JOURNAL [initandlisten] recover begin
2015-08-20T07:08:41.406+0000 I JOURNAL [initandlisten] info no lsn file in journal/ directory
2015-08-20T07:08:41.406+0000 I JOURNAL [initandlisten] recover lsn: 0
2015-08-20T07:08:41.406+0000 I JOURNAL [initandlisten] recover /data/XXXXXXXXX/journal/j._0
2015-08-20T07:08:41.407+0000 I JOURNAL [initandlisten] recover cleaning up
2015-08-20T07:08:41.407+0000 I JOURNAL [initandlisten] removeJournalFiles
2015-08-20T07:08:41.641+0000 I JOURNAL [initandlisten] recover done
2015-08-20T07:08:41.641+0000 I JOURNAL [initandlisten] preallocating a journal file /data/XXXXXXXXXXX/journal/prealloc.0
2015-08-20T07:08:44.074+0000 I - [initandlisten] File Preallocator Progress: 744488960/1073741824 69%
2015-08-20T07:08:47.176+0000 I - [initandlisten] File Preallocator Progress: 901775360/1073741824 83%
2015-08-20T07:08:50.274+0000 I - [initandlisten] File Preallocator Progress: 1027604480/1073741824 95%
2015-08-20T07:09:09.057+0000 I JOURNAL [durability] Durability thread started
2015-08-20T07:09:09.057+0000 I JOURNAL [journal writer] Journal writer thread started
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] MongoDB starting : pid=25507 port=27000 dbpath=/data/XXXXXXXXXXXXX 64-bit host=CH$
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] db version v3.0.2
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] git version: 6201872043ecbbc0a4cc169b5482dcf385fc464f
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] build info: Linux ip-10-229-1-2 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 U$
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] allocator: tcmalloc
2015-08-20T07:09:09.060+0000 I CONTROL [initandlisten] options: { config: "/data/XXXXXXXXXXXX/automation-mongod.conf", net: { port: 270$
2015-08-20T07:09:09.074+0000 I - [initandlisten] Invariant failure _name == nsToDatabaseSubstring( ns ) src/mongo/db/catalog/database.c$
2015-08-20T07:09:09.091+0000 I CONTROL [initandlisten]
0xf4f859 0xef0031 0xed4b52 0x91e106 0x91e18f 0x920033 0x922cb0 0x808701 0x7d4ba4 0x7f0503489ec5 0x805d17
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"400000","o":"B4F859"},{"b":"400000","o":"AF0031"},{"b":"400000","o":"AD4B52"},{"b":"400000","o":"51E106"},{"b":"400000","o$
mongod(_ZN5mongo15printStackTraceERSo+0x29) [0xf4f859]
mongod(_ZN5mongo10logContextEPKc+0xE1) [0xef0031]
mongod(_ZN5mongo15invariantFailedEPKcS1_j+0xB2) [0xed4b52]
mongod(_ZNK5mongo8Database13getCollectionERKNS_10StringDataE+0x36) [0x91e106]
mongod(_ZN5mongo8Database30_getOrCreateCollectionInstanceEPNS_16OperationContextERKNS_10StringDataE+0x1F) [0x91e18f]
mongod(_ZN5mongo8DatabaseC1EPNS_16OperationContextERKNS_10StringDataEPNS_20DatabaseCatalogEntryE+0x1E3) [0x920033]
mongod(_ZN5mongo14DatabaseHolder6openDbEPNS_16OperationContextERKNS_10StringDataEPb+0x150) [0x922cb0]
mongod(_ZN5mongo14DatabaseHolder6openDbEPNS_16OperationContextERKNS_10StringDataEPb+0x150) [0x922cb0]
mongod(_ZN5mongo13initAndListenEi+0xC01) [0x808701]
mongod(main+0x134) [0x7d4ba4]
libc.so.6(__libc_start_main+0xF5) [0x7f0503489ec5]
mongod(+0x405D17) [0x805d17]
----- END BACKTRACE -----
2015-08-20T07:09:09.091+0000 I - [initandlisten]
***aborting after invariant() failure
Any idea how can I fix it? I have been trying to fix it since past 4 hours but nothing seems to be working.

So, it turned out that issue was in .ns file of one of the database. I had to delete that file and restart the server. Server started successfully however, the database whose .ns I deleted was lost.
For newbies in mongoDB .ns file is the namespace file that mongo creates for each database in its data (/data) directory.

Related

Why when i start mongod after installation it got stuck to [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>

yesterday when i was about to install mongodb, i created /data/db with the right permission and i typed mongod but it got stuck on [ftdc] Marking collection local.oplog.rs as collection version: since 1 hour, thanks if you take time to help me
I was having the same problem. Open a new terminal, cd into the same path and then run "mongo" command. Then it worked!
I think we have had the same problem and I found the solution for myself.
But I beg my pardon if I am wrong)
If you want to get access to Mongodb you have to type mongo instead of mongod.
I was doing a step by step tutorial on installation of MongoDB on Centos 7 and playing around with it.
At some point I've decided to shutdown the server with:
db.shutdownServer()
And after that I've had trouble starting/logging into the database with mongod.
But the thing is, that mongod starts the Mongodb server in your current terminal.
[root#ip-*-*-*-* tmp]# mongod
2020-06-09T19:52:14.630+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-06-09T19:52:14.632+0000 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] MongoDB starting : pid=27618 port=27017 dbpath=/data/db 64-bit host=ip-*-*-*-*.eu-central-1.compute.internal
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] db version v4.2.7
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] modules: none
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] build environment:
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] distmod: rhel70
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] distarch: x86_64
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2020-06-09T19:52:14.633+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-06-09T19:52:14.633+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=256M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-06-09T19:52:15.356+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:356822][27618:0x7f9b34a81c40], txn-recover: Recovering log 6 through 7
2020-06-09T19:52:15.412+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:412272][27618:0x7f9b34a81c40], txn-recover: Recovering log 7 through 7
2020-06-09T19:52:15.500+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:500634][27618:0x7f9b34a81c40], txn-recover: Main recovery loop: starting at 6/22528 to 7/256
2020-06-09T19:52:15.609+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:609015][27618:0x7f9b34a81c40], txn-recover: Recovering log 6 through 7
2020-06-09T19:52:15.672+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:672877][27618:0x7f9b34a81c40], txn-recover: Recovering log 7 through 7
2020-06-09T19:52:15.727+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:727038][27618:0x7f9b34a81c40], txn-recover: Set global recovery timestamp: (0, 0)
2020-06-09T19:52:15.735+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-06-09T19:52:15.739+0000 I STORAGE [initandlisten] Timestamp monitor starting
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.743+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-06-09T19:52:15.744+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
2020-06-09T19:52:15.744+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-06-09T19:52:15.745+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-06-09T19:52:15.746+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-06-09T19:52:15.746+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2020-06-09T19:52:15.748+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-06-09T19:52:15.749+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-06-09T19:52:15.749+0000 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock
2020-06-09T19:52:15.749+0000 I NETWORK [listener] Listening on 127.0.0.1
2020-06-09T19:52:15.749+0000 I NETWORK [listener] waiting for connections on port 27017
2020-06-09T19:52:16.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
And I just got stuck at this point and pressed ctrl+C
2020-06-09T19:56:26.172+0000 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2020-06-09T19:56:26.172+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2020-06-09T19:56:26.176+0000 I NETWORK [listener] removing socket file: /tmp/mongodb-27017.sock
2020-06-09T19:56:26.176+0000 I - [signalProcessingThread] Stopping further Flow Control ticket acquisitions.
2020-06-09T19:56:26.176+0000 I CONTROL [signalProcessingThread] Shutting down free monitoring
2020-06-09T19:56:26.176+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Deregistering all the collections
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Timestamp monitor shutting down
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Shutting down session sweeper thread
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Finished shutting down session sweeper thread
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Shutting down journal flusher thread
2020-06-09T19:56:26.264+0000 I STORAGE [signalProcessingThread] Finished shutting down journal flusher thread
2020-06-09T19:56:26.264+0000 I STORAGE [signalProcessingThread] Shutting down checkpoint thread
2020-06-09T19:56:26.264+0000 I STORAGE [signalProcessingThread] Finished shutting down checkpoint thread
2020-06-09T19:56:26.268+0000 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2020-06-09T19:56:26.268+0000 I CONTROL [signalProcessingThread] now exiting
2020-06-09T19:56:26.268+0000 I CONTROL [signalProcessingThread] shutting down with code:0
And at this point I realized that I had that fatal extra letter and I was able to access the database with
[root#ip-*-*-*-* tmp]# mongo
After many hours and few reinstalls, I decided to look and view if some files was "corrupt", I found that MongoDB doesn't delete its folder in /var/lib/, so I deleted it and when I reinstalled MongoDB again it worked like a charm.

Mongod error (installed with homebrew)

I have installed mongodb with
brew install mongodb
Created folder
mkdir -p /data/db
Handle permissions
sudo chown -R `id -un` /data/db
Run
mongod
Error log
2018-01-06T14:28:51.450+0100 I CONTROL [initandlisten] MongoDB starting : pid=6120 port=27017 dbpath=/data/db 64-bit host=Zigas-MBP-2
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] db version v3.6.1
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] git version: 025d4f4fe61efd1fb6f0005be20cb45a004093d1
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] allocator: system
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] modules: none
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] build environment:
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] distarch: x86_64
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-01-06T14:28:51.451+0100 I CONTROL [initandlisten] options: {}
2018-01-06T14:28:51.452+0100 I - [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
2018-01-06T14:28:51.470+0100 I JOURNAL [initandlisten] journal dir=/data/db/journal
2018-01-06T14:28:51.471+0100 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2018-01-06T14:28:51.494+0100 I JOURNAL [durability] Durability thread started
2018-01-06T14:28:51.494+0100 I JOURNAL [journal writer] Journal writer thread started
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten]
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten]
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** Remote systems will be unable toconnect to this server.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-01-06T14:28:51.495+0100 I CONTROL [initandlisten]
2018-01-06T14:28:51.762+0100 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-01-06T14:28:51.762+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-01-06T14:28:51.763+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2018-01-06T14:28:51.763+0100 I REPL [initandlisten] shutdown: removing all drop-pending collections...
2018-01-06T14:28:51.763+0100 I REPL [initandlisten] shutdown: removing checkpointTimestamp collection...
2018-01-06T14:28:51.763+0100 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2018-01-06T14:28:51.763+0100 I STORAGE [initandlisten] shutdown: final commit...
2018-01-06T14:28:51.770+0100 I JOURNAL [initandlisten] journalCleanup...
2018-01-06T14:28:51.770+0100 I JOURNAL [initandlisten] removeJournalFiles
2018-01-06T14:28:51.770+0100 I JOURNAL [initandlisten] old journal file will be removed: /data/db/journal/j._0
2018-01-06T14:28:51.771+0100 I JOURNAL [initandlisten] Terminating durability thread ...
2018-01-06T14:28:51.870+0100 I JOURNAL [journal writer] Journal writer thread stopped
2018-01-06T14:28:51.870+0100 I JOURNAL [durability] Durability thread stopped
2018-01-06T14:28:51.870+0100 I STORAGE [initandlisten] shutdown: closing all files...
2018-01-06T14:28:51.883+0100 I STORAGE [initandlisten] closeAllFiles() finished
2018-01-06T14:28:51.883+0100 I STORAGE [initandlisten] shutdown: removing fs lock...
2018-01-06T14:28:51.883+0100 I CONTROL [initandlisten] now exiting
2018-01-06T14:28:51.883+0100 I CONTROL [initandlisten] shutting down with code:62
Any help would be apprichiated.
2018-01-06T14:28:51.762+0100 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.
This is the fault error in your log.
So I guess you have some 3.4 data in your /data/db.
If you want a clean installation, just remove the contents of /data/db and restart mongod
or
Get a 3.4 mongod
Ref: https://docs.mongodb.com/manual/release-notes/3.6-upgrade-standalone/
The error is telling you that you have mongo 3.4 data inside /data/db but you have version 3.6 of Mongo installed.
To fix this you can use one of the options listed below...
Remove the contents of /data/db and restart mongod. This should probably be backed up or you'll lose your data.
Install mongodb 3.4 you can check if you previously installed it using brew list --versions mongodb then if a 3.4.* version comes up, 3.4.10 for example use brew switch mongodb 3.4.10 to move back to that version. If you never had the version installed see this answer to install the older version Homebrew install specific version of formula?
Use #2 to move back to 3.4 then go into mongo shell using mongo and run db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ). Exit the mongo shell and use the brew switch command to switch back to 3.6.

MongoDB returning exit code 49

I installed mongodb and then I created a service to run it.
Starting the service works without problem but while trying to shutdown it, I get an error code by windows. I checked the log file and this is what I get:
2017-02-23T08:36:51.518+0100 I CONTROL [serviceStopWorker] shutting down with code:49
(Translation)
Error 1067: the process terminated unexpectedly
Service path:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\3.4\bin\mongod.cfg" --service
mongodb.cfg
systemLog:
destination: file
path: "C:\\data\\log\\mongod.log"
storage:
dbPath: "C:\\data\\db"
I tried to find the error codes but it doesn't appear.
https://docs.mongodb.com/manual/reference/exit-codes/
The only reference I could find is this. A test with questions/answers about exit codes. (Question #7)
http://www.sanfoundry.com/mongodb-questions-answers-exit-codes-statutes/
7. 49 code is returned by mongod from _________ Service control Manager.
a) Linux
b) Windows
c) Ubuntu
d) All of the mentioned
View Answer
Answer:a
Explanation:Custom read preferences and write concerns evaluate tags sets in different ways.
But I am on a Windows 7 machine. So that's quite odd.
Windows 7 x64 SP1
MongoDB 3.4.2
Any idea?
LOG
2017-02-23T08:36:48.484+0100 I CONTROL [main] Trying to start Windows service 'MongoDB'
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] MongoDB starting : pid=17856 port=27017 dbpath=C:\data\db 64-bit host=FRAmdsWS430
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] db version v3.4.2
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] allocator: tcmalloc
2017-02-23T08:36:48.485+0100 I CONTROL [initandlisten] modules: none
2017-02-23T08:36:48.486+0100 I CONTROL [initandlisten] build environment:
2017-02-23T08:36:48.486+0100 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-02-23T08:36:48.486+0100 I CONTROL [initandlisten] distarch: x86_64
2017-02-23T08:36:48.486+0100 I CONTROL [initandlisten] target_arch: x86_64
2017-02-23T08:36:48.486+0100 I CONTROL [initandlisten] options: { config: "C:\Program Files\MongoDB\Server\3.4\bin\mongod.cfg", service: true, storage: { dbPath: "C:\data\db" }, systemLog: { destination: "file", path: "C:\data\log\mongod.log" } }
2017-02-23T08:36:48.488+0100 I - [initandlisten] Detected data files in C:\data\db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
2017-02-23T08:36:48.497+0100 I JOURNAL [initandlisten] journal dir=C:\data\db\journal
2017-02-23T08:36:48.497+0100 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2017-02-23T08:36:48.636+0100 I JOURNAL [durability] Durability thread started
2017-02-23T08:36:48.636+0100 I JOURNAL [journal writer] Journal writer thread started
2017-02-23T08:36:48.693+0100 I CONTROL [initandlisten]
2017-02-23T08:36:48.693+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-02-23T08:36:48.693+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-02-23T08:36:48.693+0100 I CONTROL [initandlisten]
2017-02-23T08:36:48.938+0100 W FTDC [initandlisten] Failed to initialize Performance Counters for FTDC: WindowsPdhError: PdhExpandCounterPathW failed with 'Das angegebene Objekt wurde nicht auf dem Computer gefunden.' for counter '\Memory\Available Bytes'
2017-02-23T08:36:48.938+0100 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2017-02-23T08:36:48.940+0100 I NETWORK [thread1] waiting for connections on port 27017
2017-02-23T08:36:48.940+0100 I STORAGE [initandlisten] Service running
2017-02-23T08:36:51.412+0100 I CONTROL [serviceShutdown] got SERVICE_CONTROL_STOP request from Windows Service Control Manager, will terminate after current cmd ends
2017-02-23T08:36:51.412+0100 I NETWORK [serviceShutdown] shutdown: going to close listening sockets...
2017-02-23T08:36:51.412+0100 I NETWORK [serviceShutdown] closing listening socket: 456
2017-02-23T08:36:51.413+0100 I NETWORK [serviceShutdown] shutdown: going to flush diaglog...
2017-02-23T08:36:51.413+0100 I FTDC [serviceShutdown] Shutting down full-time diagnostic data capture
2017-02-23T08:36:51.413+0100 I STORAGE [serviceShutdown] shutdown: waiting for fs preallocator...
2017-02-23T08:36:51.413+0100 I STORAGE [serviceShutdown] shutdown: final commit...
2017-02-23T08:36:51.438+0100 I JOURNAL [serviceShutdown] journalCleanup...
2017-02-23T08:36:51.439+0100 I JOURNAL [serviceShutdown] removeJournalFiles
2017-02-23T08:36:51.439+0100 I JOURNAL [serviceShutdown] old journal file will be removed: C:\data\db\journal\j._0
2017-02-23T08:36:51.439+0100 I JOURNAL [serviceShutdown] Terminating durability thread ...
2017-02-23T08:36:51.516+0100 I JOURNAL [journal writer] Journal writer thread stopped
2017-02-23T08:36:51.516+0100 I JOURNAL [durability] Durability thread stopped
2017-02-23T08:36:51.516+0100 I STORAGE [serviceShutdown] shutdown: closing all files...
2017-02-23T08:36:51.518+0100 I STORAGE [serviceShutdown] closeAllFiles() finished
2017-02-23T08:36:51.518+0100 I STORAGE [serviceShutdown] shutdown: removing fs lock...
2017-02-23T08:36:51.518+0100 I CONTROL [serviceShutdown] now exiting
2017-02-23T08:36:51.518+0100 I CONTROL [serviceStopWorker] shutting down with code:49
This seems to be a bug introduced in MongoDB version 3.4.2. Check out https://jira.mongodb.org/browse/SERVER-6065

Mongo DB can't start, keeps quitting on me

I am a total mongo newbie who is very confused, frustrated and frankly lost...
I have tried installing / uninstalling mongo, then reinstalling. AT one point it seemed to be working as I followed a tutorial but ultimately wouldn't after I returned to use it in a node app I am trying to create. Now that I have it installed I created the /data/db but it keeps failing when I go to run "mongod"
name$ mongod
2015-06-28T15:13:34.503-0400 E NETWORK [initandlisten] listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2015-06-28T15:13:34.503-0400 E NETWORK [initandlisten] addr already in use
2015-06-28T15:13:34.513-0400 I JOURNAL [initandlisten] journal dir=/data/db/journal
2015-06-28T15:13:34.513-0400 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-06-28T15:13:34.541-0400 I JOURNAL [durability] Durability thread started
2015-06-28T15:13:34.541-0400 I JOURNAL [journal writer] Journal writer thread started
2015-06-28T15:13:34.541-0400 I CONTROL [initandlisten] MongoDB starting : pid=4041 port=27017 dbpath=/data/db 64-bit host=Vickens-MBP.home
2015-06-28T15:13:34.541-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-06-28T15:13:34.541-0400 I CONTROL [initandlisten]
2015-06-28T15:13:34.541-0400 I CONTROL [initandlisten]
2015-06-28T15:13:34.541-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-06-28T15:13:34.542-0400 I CONTROL [initandlisten] db version v3.0.4
2015-06-28T15:13:34.542-0400 I CONTROL [initandlisten] git version: nogitversion
2015-06-28T15:13:34.542-0400 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-06-28T15:13:34.542-0400 I CONTROL [initandlisten] allocator: system
2015-06-28T15:13:34.542-0400 I CONTROL [initandlisten] options: {}
2015-06-28T15:13:34.551-0400 I CONTROL [initandlisten] now exiting
2015-06-28T15:13:34.551-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2015-06-28T15:13:34.551-0400 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2015-06-28T15:13:34.551-0400 I NETWORK [initandlisten] shutdown: going to close sockets...
2015-06-28T15:13:34.551-0400 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2015-06-28T15:13:34.552-0400 I STORAGE [initandlisten] shutdown: final commit...
2015-06-28T15:13:34.555-0400 I JOURNAL [initandlisten] journalCleanup...
2015-06-28T15:13:34.555-0400 I JOURNAL [initandlisten] removeJournalFiles
2015-06-28T15:13:34.556-0400 I JOURNAL [initandlisten] Terminating durability thread ...
2015-06-28T15:13:34.663-0400 I JOURNAL [journal writer] Journal writer thread stopped
2015-06-28T15:13:34.663-0400 I JOURNAL [durability] Durability thread stopped
2015-06-28T15:13:34.664-0400 I STORAGE [initandlisten] shutdown: closing all files...
2015-06-28T15:13:34.665-0400 I STORAGE [initandlisten] closeAllFiles() finished
2015-06-28T15:13:34.665-0400 I STORAGE [initandlisten] shutdown: removing fs lock...
2015-06-28T15:13:34.665-0400 I CONTROL [initandlisten] dbexit: rc: 48
Looks like something is running on 0.0.0.0:27017,
run command to kill that process first
kill $(lsof -t -i:27017)
then start you mongo server
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start

MongoDB --dbpath giving access to old data

I have mongo installed on my local machine. When I start the database by running mongod I got this error (that is fairly common, and this site has solutions to workarounds):
$ mongod
mongod --help for help and startup options
2015-01-01T22:31:17.350-0600 [initandlisten] MongoDB starting : pid=2835 port=27017 dbpath=/data/db 64-bit host=hermes
2015-01-01T22:31:17.351-0600 [initandlisten] db version v2.6.4
2015-01-01T22:31:17.351-0600 [initandlisten] git version: nogitversion
2015-01-01T22:31:17.351-0600 [initandlisten] build info: Darwin minimavericks.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-01-01T22:31:17.351-0600 [initandlisten] allocator: tcmalloc
2015-01-01T22:31:17.351-0600 [initandlisten] options: {}
2015-01-01T22:31:17.351-0600 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
2015-01-01T22:31:17.351-0600 [initandlisten] dbexit:
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: going to close listening sockets...
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: going to flush diaglog...
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: going to close sockets...
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: waiting for fs preallocator...
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: lock for final commit...
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: final commit...
2015-01-01T22:31:17.351-0600 [initandlisten] shutdown: closing all files...
2015-01-01T22:31:17.352-0600 [initandlisten] closeAllFiles() finished
2015-01-01T22:31:17.355-0600 [initandlisten] dbexit: really exiting now
I created a directory in my development environment at /my/curent/directory/data/db and started mongo again with $ mongod --dbpath /my/curent/directory/data/db, this time producing:
2015-01-01T22:32:31.282-0600 [initandlisten] options: { storage: { dbPath: "./data/db" } }
2015-01-01T22:32:31.319-0600 [initandlisten] journal dir=./data/db/journal
2015-01-01T22:32:31.320-0600 [initandlisten] recover : no journal files present, no recovery needed
2015-01-01T22:32:31.383-0600 [FileAllocator] allocating new datafile ./data/db/local.ns, filling with zeroes...
2015-01-01T22:32:31.383-0600 [FileAllocator] creating directory ./data/db/_tmp
2015-01-01T22:32:31.482-0600 [FileAllocator] done allocating datafile ./data/db/local.ns, size: 16MB, took 0.098 secs
2015-01-01T22:32:31.842-0600 [FileAllocator] allocating new datafile ./data/db/local.0, filling with zeroes...
2015-01-01T22:32:32.756-0600 [FileAllocator] done allocating datafile ./data/db/local.0, size: 64MB, took 0.914 secs
2015-01-01T22:32:33.215-0600 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2015-01-01T22:32:33.216-0600 [initandlisten] added index to empty collection
2015-01-01T22:32:33.216-0600 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0 reslen:37 1852ms
2015-01-01T22:32:33.216-0600 [initandlisten] waiting for connections on port 27017
2015-01-01T22:33:31.402-0600 [clientcursormon] mem (MB) res:33 virt:2635
2015-01-01T22:33:31.402-0600 [clientcursormon] mapped (incl journal view):160
2015-01-01T22:33:31.402-0600 [clientcursormon] connections:0
It's great. Using the mongo shell, I can access my collections that I was working with in this directory, but I can also see all of my other databases from weeks prior (when this directory did not exist) using show dbs. What purpose does the --dbpath option serve if not to isolate where data is stored? Is something weird happening here?
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db.
To use an alternate dbpath, specify the path in the configuration file (e.g. C:\Program Files\MongoDB\mongod.cfg) or on the command line with the --dbpath option.
Read more about MongoDB Installation
If you are using windows then create data\db folder under C drive.
If you are using your own directory for data then pass full path of the folder as --dbpath argument value.
If MongoDB’s default data directory path "\data\db" is correct but accessing old data means just check your Task Manager.
End all mongo command and restart your mongodb. I tried it, working well