mongod fails to start with error message "missing UUID" - mongodb

Mongod has been running as v4 for several months. It is used to record clinical data for patient with neurological diseases, and is essential to the drug trials.
This morning mongo crashed, and upon restarting, mongod refuses to start, on a collection that has a missing UUID. The message is cryptic, as this is not a 3.6 DB. Is there a way to proceed? The sensorTag collection is not really essential, and erasing it would be OK. Is there a way to get mongod to use the DB at all?
Here is the startup message:
2020-05-18T23:23:58.587+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] MongoDB starting : pid=1526 port=23417 dbpath=./db 64-bit host=retro-4-10-19
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] db version v4.0.18
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] git version: 6883bdfb8b8cff32176b1fd176df04da9165fd67
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] modules: none
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] build environment:
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] distmod: ubuntu1804
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] distarch: x86_64
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-05-18T23:23:58.590+0000 I CONTROL [initandlisten] options: { net: { bindIp: "127.0.0.1", port: 23417 }, storage: { dbPath: "./db" } }
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] Detected data files in ./db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten]
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-05-18T23:23:58.591+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=484M,cache_overflow=(file_max=0M),session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
2020-05-18T23:23:59.519+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:519947][1526:0x7fa98a9fca40], txn-recover: Main recovery loop: starting at 46/768 to 47/256
2020-05-18T23:23:59.635+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:635147][1526:0x7fa98a9fca40], txn-recover: Recovering log 46 through 47
2020-05-18T23:23:59.703+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:703356][1526:0x7fa98a9fca40], txn-recover: Recovering log 47 through 47
2020-05-18T23:23:59.767+0000 I STORAGE [initandlisten] WiredTiger message [1589844239:767605][1526:0x7fa98a9fca40], txn-recover: Set global recovery timestamp: 0
2020-05-18T23:23:59.794+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten]
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-05-18T23:23:59.807+0000 I CONTROL [initandlisten]
2020-05-18T23:23:59.823+0000 F CONTROL [initandlisten] ** IMPORTANT: Collection RetrotopeClinic.sensortags is missing an UUID. We expect all collections to have UUIDs starting in FCV 3.6. Please make sure the FCV is version 3.6 before attempting an upgrade to 4.0; see http://dochub.mongodb.org/core/4.0-upgrade-fcv for more details. If the FCV is already 3.6, please try --repair with a 3.6 binary or initial sync to fix the data files.
2020-05-18T23:23:59.823+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-18T23:23:59.823+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-23417.sock
2020-05-18T23:23:59.823+0000 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2020-05-18T23:23:59.823+0000 I STORAGE [initandlisten] Shutting down session sweeper thread
2020-05-18T23:23:59.823+0000 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2020-05-18T23:23:59.901+0000 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2020-05-18T23:24:00.088+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:88483][1526:0x7fa98a9fca40], txn-recover: Main recovery loop: starting at 47/2176 to 48/256
2020-05-18T23:24:00.190+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:190325][1526:0x7fa98a9fca40], txn-recover: Recovering log 47 through 48
2020-05-18T23:24:00.250+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:250635][1526:0x7fa98a9fca40], txn-recover: Recovering log 48 through 48
2020-05-18T23:24:00.302+0000 I STORAGE [initandlisten] WiredTiger message [1589844240:302709][1526:0x7fa98a9fca40], txn-recover: Set global recovery timestamp: 0
2020-05-18T23:24:00.477+0000 I STORAGE [initandlisten] shutdown: removing fs lock...
2020-05-18T23:24:00.477+0000 I CONTROL [initandlisten] now exiting
2020-05-18T23:24:00.477+0000 I CONTROL [initandlisten] shutting down with code:62
I did also run with the --repair flag: it said it repaied the sensorTag collection, but no, it didn't, and still failed:
020-05-19T00:09:27.800+0000 I STORAGE [initandlisten] Repairing collection StagServExpress.sensortags
2020-05-19T00:09:27.801+0000 I STORAGE [initandlisten] Verify succeeded on uri table:collection-22-4256855214379632921. Not salvaging.
2020-05-19T00:09:27.805+0000 I INDEX [initandlisten] build index on: StagServExpress.sensortags properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "StagServExpress.sensortags" }
2020-05-19T00:09:27.806+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 166 megabytes of RAM
2020-05-19T00:09:27.810+0000 I INDEX [initandlisten] build index on: StagServExpress.sensortags properties: { v: 2, unique: true, key: { UUID: 1 }, name: "UUID_1", ns: "StagServExpress.sensortags", background: true }
2020-05-19T00:09:27.810+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 166 megabytes of RAM
2020-05-19T00:09:27.813+0000 I INDEX [initandlisten] build index on: StagServExpress.sensortags properties: { v: 2, key: { nickname: 1 }, name: "nickname_1", ns: "StagServExpress.sensortags", background: true }
2020-05-19T00:09:27.813+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 166 megabytes of RAM

