GoormIDE | Can't run mongod in GoormIDE Container - mongodb

For context: I am creating a website in html+ejs+mongoose which I had created locally on my pc. Since I want to see the website running on another device besides my local computer, I uploaded the files on GitHub and then cloned it into an online IDE, in this case, GoormIDE, to do that.
As the title above had said, I can't run mongod in a container even though I have enabled mongoDB in the container setup. I created a file which is mongod which runs the code mongod --nojournal so that I will not have journal files in my directory. I kept receiving this error code:
2020-12-27T05:24:49.128+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] MongoDB starting : pid=802 port=27017 dbpath=/data/db 64-bit host=goorm
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] db version v4.0.22
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] git version: 1741806fb46c161a1d42870f6e98f5100d196315
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] modules: none
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] build environment:
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] distmod: ubuntu1804
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] distarch: x86_64
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] 1024 MB of memory available to the process out of 7771 MB total system memory
2020-12-27T05:24:49.135+0000 I CONTROL [initandlisten] options: { storage: { journal: { enabled: false } } }
2020-12-27T05:24:49.135+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file., terminating
2020-12-27T05:24:49.136+0000 I REPL [initandlisten] Stepping down the ReplicationCoordinator for shutdown, waitTime: 10000ms
2020-12-27T05:24:49.136+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-12-27T05:24:49.136+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2020-12-27T05:24:49.136+0000 I NETWORK [initandlisten] Shutting down the global connection pool
2020-12-27T05:24:49.136+0000 I - [initandlisten] Killing all operations for shutdown
2020-12-27T05:24:49.136+0000 I NETWORK [initandlisten] Shutting down the ReplicaSetMonitor
2020-12-27T05:24:49.136+0000 I CONTROL [initandlisten] Shutting down free monitoring
2020-12-27T05:24:49.136+0000 I FTDC [initandlisten] Shutting down full-time data capture
2020-12-27T05:24:49.136+0000 I STORAGE [initandlisten] Shutting down the HealthLog
2020-12-27T05:24:49.136+0000 I - [initandlisten] Dropping the scope cache for shutdown
2020-12-27T05:24:49.136+0000 I CONTROL [initandlisten] now exiting
2020-12-27T05:24:49.136+0000 I CONTROL [initandlisten] shutting down with code:100
Because of this, I can't start the website because it needs mongoDB/mongoose in order to run the server.
It seems that mongod/mongoDB doesn't have a data directory. Any ideas?

I already found the answer guys!
I just need to put -dbpath ./data/db after mongod
With that, I created a directory of data/db where I will store all the data from mongoDB.
so now I edited the file that I created named "mongod" with: mongod --nojournal -dbpath ./data/db and everything works once again. I feel pretty silly not knowing this but I hope I will never make this mistake again.

Related

MongoDB shutting down with code:12

I have saved my data yesterday, but when I tried to open my MongoDB via command Prompt and fire the command mongod its throwing out the following messages
>C:\mongodb\bin>mongod
>2018-07-20T16:21:25.350+0530 I CONTROL [main] Automatically disabling TLS 1.0, >to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
>2018-07-20T16:21:25.842+0530 I CONTROL [initandlisten] MongoDB starting : >pid=13544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-4H7RM2O
>2018-07-20T16:21:25.842+0530 I CONTROL [initandlisten] targetMinOS: Windows >7/Windows Server 2008 R2
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] db version v4.0.0
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] git version: >3b07af3d4f471ae89e8186d33bbb1d5259597d51
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] allocator: tcmalloc
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] modules: none
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] build environment:
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] distmod: 2008plus->ssl
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] distarch: x86_64
>2018-07-20T16:21:25.843+0530 I CONTROL [initandlisten] target_arch: x86_64
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] options: {}
>2018-07-20T16:21:25.844+0530 I STORAGE [initandlisten] exception in >initAndListen: NonExistentPath: Data directory C:\data\db\ not found., >terminating
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] now exiting
>2018-07-20T16:21:25.844+0530 I CONTROL [initandlisten] shutting down with >code:100
>
**Here is the command Prompt output when I fire mongo command**
<C:\mongodb\bin>mongo
<MongoDB shell version v4.0.0
<connecting to: mongodb://127.0.0.1:27017
<2018-07-20T16:28:01.594+0530 E QUERY [js] Error: couldn't connect to server <127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to <127.0.0.1:27017 :: caused by :: No connection could be made because the target <machine actively refused it. :
<connect#src/mongo/shell/mongo.js:251:13
<#(connect):1:6
<exception: connect failed
**This is my log file which is showing error =shutting down with code:12 **
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** WARNING: Access >control is not enabled for the database.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Read and >write access to data and configuration is unrestricted.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten]
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** WARNING: This server >is bound to localhost.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Remote >systems will be unable to connect to this server.
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** Start the >server with --bind_ip <address> to specify which IP
>2018-07-20T15:43:37.425+0530 I CONTROL [initandlisten] ** addresses it >should serve responses from, or with --bind_ip_all to
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten] ** bind to all >interfaces. If this behavior is desired, start the
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten] ** server with >--bind_ip 127.0.0.1 to disable this warning.
>2018-07-20T15:43:37.426+0530 I CONTROL [initandlisten]
>2018-07-20T15:43:40.388+0530 I FTDC [initandlisten] Initializing full-time >diagnostic data capture with directory 'C:/mongodb/data/db/diagnostic.data'
>2018-07-20T15:43:40.499+0530 I NETWORK [initandlisten] waiting for connections >on port 27017
>2018-07-20T15:45:42.106+0530 I CONTROL [thread1] Ctrl-C signal
>2018-07-20T15:45:42.106+0530 I CONTROL [consoleTerminate] got CTRL_C_EVENT, >will terminate after current cmd ends
>2018-07-20T15:45:42.106+0530 I NETWORK [consoleTerminate] shutdown: going to >close listening sockets...
>2018-07-20T15:45:42.325+0530 I CONTROL [consoleTerminate] Shutting down free >monitoring
>2018-07-20T15:45:42.326+0530 I FTDC [consoleTerminate] Shutting down full->time diagnostic data capture
>2018-07-20T15:45:42.334+0530 I STORAGE [consoleTerminate] WiredTigerKVEngine >shutting down
>2018-07-20T15:45:45.543+0530 I STORAGE [consoleTerminate] shutdown: removing fs >lock...
>2018-07-20T15:45:45.543+0530 I CONTROL [consoleTerminate] now exiting
>2018-07-20T15:45:45.543+0530 I CONTROL [consoleTerminate] shutting down with >code:12
I have ensured that my data path is correct but unable to solve this problem.
Try below:
Mac: Documents/mongodb/bin/mongod --dbpath Documents/data/db/
Window: "C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath d:\test\mongodb\data
You just need to set db path.
You can set storage db path to the config file: Check this
And check this for window installation.
If you're using Linux just give increased permission to the storage file and restart mongodb it will work. Default storage file will be var/lib/mongodb. To give increased permissions use : chmod 777 mongod.

