Trouble installing mongodb using Homebrew - mongodb

I'm trying to get Mongo running.
I installed the package manager Homebrew
I then used the commands located on the Mongo site:
$ brew update
$ brew install mongodb
This appeared to install correctly.
I typed mongo in a new terminal window and got the following error:
MongoDB shell version: 2.0.1
connecting to: test
Thu Dec 15 09:37:25 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
So I then followed the instructions found on here
Ran mongod and this is the result:
mongod --help for help and startup options
Thu Dec 15 09:38:49 [initandlisten] MongoDB starting : pid=7364 port=27017 dbpath=/data/db/ 64-bit host=Mike-Fieldens-iMac.local
Thu Dec 15 09:38:49 [initandlisten] db version v2.0.1, pdfile version 4.5
Thu Dec 15 09:38:49 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
Thu Dec 15 09:38:49 [initandlisten] build info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Thu Dec 15 09:38:49 [initandlisten] options: {}
Thu Dec 15 09:38:49 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db/) does not exist, terminating
Thu Dec 15 09:38:49 dbexit:
Thu Dec 15 09:38:49 [initandlisten] shutdown: going to close listening sockets...
Thu Dec 15 09:38:49 [initandlisten] shutdown: going to flush diaglog...
Thu Dec 15 09:38:49 [initandlisten] shutdown: going to close sockets...
Thu Dec 15 09:38:49 [initandlisten] shutdown: waiting for fs preallocator...
Thu Dec 15 09:38:49 [initandlisten] shutdown: lock for final commit...
Thu Dec 15 09:38:49 [initandlisten] shutdown: final commit...
Thu Dec 15 09:38:49 [initandlisten] shutdown: closing all files...
Thu Dec 15 09:38:49 [initandlisten] closeAllFiles() finished
Thu Dec 15 09:38:49 dbexit: really exiting now
Notice there was an exception with "initAndListen" then it shutdown.
What am I doing wrong? How can I fix this installation and get Mongo up and running?

This is the problem:
15 09:38:49 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db/) does not exist, terminating
Thu Dec 15 09:38:49 dbexit:
Create the path /data/db on your system and it will work.

Related

mongod doesn't start even on start of the system

when I run sudo mongod on my ubuntu 14.04 it gives below error
mongod --help for help and startup options
Tue Mar 7 09:42:15.992 [initandlisten] MongoDB starting : pid=2870 port=27017 dbpath=/data/db/ 64-bit host=keshav-mohta
Tue Mar 7 09:42:15.992 [initandlisten] db version v2.4.9
Tue Mar 7 09:42:15.992 [initandlisten] git version: nogitversion
Tue Mar 7 09:42:15.992 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Tue Mar 7 09:42:15.992 [initandlisten] allocator: tcmalloc
Tue Mar 7 09:42:15.992 [initandlisten] options: {}
Tue Mar 7 09:42:16.431 [initandlisten] journal dir=/data/db/journal
Tue Mar 7 09:42:16.435 [initandlisten] recover : no journal files present, no recovery needed
Tue Mar 7 09:42:17.587 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Tue Mar 7 09:42:17.587 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Tue Mar 7 09:42:17.587 [websvr] ERROR: addr already in use
Tue Mar 7 09:42:17.587 [initandlisten] ERROR: addr already in use
Tue Mar 7 09:42:17.587 [initandlisten] now exiting
Tue Mar 7 09:42:17.587 dbexit:
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: going to close listening sockets...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: going to flush diaglog...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: going to close sockets...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: waiting for fs preallocator...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: lock for final commit...
Tue Mar 7 09:42:17.587 [initandlisten] shutdown: final commit...
Tue Mar 7 09:42:17.760 [initandlisten] shutdown: closing all files...
Tue Mar 7 09:42:17.760 [initandlisten] closeAllFiles() finished
Tue Mar 7 09:42:17.760 [initandlisten] journalCleanup...
Tue Mar 7 09:42:17.760 [initandlisten] removeJournalFiles
Tue Mar 7 09:42:17.969 [initandlisten] shutdown: removing fs lock...
Tue Mar 7 09:42:17.969 dbexit: really exiting now
I know the solution to kill the process (sudo killall mongod) and then run the command again but my question is :
WHY it say addr already in use when I just start the system?
Is there any way so that I do not require to run 2 command on every morning to start mongod service.
UPDATE
my guess is that mongo service start on startup as I checked with
sudo initctl list | grep mongo
which output
mongodb start/running, process 1190
now I execute below command to stop mongodb on startup
sudo update-rc.d -f mongodb remove
which output
Removing any system startup links for /etc/init.d/mongodb ...
BUt it still display the mongodb in the list when check with sudo initctl list. even I start the system again to verify?
Step 1: Sometimes starting the services in completely new terminal ctrl + alt + T works.
Step 2: Use netstat to detect the port is running or not
netstat -anp | grep mongodPortHere
If it is running then use ps aux | grep "mongod" | less for processId and use kill -9 processId

