问题
We need to prepare a ubuntu-server with MongoDB. We managed to install it properly. When we type:
sudo mongod
this is our result:
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
After that, nothing happens. I keeps saying:
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
Could anybody tell us what is happening here? We just need MongoDB installed. We have a admin account with all rights. We need make sure we can start the MongoDB server and manage it through a GUI.
When we type: mongo Result:
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
Another try:
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
Thanks in advance. We appreciate any comment/answer.
回答1:
MongoDB installed correctly. What you need to do is configure it (edit /etc/mongodb.conf
) enable the service (sudo service mongod start
).
Both of which, you will note, are clearly documented (as well as everything else you need to do to get MongoDB up and running on a Ubuntu machine) at the very first link Google returns when you search for "ubuntu mongodb install": http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
As for the "0 connections" thing, it simply means that nobody is connecting to your database server (which makes perfect sense given that you're in the process of setting it up -- your production applications that use MongoDB shouldn't be started until the DB server is up and running).
来源:https://stackoverflow.com/questions/26690170/mongodb-on-server-installed-connections0