MongoDB 4.0.18 was released a month ago (April 13). You said:
Mongod has been running as v4 for several months.
Which version were you running for "several months" and how long have you been running 4.0.18 for?
Did you upgrade MongoDB at the same time as you experienced the crash?
Do you have backups?
Assuming you have a backup, reinstate the version of MongoDB that was in use prior to the crash and run it on the data directory as close to the crash as your backups allow.
The error message you are seeing was added in 4.0.13, so if you run 4.0.12 or earlier you shouldn't get this error (but I don't know if your data is corrupted and what other issues might exist).
Functionality does get backported to older versions, so it's possible there are older 4.0 servers that don't have the UUID that the current 4.0 is expecting because the changes were made in 4.0 (or 4.2) and backported to 3.6 but after 4.0.0 came out.

Related

MongoDB and WiredTiger compatibility issue

Today, my MongoDB container running on Google Kubernetes Engine suddently stopped working, and this is the generated log:
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=mongo-db-0
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] db version v3.6.20
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] git version: 39c200878284912f19553901a6fea4b31531a899
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] modules: none
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] build environment:
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] distarch: x86_64
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-09-30T07:01:42.782+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true } }
2020-09-30T07:01:42.782+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-09-30T07:01:42.783+0000 I STORAGE [initandlisten]
2020-09-30T07:01:42.783+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-09-30T07:01:42.783+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-09-30T07:01:42.783+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=334M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),compatibility=(release="3.0",require_max="3.0"),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2020-09-30T07:01:43.433+0000 E STORAGE [initandlisten] WiredTiger error (95) [1601449303:433554][1:0x7f9f6c49da40], wiredtiger_open: __wt_conn_compat_config, 226: Version incompatibility detected: required max of 3.0cannot be larger than saved release 3.3: Operation not supported Raw: [1601449303:433554][1:0x7f9f6c49da40], wiredtiger_open: __wt_conn_compat_config, 226: Version incompatibility detected: required max of 3.0cannot be larger than saved release 3.3: Operation not supported
2020-09-30T07:01:43.434+0000 E - [initandlisten] Assertion: 28595:95: Operation not supported src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 488
2020-09-30T07:01:43.434+0000 I STORAGE [initandlisten] exception in initAndListen: Location28595: 95: Operation not supported, terminating
2020-09-30T07:01:43.434+0000 F - [initandlisten] Invariant failure globalStorageEngine src/mongo/db/service_context_d.cpp 272
2020-09-30T07:01:43.435+0000 F - [initandlisten]
I tested older Mongo container versions but it didn't work. I had this problem in the past, and I was able to fix it by completly wiping the persistent storage, but unfortunatelly this time I cannot do this.
How do I solve this compatibility issue without wiping the storage data?
A stored WiredTiger version of 3.3 means the data files were written by a MongoDB version from 4.2.6 to 4.2.8.
One of those versions should be able to open those files.

Unable to connect with mongo db shell

