sudo service mongod start : mongod: 无法识别的服务

sudo service mongod start : mongod: unrecognized service

我正在测试基于 MongoDB 的学习储物柜,它都在 ubuntu14.04 docker https://hub.docker.com/r/hadyrashwan/learninglocker-ubuntu14.04/ 中。我让它工作但我无法启动 Mongodb 自动尝试了修复命令并将启动服务命令中的名称更改为 Mongodb 或 mongo 但没有工作。但是 运行 Mongodb 让它启动但我想自动启动它而不打开终端并保持打开状态以便系统继续工作

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

我遇到了同样的问题。源码安装好像配置有问题

Re-installing mongoDB using apt-get activated mongod as a service for me.

如果你已经安装了 mongodb 只需根据 mongodb config

卸载

在开始之前先安装 mongodb 服务器。

sudo apt install mongodb-server  

然后继续安装 mongodb config 建议的内容。

完成 mongodb 配置后,您可以开始

sudo service mongodb start

注意:它不是 mongod 它 mongodb