安装服务器上的MongoDB,连接数:0

时间:2014-11-01 14:25:00

标签: linux mongodb ubuntu ubuntu-server

我们需要使用MongoDB准备一个ubuntu服务器。 我们成功安装了它。当我们输入:

sudo mongod

这是我们的结果:

XXX@ubuntu-vm:~$ sudo mongod
[sudo] password for XXX: 
mongod --help for help and startup options
2014-11-01T14:42:19.717+0100 [initandlisten] MongoDB starting : pid=15519 port=27017 dbpath=/data/db 64-bit host=ubuntu-vm
2014-11-01T14:42:19.718+0100 [initandlisten] db version v2.6.5
2014-11-01T14:42:19.718+0100 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-11-01T14:42:19.718+0100 [initandlisten] build info: Linux build8.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-11-01T14:42:19.718+0100 [initandlisten] allocator: tcmalloc
2014-11-01T14:42:19.718+0100 [initandlisten] options: {}
2014-11-01T14:42:19.732+0100 [initandlisten] journal dir=/data/db/journal
2014-11-01T14:42:19.733+0100 [initandlisten] recover : no journal files present, no recovery needed
2014-11-01T14:42:19.745+0100 [initandlisten] waiting for connections on port 27017
2014-11-01T14:43:19.755+0100 [clientcursormon] mem (MB) res:35 virt:344
2014-11-01T14:43:19.755+0100 [clientcursormon]  mapped (incl journal view):160
2014-11-01T14:43:19.756+0100 [clientcursormon]  connections:0

之后,没有任何反应。我一直在说:

2014-11-01T14:48:19.770+0100 [clientcursormon] mem (MB) res:35 virt:344
2014-11-01T14:48:19.770+0100 [clientcursormon]  mapped (incl journal view):160
2014-11-01T14:48:19.770+0100 [clientcursormon]  connections:0

有人能告诉我们这里发生了什么吗?我们只需要安装MongoDB。我们有一个拥有所有权利的管理员帐户。我们需要确保我们可以启动MongoDB服务器并通过GUI进行管理。

当我们输入:mongo 结果:

2014-11-01T15:30:22.616+0100 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

另一次尝试:

XXX@ubuntu-vm:~$ sudo service mongod start
[sudo] password for XXX: 
mongod start/running, process 15671

XXX@ubuntu-vm:~$ sudo mongod
mongod --help for help and startup options
2014-11-01T15:33:10.025+0100 [initandlisten] MongoDB starting : pid=15677 port=27017 dbpath=/data/db 64-bit host=ubuntu-vm
2014-11-01T15:33:10.026+0100 [initandlisten] db version v2.6.5
2014-11-01T15:33:10.026+0100 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-11-01T15:33:10.027+0100 [initandlisten] build info: Linux build8.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-11-01T15:33:10.027+0100 [initandlisten] allocator: tcmalloc
2014-11-01T15:33:10.027+0100 [initandlisten] options: {}
2014-11-01T15:33:10.041+0100 [initandlisten] journal dir=/data/db/journal
2014-11-01T15:33:10.041+0100 [initandlisten] recover : no journal files present, no recovery needed
2014-11-01T15:33:10.062+0100 [initandlisten] waiting for connections on port 27017
2014-11-01T15:34:10.057+0100 [clientcursormon] mem (MB) res:35 virt:344
2014-11-01T15:34:10.058+0100 [clientcursormon]  mapped (incl journal view):160
2014-11-01T15:34:10.058+0100 [clientcursormon]  connections:0

提前致谢。我们感谢任何评论/回答。

1 个答案:

答案 0 :(得分:1)

MongoDB安装正确。您需要做的是配置它(编辑/etc/mongodb.conf)启用服务(sudo service mongod start)。

你会注意到,当你搜索“ubuntu mongodb install”时,谷歌返回的第一个链接上清楚地记录了这两个(以及你需要做的其他事情,以便在Ubuntu机器上运行MongoDB) “:http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

至于“0连接”的事情,它只是意味着没有人连接到你的数据库服务器(鉴于你正在设置它,这是完全合理的 - 你使用MongoDB的生产应用程序不应该'启动直到DB服务器启动并运行。