mongo: “exception: connect failed”

I am trying to connect to the mongo server, using the "mongo" command in the command prompt and this error is showing: "exception: connect failed"
Here is how I am trying to do it:
enter image description here
This is the mongodb.log
2018-03-27T14:00:19.299+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-03-27T14:00:19.647+0800 I CONTROL [main] Trying to start Windows service 'MongoDB'
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] MongoDB starting : pid=10480 port=27017 dbpath=d:\mongodbData\db 64-bit host=DESKTOP-KEA31I3
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] db version v3.6.3
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] modules: none
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] build environment:
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] distarch: x86_64
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] options: { service: true, storage: { dbPath: "d:\mongodbData\db" }, systemLog: { destination: "file", logAppend: true, path: "d:\mongodbData\log\mongodb.log" } }
2018-03-27T14:00:19.651+0800 I - [initandlisten] Detected data files in d:\mongodbData\db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-03-27T14:00:19.651+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7632M,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),
2018-03-27T14:00:19.834+0800 I STORAGE [initandlisten] WiredTiger message [1522130419:833660][10480:140722874245456], txn-recover: Main recovery loop: starting at 4/6272
2018-03-27T14:00:19.970+0800 I STORAGE [initandlisten] WiredTiger message [1522130419:970024][10480:140722874245456], txn-recover: Recovering log 4 through 5
2018-03-27T14:00:20.046+0800 I STORAGE [initandlisten] WiredTiger message [1522130420:46191][10480:140722874245456], txn-recover: Recovering log 5 through 5
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** WARNING: The file system cache of this machine is configured to be greater than 40% of the total memory. This can lead to increased memory pressure and poor performance.
2018-03-27T14:00:20.174+0800 I CONTROL [initandlisten] See http://dochub.mongodb.org/core/wt-windows-system-file-cache
2018-03-27T14:00:20.174+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.402+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'd:/mongodbData/db/diagnostic.data'
2018-03-27T14:00:20.404+0800 I NETWORK [initandlisten] waiting for connections on port 27017
2018-03-27T14:00:20.404+0800 I STORAGE [initandlisten] Service running
Please help me. How to fix it
Run this following command :
sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
mongo

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 :)

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.

sudo service mongod start : mongod: unrecognized service

I'm testing learning locker which is based on MongoDB it's all inside a ubuntu14.04 docker https://hub.docker.com/r/hadyrashwan/learninglocker-ubuntu14.04/ . I got it to work but I can't start Mongodb automatically tried the repair command and changing the name in start service command to Mongodb or mongo but not working. but running Mongodb just make it start but I want to start it automatically not opening a terminal and leave it open so the system continues to work
root#bd1997365c3a:/# mongodb
2016-09-06T07:41:51.816+0000 I CONTROL [initandlisten] MongoDB starting : pid=197 port=27017 dbpath=/data/db 64-bit host=bd1997365c3a
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] db version v3.2.9
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] modules: none
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] build environment:
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] distarch: x86_64
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-09-06T07:41:51.817+0000 I CONTROL [initandlisten] options: {}
2016-09-06T07:41:51.823+0000 I - [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
2016-09-06T07:41:51.867+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
2016-09-06T07:41:51.867+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-09-06T07:41:52.027+0000 I JOURNAL [durability] Durability thread started
2016-09-06T07:41:52.027+0000 I JOURNAL [journal writer] Journal writer thread started
2016-09-06T07:41:52.101+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-09-06T07:41:52.101+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-09-06T07:41:52.102+0000 I CONTROL [initandlisten]
2016-09-06T07:41:52.111+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-09-06T07:41:52.112+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-09-06T07:41:52.112+0000 I NETWORK [initandlisten] waiting for connections on port 27017
If already you install the mongodb just uninstall based on mongodb config
Before going do all stuff first install mongodb server.
sudo apt install mongodb-server
Then continue to install what mongodb config suggest you.
Once done your mongodb configuration you can go
sudo service mongodb start
Note: Its not mongod its mongodb
I had same problem. It seems there is some mis-configuration if you install via source code.
Re-installing mongoDB using apt-get activated mongod as a service for
me.