1

I have a problem with my MongoDB installation on Linux. I just need to install MongoDB local. I started with a outdated version (2.4.9), so I used these command lines to delete the entire old version:

sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev
sudo apt-get purge mongodb-10gen
sudo apt-get autoremove

So at this moment I had no version of MongoDB installed on my Linux Mint Qaina 17

I went to the website: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ Did the following command lines, just like the websites told me to do:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start

At this moment I have MongoDB 2.6.5 installed. The latest version. After I got none error, I restart my terminal. This is my result in terminal after I typed: sudo mongod

mongod --help for help and startup options
2014-10-31T19:24:30.653+0100 [initandlisten] MongoDB starting : pid=2749 port=27017 dbpath=/data/db 64-bit host=XXX-pc
2014-10-31T19:24:30.653+0100 [initandlisten] db version v2.6.5
2014-10-31T19:24:30.653+0100 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-10-31T19:24:30.653+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-10-31T19:24:30.653+0100 [initandlisten] allocator: tcmalloc
2014-10-31T19:24:30.654+0100 [initandlisten] options: {}
2014-10-31T19:24:30.728+0100 [initandlisten] journal dir=/data/db/journal
2014-10-31T19:24:30.729+0100 [initandlisten] recover : no journal files present, no recovery needed
2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-10-31T19:24:30.894+0100 [initandlisten] ERROR:   addr already in use
2014-10-31T19:24:30.895+0100 [initandlisten] now exiting
2014-10-31T19:24:30.895+0100 [initandlisten] dbexit: 
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: going to close listening sockets...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: going to flush diaglog...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: going to close sockets...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: waiting for fs preallocator...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: lock for final commit...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: final commit...
2014-10-31T19:24:30.969+0100 [initandlisten] shutdown: closing all files...
2014-10-31T19:24:30.970+0100 [initandlisten] closeAllFiles() finished
2014-10-31T19:24:30.970+0100 [initandlisten] journalCleanup...
2014-10-31T19:24:30.970+0100 [initandlisten] removeJournalFiles
2014-10-31T19:24:31.028+0100 [initandlisten] shutdown: removing fs lock...
2014-10-31T19:24:31.029+0100 [initandlisten] dbexit: really exiting now

Could anybody tell me what the problem is? I had the same problem on a

M. Douglas
  • 347
  • 1
  • 4
  • 17
  • Is mongod already running? This error states that port 27017 is already in use by another process. I would run a ps -ef | grep mongo to double check that mongo isn't already up. If it isn't you could also change the port # with a --port argument. – James Wahlin Oct 31 '14 at 18:49

2 Answers2

0

Thanks for your quick response!

Result:

sudo lsof -i :27017
[sudo] password for XXX: 
COMMAND  PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mongod  1294 mongodb    8u  IPv4  11020      0t0  TCP localhost:27017 (LISTEN)

and

sudo service mongod status
mongod start/running, process 1294

When I go to my webbrowser and type

http://localhost:27017/mydb

I get a "It looks like you are trying to access MongoDB over HTTP on the native driver port." Am I missing something here?

M. Douglas
  • 347
  • 1
  • 4
  • 17
  • It's working. Through a GUI I can enter my local database Thanks everyone! – M. Douglas Nov 01 '14 at 14:10
  • great! for your next question, try to post results as comment instead of posting a new response – kamaradclimber Nov 01 '14 at 19:05
  • Sure, will do. I am new here, so I will pay attention to it next time. I am not sure if this is allowed, but could you take a look at this post as well: http://stackoverflow.com/questions/26690170/mongodb-on-server-installed-connections0?noredirect=1#comment41977277_26690170 I need to prep a MongoDB ubuntu server, but I have some problems – M. Douglas Nov 02 '14 at 10:49
-1

2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017

2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: addr already in use 2014-10-31T19:24:30.895+0100 [initandlisten] now exiting

means that some process is already bound to port 27017.

You can find out which one with lsof -i :27017 (running with superuser priviledge, with sudo for instance)

It is probably the mongod service installed (and started) with the mongod package.

You can verify this with sudo service mongod status

Community
  • 1
  • 1
kamaradclimber
  • 2,479
  • 1
  • 26
  • 45
  • Just partially true. The status check fails on newer Ubuntu and other Debianish systems as of a problem with reading the pid. A `ps ax | grep [m]ongod` does the same more reliable, without sudo. On the other hand, it is wrong to assume that everybody needs to use `sudo` for each command. Some people actually administer even their Ubuntu system as root, and contrary to what the "canonical" fairytal tellers try to establish, there is nothing evil about that. When changing your ID, you know you have to be careful. When suggesting doing sth via sudo, you should warn about it's power and explain. – Markus W Mahlberg Nov 01 '14 at 09:07
  • @MarkusWMahlberg, even if some people administer their system as root, giving them command with sudo is not wrong. I'll edit my answer to take into account your comment. – kamaradclimber Nov 01 '14 at 19:06
  • @MarkusWMahlberg, service mongod status is the canonical command to check the status of a service. Overwhelming new users with possible bug and their workaround would not help them imho. – kamaradclimber Nov 01 '14 at 19:09
  • I suggest you install MongoDB on a fresh ubuntu system and try to stop it with `service mongod stop`. And have a look here: http://stackoverflow.com/questions/13303685/stop-unknown-instance-mongodb-ubuntu. ;) – Markus W Mahlberg Nov 01 '14 at 19:25
  • as I said, I don't want to overwhelm users with a bug that is transient (question is not specific to a ubuntu version, the answer shoudl not be) – kamaradclimber Nov 02 '14 at 08:37
  • A) If you read the question closely, the problem _is_ specific to Ubuntu -at least the Ubuntu packages provided by the 10gen repo. And guess what, they install the same upstart script regardless of which ubuntu derivate they are installed on. B) The OP needs help _now_. If he or she could wait until that bug in the startup scripts is fixed, he or she would not have asked. C) If you wanted it to make general and for the future, you should have used systemd commands instead of upstart. – Markus W Mahlberg Nov 02 '14 at 08:42
  • ok, let's avoid extending this discussion since the OP already found the answer useful a few hours ago. anyway thanks for your detail and specific precision around this packaging issue – kamaradclimber Nov 02 '14 at 08:48