After running mongod and mongo in terminal
$mongo
MongoDB shell version v4.2.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("707b65a3-c675-4b03-a386-21c5d589c05f") }
MongoDB server version: 4.2.6
and nothing happens! I am unable to create a new database. Please Help!
In another terminal
$ mongod
2020-06-28T20:52:27.841+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-06-28T20:52:28.502+0530 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] MongoDB starting : pid=14576 port=27017 dbpath=E:\data\db\ 64-bit host=BTL
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] db version v4.2.6
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] allocator: tcmalloc
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] modules: none
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] build environment:
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] distmod: 2012plus
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] distarch: x86_64
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] target_arch: x86_64
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] options: {}
2020-06-28T20:52:28.512+0530 W STORAGE [initandlisten] Detected unclean shutdown - E:\data\db\mongod.lock is not empty.
2020-06-28T20:52:28.514+0530 I STORAGE [initandlisten] Detected data files in E:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-06-28T20:52:28.514+0530 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
2020-06-28T20:52:28.514+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1491M,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-28T20:52:28.889+0530 I STORAGE [initandlisten] WiredTiger message [1593357748:888613][14576:140705565789264], txn-recover: Recovering log 3 through 4
2020-06-28T20:52:29.105+0530 I STORAGE [initandlisten] WiredTiger message [1593357749:104639][14576:140705565789264], txn-recover: Recovering log 4 through 4
2020-06-28T20:52:29.382+0530 I STORAGE [initandlisten] WiredTiger message [1593357749:381648][14576:140705565789264], txn-recover: Main recovery loop: starting at 3/5632 to 4/256
2020-06-28T20:52:29.885+0530 I STORAGE [initandlisten] WiredTiger message [1593357749:884866][14576:140705565789264], txn-recover: Recovering log 3 through 4
2020-06-28T20:52:30.476+0530 I STORAGE [initandlisten] WiredTiger message [1593357750:475971][14576:140705565789264], txn-recover: Recovering log 4 through 4
2020-06-28T20:52:30.693+0530 I STORAGE [initandlisten] WiredTiger message [1593357750:692960][14576:140705565789264], txn-recover: Set global recovery timestamp: (0, 0)
2020-06-28T20:52:33.168+0530 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-06-28T20:52:36.667+0530 I STORAGE [initandlisten] Timestamp monitor starting
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten]
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten]
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten]
2020-06-28T20:52:42.495+0530 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-06-28T20:52:44.701+0530 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
2020-06-28T20:52:45.029+0530 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-06-28T20:52:45.348+0530 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-06-28T20:52:47.258+0530 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-06-28T20:52:51.373+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'E:/data/db/diagnostic.data'
2020-06-28T20:52:51.410+0530 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-06-28T20:52:51.411+0530 I NETWORK [listener] Listening on 127.0.0.1
2020-06-28T20:52:51.411+0530 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-06-28T20:52:51.411+0530 I NETWORK [listener] waiting for connections on port 27017
2020-06-28T20:52:52.042+0530 I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
2020-06-28T20:52:52.520+0530 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>

Mongod exits with error code: 62 when attempting to start mongod

