JeromeDL30
JeromeDL30

Reputation: 799

MongoDB service would not start

I installed the MongoDB using the following commands:

sudo apt update
sudo apt install mongodb

and when I checked the status of the service:

mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-11-06 10:25:11 PST; 54min ago
     Docs: man:mongod(1)
  Process: 1030 ExecStart=/usr/bin/mongod --unixSocketPrefix=${SOCKETPATH} --config ${CONF} $DAEMON_OPTS (code=exited, status=100)
 Main PID: 1030 (code=exited, status=100)

Nov 06 10:25:09 JDL systemd[1]: Started An object/document-oriented database.
Nov 06 10:25:11 JDL systemd[1]: mongodb.service: Main process exited, code=exited, status=100/n/a
Nov 06 10:25:11 JDL systemd[1]: mongodb.service: Failed with result 'exit-code'.

I tried creating /data/db and changed its permission. I was also able to run the mongod command and even restarted the PC. I also tried deleting lock file and did repair in MongoDB but the result was still the same.

How can I fix this one? I tried to search for solutions but none of it seemed to work for me.

Additional Info

running sudo tail -n 20 /var/log/mongodb/mongod.log showed me this

2019-11-05T22:17:52.153+0800 I CONTROL  [initandlisten] build environment:
2019-11-05T22:17:52.153+0800 I CONTROL  [initandlisten]     distarch: x86_64
2019-11-05T22:17:52.153+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2019-11-05T22:17:52.153+0800 I CONTROL  [initandlisten] options: { config: "./etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2019-11-05T22:17:52.154+0800 I -        [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-11-05T22:17:52.154+0800 I STORAGE  [initandlisten] 
2019-11-05T22:17:52.154+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-11-05T22:17:52.154+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-11-05T22:17:52.154+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=5431M,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),
2019-11-05T22:17:52.723+0800 E STORAGE  [initandlisten] WiredTiger error (-31802) [1572963472:723937][2926:0x7f9a371b00c0], txn-recover: unsupported WiredTiger file version: this build  only supports versions up to 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error
2019-11-05T22:17:52.724+0800 E STORAGE  [initandlisten] WiredTiger error (0) [1572963472:724065][2926:0x7f9a371b00c0], txn-recover: WiredTiger is unable to read the recovery log.
2019-11-05T22:17:52.724+0800 E STORAGE  [initandlisten] WiredTiger error (0) [1572963472:724099][2926:0x7f9a371b00c0], txn-recover: This may be due to the log files being encrypted, being from an older version or due to corruption on disk
2019-11-05T22:17:52.724+0800 E STORAGE  [initandlisten] WiredTiger error (0) [1572963472:724124][2926:0x7f9a371b00c0], txn-recover: You should confirm that you have opened the database with the correct options including all encryption and compression options
2019-11-05T22:17:52.724+0800 E STORAGE  [initandlisten] WiredTiger error (-31802) [1572963472:724152][2926:0x7f9a371b00c0], txn-recover: Recovery failed: WT_ERROR: non-specific WiredTiger error
2019-11-05T22:17:52.759+0800 E -        [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 413
2019-11-05T22:17:52.759+0800 I STORAGE  [initandlisten] exception in initAndListen: Location28595: -31802: WT_ERROR: non-specific WiredTiger error, terminating
2019-11-05T22:17:52.759+0800 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-11-05T22:17:52.759+0800 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-05T22:17:52.759+0800 I CONTROL  [initandlisten] now exiting
2019-11-05T22:17:52.759+0800 I CONTROL  [initandlisten] shutting down with code:100

Upvotes: 0

Views: 3606

Answers (1)

Krunal Sonparate
Krunal Sonparate

Reputation: 1142

If you don't need database then remove all the files in database folder (in Ubuntu path will be /usr/lib/mongodb) using rm -rf /usr/lib/mongodb and if you require database then follow this steps: When you upgrade MongoDB Server, let's say from 3.4 to 3.6. You also need to set database feature compatibility version using this command before upgrading. This command must be run in MongoDB Server v3.4

db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

and then upgrade to the next major release. For eg., you must upgrade your MongoDB server from 3.4 to 3.6 not directly to 4.0 for more details follow MongoDB Docs

Upvotes: 1

Related Questions