sudo service mongod start : mongod: unrecognized service
Asked Answered
E

2

7

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
Ern answered 6/9, 2016 at 8:4 Comment(4)
you need to install mongo as a service. check this out docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntuMelano
@DeendayalGarg adding a service is listed for 16.04 which got systemd If I understand correctly . I used 14.04 to avoid php 7 and downgrading itErn
systemd is required when u r using ubuntu 16 . but installing mongo as a service is required if you are using command sudo service mongod start in any ubuntu version. check this for more info. digitalocean.com/community/tutorials/…Melano
I couldn't get it to work I need to reinstall mongo . I will try reinstalling it all together also work with 16.04 for systemdErn
C
7

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

Coparcenary answered 8/11, 2017 at 16:10 Comment(0)
C
1

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.

Cru answered 6/9, 2016 at 13:28 Comment(1)
how do you do that?Brannen

© 2022 - 2024 — McMap. All rights reserved.