I tried to start mongod and got this error
forked process: 4271
ERROR: child process failed, exited with error number 62
To see additional information in this output, start without the "--fork" option.
I retried with sudo mongod and got this instead
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] MongoDB starting : pid=4275 port=27017 dbpath=/data/db 64-bit host=dhcp020-218-083.wireless.buffalo.edu
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] db version v4.2.1
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] allocator: system
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] modules: none
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] build environment:
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] distarch: x86_64
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] target_arch: x86_64
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] options: {}
2019-11-26T12:54:27.564-0500 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-11-26T12:54:27.564-0500 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,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],
2019-11-26T12:54:28.082-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:81997][4275:0x114a835c0], txn-recover: Recovering log 35 through 36
2019-11-26T12:54:28.131-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:131917][4275:0x114a835c0], txn-recover: Recovering log 36 through 36
2019-11-26T12:54:28.180-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:180756][4275:0x114a835c0], txn-recover: Main recovery loop: starting at 35/896 to 36/256
2019-11-26T12:54:28.259-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:259184][4275:0x114a835c0], txn-recover: Recovering log 35 through 36
2019-11-26T12:54:28.306-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:306249][4275:0x114a835c0], txn-recover: Recovering log 36 through 36
2019-11-26T12:54:28.345-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:345839][4275:0x114a835c0], txn-recover: Set global recovery timestamp: (0,0)
2019-11-26T12:54:28.399-0500 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-11-26T12:54:28.405-0500 I STORAGE [initandlisten] Timestamp monitor starting
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2019-11-26T12:54:28.407-0500 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-11-26T12:54:28.408-0500 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http://dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/4.0-upgrade-fcv.
2019-11-26T12:54:28.408-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-11-26T12:54:28.408-0500 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-26T12:54:28.408-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Deregistering all the collections
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-11-26T12:54:28.499-0500 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-11-26T12:54:28.576-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:576019][4275:0x114a835c0], txn-recover: Recovering log 36 through 37
2019-11-26T12:54:28.615-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:615152][4275:0x114a835c0], txn-recover: Recovering log 37 through 37
2019-11-26T12:54:28.666-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:666135][4275:0x114a835c0], txn-recover: Main recovery loop: starting at 36/2048 to 37/256
2019-11-26T12:54:28.744-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:744560][4275:0x114a835c0], txn-recover: Recovering log 36 through 37
2019-11-26T12:54:28.790-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:790388][4275:0x114a835c0], txn-recover: Recovering log 37 through 37
2019-11-26T12:54:28.831-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:831263][4275:0x114a835c0], txn-recover: Set global recovery timestamp: (0,0)
2019-11-26T12:54:28.964-0500 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-11-26T12:54:28.965-0500 I CONTROL [initandlisten] now exiting
2019-11-26T12:54:28.965-0500 I CONTROL [initandlisten] shutting down with code:62```
I already checked to see if I have a /data/db folder and I do, I tried to delete the data folder and recreate it with no luck. I checked on the forums and error code 62 means that the data/db folder is on a different version than the MongoDB installation, I'm not sure how I would go about fixing this error.

How to resolve featureCompatibilityVersion issue between MongoDB 3.6 and 4.2?

I recently uninstalled MongoDB 3.6 and then installed MongoDB 4.2. When I navigated to MongoDB/Server/4.2/bin and executed mongo, I got the following error message:
$ mongod
2019-10-22T21:16:36.723-0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] MongoDB starting : pid=9376 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-LF34G1M
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-10-22T21:16:37.217-0400 I CONTROL [initandlisten] db version v4.2.1
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] allocator: tcmalloc
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] modules: none
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] build environment:
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] distmod: 2012plus
2019-10-22T21:16:37.218-0400 I CONTROL [initandlisten] distarch: x86_64
2019-10-22T21:16:37.219-0400 I CONTROL [initandlisten] target_arch: x86_64
2019-10-22T21:16:37.219-0400 I CONTROL [initandlisten] options: {}
2019-10-22T21:16:37.230-0400 I STORAGE [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wire
dTiger'.
2019-10-22T21:16:37.231-0400 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1498M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threa
ds_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],
2019-10-22T21:16:37.295-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:294196][9376:140704250879568], txn-recover: Recovering log 22 through 23
2019-10-22T21:16:37.439-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:438812][9376:140704250879568], txn-recover: Recovering log 23 through 23
2019-10-22T21:16:37.561-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:560490][9376:140704250879568], txn-recover: Main recovery loop: starting at 22/896 to 23/256
2019-10-22T21:16:37.712-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:712086][9376:140704250879568], txn-recover: Recovering log 22 through 23
2019-10-22T21:16:37.807-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:806834][9376:140704250879568], txn-recover: Recovering log 23 through 23
2019-10-22T21:16:37.883-0400 I STORAGE [initandlisten] WiredTiger message [1571793397:882664][9376:140704250879568], txn-recover: Set global recovery timestamp: (0,0)
2019-10-22T21:16:37.934-0400 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-10-22T21:16:37.943-0400 I STORAGE [initandlisten] Timestamp monitor starting
2019-10-22T21:16:37.947-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.947-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-10-22T21:16:37.948-0400 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-10-22T21:16:37.949-0400 I CONTROL [initandlisten]
2019-10-22T21:16:37.959-0400 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-10-22T21:16:37.965-0400 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for ver
sion, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http:
//dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/
4.0-upgrade-fcv.
2019-10-22T21:16:37.965-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-10-22T21:16:37.966-0400 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-10-22T21:16:37.966-0400 I STORAGE [initandlisten] Deregistering all the collections
2019-10-22T21:16:37.966-0400 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-10-22T21:16:37.967-0400 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-10-22T21:16:37.967-0400 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-10-22T21:16:37.968-0400 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-10-22T21:16:37.968-0400 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-10-22T21:16:38.037-0400 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-10-22T21:16:38.037-0400 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-10-22T21:16:38.038-0400 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-10-22T21:16:38.038-0400 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-10-22T21:16:38.188-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:187822][9376:140704250879568], txn-recover: Recovering log 23 through 24
2019-10-22T21:16:38.273-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:272644][9376:140704250879568], txn-recover: Recovering log 24 through 24
2019-10-22T21:16:38.365-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:365403][9376:140704250879568], txn-recover: Main recovery loop: starting at 23/2048 to 24/256
2019-10-22T21:16:38.533-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:532944][9376:140704250879568], txn-recover: Recovering log 23 through 24
2019-10-22T21:16:38.642-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:642615][9376:140704250879568], txn-recover: Recovering log 24 through 24
2019-10-22T21:16:38.722-0400 I STORAGE [initandlisten] WiredTiger message [1571793398:722405][9376:140704250879568], txn-recover: Set global recovery timestamp: (0,0)
2019-10-22T21:16:39.004-0400 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-10-22T21:16:39.005-0400 I CONTROL [initandlisten] now exiting
2019-10-22T21:16:39.005-0400 I CONTROL [initandlisten] shutting down with code:62
The error which confuses me is:
UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'.
This does not seem to align with what I'm seeing below:
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "4.2" }, "ok" : 1 }
How am I able to fix this featureCompatibilityVersion issue?
The answer lies in the error message.
If the current featureCompatibilityVersion is below 4.0,
see the documentation on upgrading at
https://docs.mongodb.com/manual/release-notes/4.2/#upgrade-procedures
That page points out that if you have a version 3 installation, first you have to upgrade to 4.0. It doesn't help that on Macs, homebrew offers a mongodb-community installation that does not specify a version number. Currently, mongodb-community is 4.2.
What I did is:
brew services stop mongodb-community
brew uninstall mongodb-community
brew install mongodb-community#4.0
brew install mongodb-community-shell
brew services start mongodb-community#4.0
mongo
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
[ it gave: { "featureCompatibilityVersion" : { "version" : "3.6" }, "ok" : 1 } ]
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
ctrl-c
brew services stop mongodb-community#4.0
brew uninstall mongodb-community#4.0
brew uninstall mongodb-community-shell [you get a new one with the next step]
brew install mongodb-community
brew services start mongodb-community
Which doesn't exactly trip off the tongue but did work for me without too much trouble.
My database directory, C:\data\db\, still existed from when 3.6 was running. The directory kept its state even after 3.6 was uninstalled, and was still configured for 3.6.
After clearing the directory, re-running mongod a second time did not produce any errors.
Quick 2023 update:
You can't install mongodb-community#4.0 via brew anymore, so my advice is:
Download the required version (4.0) from https://www.mongodb.com/try/download/community
Extract the files and run the binary bin/mongod directly from the extracted directory (you may need to grant permissions in your OS).
Once it's running, make the adjustments outlined here: https://www.mongodb.com/docs/manual/release-notes/4.2-upgrade-standalone/
Once you have completed the instructions from the link above, shutdown the server.
Now run your newer version of mongod, it should work ok.
Hope this saves time to some people.

MongoDB server running, I get "mongo: command not found"

I`ve started mongoDB and it seems like its running fine, I think (see message below)? Then I open a new terminal window and I try to use the "mongo" command I get the following message:
-bash: mongo: command not found
When I try commands such as "use newtest", it says
-bash: use: command not found
My Path:
PATH=/Users/myname/.npm-global/bin:$PATH
Here is the message when I start mongoDB:
myname-MacBook-Air:~ myname$ mongod
I CONTROL [initandlisten] MongoDB starting : pid=581 port=27017 dbpath=/data/db 64-bit host=myname-MacBook-Air.local
I CONTROL [initandlisten] db version v3.6.2
I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
I CONTROL [initandlisten] allocator: system
I CONTROL [initandlisten] modules: none
I CONTROL [initandlisten] build environment:
I CONTROL [initandlisten] distarch: x86_64
I CONTROL [initandlisten] target_arch: x86_64
I CONTROL [initandlisten] options: {}
W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
I STORAGE [initandlisten] WiredTiger message [1519475976:405758][581:0x7fff95b02340], txn-recover: Main recovery loop: starting at 4/3200
I STORAGE [initandlisten] WiredTiger message [1519475976:408878][581:0x7fff95b02340], txn-recover: Recovering log 4 through 5
I STORAGE [initandlisten] WiredTiger message [1519475976:564148][581:0x7fff95b02340], txn-recover: Recovering log 5 through 5
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
I CONTROL [initandlisten]
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
I NETWORK [initandlisten] waiting for connections on port 27017
I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
What am I doing wrong here to start mongodB? Or am I misunderstanding it?
Thanks :)