I installed mongodb following this tutorial here, no errors during the installation but when I try to start the mongod server using this command sudo systemctl start m
The first thing, you should examine the mongo log. It should tell you what went wrong.
$ tail -n 100 /var/log/mongodb/mongod.log
This command will show last 100 lines of the log file which will point you to the exact problem.
For example, mine wasn't working because i was running a mongo
instance using the same port 27017
. when i ran another instance, the instance failed to load.
2018-05-11T19:03:49.102-0400 I CONTROL [initandlisten] MongoDB starting : pid=1247 port=27017 dbpath=/var/lib/mongodb 64-bit host=dev-hyuen
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] db version v3.2.20
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] git version: a7a144f40b70bfe290906eb33ff2714933544af8
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] allocator: tcmalloc
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] modules: none
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] build environment:
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] distmod: ubuntu1604
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] distarch: x86_64
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] target_arch: x86_64
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2018-05-11T19:03:49.124-0400 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 127.0.0.1:27017
2018-05-11T19:03:49.124-0400 E NETWORK [initandlisten] addr already in use
2018-05-11T19:03:49.124-0400 E STORAGE [initandlisten] Failed to set up sockets during startup.
2018-05-11T19:03:49.124-0400 I CONTROL [initandlisten] dbexit: rc: 48