8

I'm installing Mongodb in several time in Ubuntu 15.04 but it not install properly and mongo shell has an error :

   mongo
MongoDB shell version: 3.0.1
connecting to: test
2015-04-07T18:46:14.958+0430 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-04-07T18:46:14.959+0430 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
    at connect (src/mongo/shell/mongo.js:179:14)
    at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed

I'm installing the 2.6.4 and updated to 3.0.1 but the error not resolve. I found this Answer in stackoverflow and search to find mongod.lock in ubuntu and remove it and then flow this step :

Step 2: Repair mongodb. 
sudo mongod --repair 

Step 3: start mongodb.
sudo start mongodb 
or
sudo service mongodb start

Step 4: Check status of mongodb.
sudo status mongodb 
or   
sudo service mongodb status

Step 5: Start mongo console.
mongo

for reapir :

   mongod --repair
2015-04-07T18:58:15.595+0430 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2015-04-07T18:58:15.595+0430 I CONTROL  [initandlisten] dbexit:  rc: 100

This error for sudo service mongodb start :

   sudo service mongodb start
[sudo] password for amir: 
Failed to start mongodb.service: Unit mongodb.service failed to load: No such file or directory.

and for status :

   sudo service mongodb status
● mongodb.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

and for start shell the first problem has throw.

I try install mongodb with linuxbrew and again the error did not gone...

--------------- update -------- since in what say "demostene" :

I think you just need to create this folder /data/db . Try sudo mkdir /data/db then repair

I have the /data/db in the home/amir/data/db then i create the /data/db in root and nothing change... In last time i installing the mongo with linuxbrew and for that the sudo command did not work in sudo mongod --repair and other step and without sudo that's command did not work... so i first try sudo su in terminal and try the step in root in first step say the mongodb is not install and for install it insert : apt-get install mongo-server I insert this command and install mongodb again. Now in root mongo shell start correctly in this version :

root@AbrFa:/home/amir# mongo
MongoDB shell version: 2.6.3
connecting to: test
>

and without the sudo su mongo shell start in this version :

MongoDB shell version: 3.0.1
connecting to: test

By the way I want's to know do not conflict this 2 version with each other?

Community
  • 1
  • 1
Syd Amir
  • 465
  • 7
  • 19
  • 1
    I think you just need to create this folder /data/db . Try sudo mkdir /data/db then repair – panagdu Apr 07 '15 at 14:37
  • I have the 'data/db' folder. and i was delete the 'mongod.lock' from '/home/amir/data/db/_tmp' – Syd Amir Apr 07 '15 at 14:47
  • Looks like you have it inside /home/amir/ but mongodb is pointing to /data/db. Try running my command – panagdu Apr 07 '15 at 14:51
  • Since `mongod` runs as a dedicated user (`mongodb` of the top of my head), which does not have write access to `/home/amir` by default, this can't work. Try again with the default values. – Markus W Mahlberg Apr 07 '15 at 15:52
  • Refer http://stackoverflow.com/questions/25225650/how-to-install-mongodb-after-downloading/25225731#25225731 – Darshan Patel Apr 07 '15 at 16:11
  • Tanx dude I update the question ... – Syd Amir Apr 07 '15 at 16:52
  • This may be realted to the fact that ubuntu 15.04 moved to systemd and no longer uses upstart. also discussed here http://stackoverflow.com/questions/29879231/upgrade-to-ubuntu-15-04-from-14-10-breaks-mongo-how-to-fix – aeischeid Apr 27 '15 at 17:18

2 Answers2

1

Ok I've found the fix. Not the best but it'll do for now. Click this link and download the suitable option. I chose the apt-install option. Choice is yours. The version is 2.6.3 and you will have to create the /data/db folder again. But we're back for now.

Niall Lonergan
  • 891
  • 1
  • 7
  • 29
1

in my case I was running "sudo mongod --repair" and I figure out that I did not have the folder "/data/db". So I just created that folder and ran again the "sudo mongod --repair" and now it works!

Victor Gazotti
  • 1,773
  • 1
  • 13
  • 9