mongodb 无法在 ubuntu 16.10 上启动

mongodb 无法在 ubuntu 16.10 上启动

我第一次尝试在 Ubuntu 16.10 上安装 mongodb。我已经成功安装它,但当我尝试运行它时,我收到此错误。当我mongo在终端上输入

MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.2
Server has startup warnings: 
2017-03-21T22:29:13.268+0700 I STORAGE  [initandlisten] 
2017-03-21T22:29:13.268+0700 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-03-21T22:29:13.268+0700 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-03-21T22:29:14.010+0700 I CONTROL  [initandlisten] 
2017-03-21T22:29:14.010+0700 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-03-21T22:29:14.010+0700 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-03-21T22:29:14.010+0700 I CONTROL  [initandlisten] 
2017-03-21T22:29:14.010+0700 I CONTROL  [initandlisten] 
2017-03-21T22:29:14.010+0700 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-03-21T22:29:14.011+0700 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-03-21T22:29:14.011+0700 I CONTROL  [initandlisten] 

当我打字时mongod我收到了这条消息

2017-03-21T22:46:31.103+0700 I CONTROL  [initandlisten] MongoDB starting : pid=13038 port=27017 dbpath=/data/db 64-bit host=michael-Satellite-L740
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] db version v3.4.2
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] allocator: tcmalloc
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] modules: none
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] build environment:
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten]     distarch: x86_64
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten]     target_arch: x86_64
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] options: {}
2017-03-21T22:46:31.104+0700 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-03-21T22:46:31.104+0700 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2017-03-21T22:46:31.104+0700 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] now exiting
2017-03-21T22:46:31.104+0700 I CONTROL  [initandlisten] shutting down with code:100

我对 Linux 还很陌生,mongodb所以如果能得到任何帮助我都会很感激,

答案1

在最新版本的 ubuntu 上启动 mongodb 有点不同。

启动 mongodb 的正确代码是

sudo service mongodb start

要确认 mongodb 正在运行,请运行

sudo service mongodb status

其他命令包括

sudo service mongodb stop
sudo service mongodb restart

相关内容