Unable to start MongoDB. ERROR: addr already in use

I tried running MongoDB in local server with mongod command and it failed to run. The error:
mongod --help for help and startup options
Sat Jan 31 13:07:16.392 [initandlisten] MongoDB starting : pid=5127 port=27017 dbpath=/data/db/ 64-bit host=leandrotk
Sat Jan 31 13:07:16.392 [initandlisten] db version v2.4.9
Sat Jan 31 13:07:16.392 [initandlisten] git version: nogitversion
Sat Jan 31 13:07:16.392 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Sat Jan 31 13:07:16.392 [initandlisten] allocator: tcmalloc
Sat Jan 31 13:07:16.392 [initandlisten] options: {}
Sat Jan 31 13:07:16.435 [initandlisten] journal dir=/data/db/journal
Sat Jan 31 13:07:16.435 [initandlisten] recover : no journal files present, no recovery needed
Sat Jan 31 13:07:16.513 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Sat Jan 31 13:07:16.514 [initandlisten] ERROR: addr already in use
Sat Jan 31 13:07:16.514 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Sat Jan 31 13:07:16.514 [initandlisten] now exiting
Sat Jan 31 13:07:16.514 [websvr] ERROR: addr already in use
Sat Jan 31 13:07:16.514 dbexit:
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to close listening sockets...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to flush diaglog...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to close sockets...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: waiting for fs preallocator...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: lock for final commit...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: final commit...
Sat Jan 31 13:07:16.599 [initandlisten] shutdown: closing all files...
Sat Jan 31 13:07:16.599 [initandlisten] closeAllFiles() finished
Sat Jan 31 13:07:16.599 [initandlisten] journalCleanup...
Sat Jan 31 13:07:16.599 [initandlisten] removeJournalFiles
Sat Jan 31 13:07:16.668 [initandlisten] shutdown: removing fs lock...
Sat Jan 31 13:07:16.668 dbexit: really exiting now
you already have a process running
killall mongod
should kill the other process, if you have another kind of process bound to that port you could find it with netstat | grep 27017
Try this:
sudo service mongodb stop
sudo mongod
some version is:
sudo service mongod stop
mongod: mongo damon

Error in textSearchEnable=true in MongoDB

I am getting the below error when enabling text search in mongodb. Any Suggestion.
I have mongo.config filw which contains :
##store data here
dbpath=C:\mongodb\data
##all output go here
logpath=C:\mongodb\log\mongo.log
##log read and write operations
diaglog=3
Error is :
C:\mongodb-win32-x86_64-2.4.6\bin>mongod --setParameter textSearchEnabled=true
Tue Jan 14 16:52:51.336 [initandlisten] MongoDB starting : pid=976 port=27017 dbpath=\data\db\ 64-bit host=dellvostro3
Tue Jan 14 16:52:51.337 [initandlisten] db version v2.4.6
Tue Jan 14 16:52:51.337 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Tue Jan 14 16:52:51.337 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack
1') BOOST_LIB_VERSION=1_49
Tue Jan 14 16:52:51.337 [initandlisten] allocator: system
Tue Jan 14 16:52:51.337 [initandlisten] options: { setParameter: [ "textSearchEnabled=true" ] }
Tue Jan 14 16:52:51.337 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (\data\db\) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Tue Jan 14 16:52:51.338 dbexit:
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: going to close listening sockets...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: going to flush diaglog...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: going to close sockets...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: waiting for fs preallocator...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: lock for final commit...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: final commit...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: closing all files...
Tue Jan 14 16:52:51.338 [initandlisten] closeAllFiles() finished
Tue Jan 14 16:52:51.338 dbexit: really exiting now
You provide wrong path to your data
ERROR: dbpath (\data\db\) does not exist.
\data\db\ is default mongo data path, you need to create this directory or get provide another path when running mongod
When you run
mongod --setParameter textSearchEnabled=true
MongoDB will take \data\db\ as the dbpath. Which is not there in your machine and hence you get the error.
I see you have a config file containing the dbpath etc, but you haven't specified the config file while starting mongod.
mongod --config mongo.config --setParameter textSearchEnabled=true
See using config file here.
Also you could move the textSearchEnabled=true to your config file.
##store data here
dbpath=C:\mongodb\data
##all output go here
logpath=C:\mongodb\log\mongo.log
##log read and write operations
diaglog=3
setParameter=textSearchEnabled=true
Now you can start mongod by just using
mongod --config mongo.config

Error connecting to local installation of MongoDB thru terminal

