Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing mongodb in ubuntu 15.04

Tags:

mongodb

ubuntu

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?

like image 552
Syd Amir Avatar asked Apr 07 '15 14:04

Syd Amir


People also ask

Does MongoDB work in Ubuntu?

MongoDB can be installed on Ubuntu with the use of the following commands. These commands are easy to run on the terminal and make the installation process handy. Follow the steps given below to install MongoDB: Step 1: First you need to update and upgrade your system repository in order to install MongoDB.

How do I know if MongoDB is installed Ubuntu?

MongoDB installs as a systemd service, which means that you can manage it using standard systemd commands alongside all other sytem services in Ubuntu. To verify the status of the service, type: sudo systemctl status mongodb.


2 Answers

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.

like image 89
Niall Lonergan Avatar answered Nov 09 '22 05:11

Niall Lonergan


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!

like image 39
Victor Gazotti Avatar answered Nov 09 '22 05:11

Victor Gazotti