Terminal displays following error:
$ mongo
MongoDB shell version: 2.4.5
connecting to: test
Wed Jul 24 14:26:45.779 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
upon running
mongod run --config /usr/local/etc/mongod.conf
I get following error on console:
about to fork child process, waiting until server is ready for connections.
forked process: 11204
all output going to: /usr/local/var/log/mongodb/mongo.log
ERROR: child process failed, exited with error number 100
The mongo.log shows:
***** SERVER RESTARTED *****
Wed Jul 24 14:39:57.360 [initandlisten] MongoDB starting : pid=11204 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=59.161.67.13.del-cdma.dialup.vsnl.net.in
Wed Jul 24 14:39:57.363 [initandlisten]
Wed Jul 24 14:39:57.363 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Wed Jul 24 14:39:57.363 [initandlisten] db version v2.4.5
Wed Jul 24 14:39:57.363 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Wed Jul 24 14:39:57.363 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Wed Jul 24 14:39:57.363 [initandlisten] allocator: system
Wed Jul 24 14:39:57.363 [initandlisten] options: { bind_ip: "127.0.0.1", command: [ "run" ], config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", fork: "true", journal: "true", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log", port: 27017, quiet: "true" }
Wed Jul 24 14:39:57.367 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Wed Jul 24 14:39:57.368 [initandlisten] recover : no journal files present, no recovery needed
Wed Jul 24 14:39:58.113 [initandlisten] couldn't open /usr/local/var/mongodb/test.0 errno:13 Permission denied
Wed Jul 24 14:39:58.136 [initandlisten] couldn't open /usr/local/var/mongodb/test.0 errno:13 Permission denied
Wed Jul 24 14:39:58.152 [initandlisten] exception in initAndListen: 10085 can't map file memory, terminating
Wed Jul 24 14:39:58.152 dbexit:
Wed Jul 24 14:39:58.152 [initandlisten] shutdown: going to close listening sockets...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: going to flush diaglog...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: going to close sockets...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: waiting for fs preallocator...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: lock for final commit...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: final commit...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: closing all files...
Wed Jul 24 14:39:58.154 [initandlisten] closeAllFiles() finished
Wed Jul 24 14:39:58.154 [initandlisten] journalCleanup...
Wed Jul 24 14:39:58.154 [initandlisten] removeJournalFiles
Wed Jul 24 14:39:58.154 [initandlisten] shutdown: removing fs lock...
Wed Jul 24 14:39:58.154 dbexit: really exiting now
EDIT! ( trying suggestions from answers)
running $ mongod --repair gives the following error:
$ mongod --repair
Wed Jul 24 15:16:51.596 Can't specify both --journal and --repair options.
Run the following command first to start the mongo server
mongod run --config /usr/local/etc/mongod.conf
Assuming you installed mongo using Brew.
More information about the mongod process here
EDIT
Try to repair mongo using :
mongod --repair
Seems to have issues with permissions also, try using sudo to start mongod
You need to make sure that you've actually started the server. It doesn't seem to be running here.

can't start mongo db

I'm trying to start mongo db but I'm getting an error
Here is the output:
k-ps-macbook:~ kp$ mongod
mongod --help for help and startup options
Tue Aug 16 15:57:11 [initandlisten] MongoDB starting : pid=4143 port=27017 dbpath=/data/db/ 64-bit
Tue Aug 16 15:57:11 [initandlisten] db version v1.8.2, pdfile version 4.5
Tue Aug 16 15:57:11 [initandlisten] git version: 433bbaa14aaba6860da15bd4de8edf600f56501b
Tue Aug 16 15:57:11 [initandlisten] build sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Tue Aug 16 15:57:11 [initandlisten] couldn't open /data/db/awesome_blog.ns errno:13 Permission denied
Tue Aug 16 15:57:11 [initandlisten] error couldn't open file /data/db/awesome_blog.ns terminating
Tue Aug 16 15:57:11 dbexit:
Tue Aug 16 15:57:11 [initandlisten] shutdown: going to close listening sockets...
Tue Aug 16 15:57:11 [initandlisten] shutdown: going to flush diaglog...
Tue Aug 16 15:57:11 [initandlisten] shutdown: going to close sockets...
Tue Aug 16 15:57:11 [initandlisten] shutdown: waiting for fs preallocator...
Tue Aug 16 15:57:11 [initandlisten] shutdown: closing all files...
Tue Aug 16 15:57:11 closeAllFiles() finished
Tue Aug 16 15:57:11 [initandlisten] shutdown: removing fs lock...
Tue Aug 16 15:57:11 dbexit: really exiting now
any help will be appreciated,
thanks!
You will need read/write permissions to /data/db/
The error shows up, because you are not logged in as root user. To do that (if you use Debian), run:
sudo mongod
Or simply:
su root
Then type the password and type
mongod
Then you will get access to the
/data/db directory.
I deleted /data/db/mongod.lock to solve the problem.
From the command line, run:
cd ~
./mongod --repair
If you're still having trouble getting it to run then find the /data directory (it should be inside of ~ or ~/workspace) and cd into it. Once inside, run rm mongod.lock then cd back into ~ and run ./mongod again (see below).
cd ~/data
rm mongod.lock
cd
./mongod