Error connecting to local installation of MongoDB thru terminal - mongodb

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.

Related

Unable to run mongod server on CentOS

When i try to run my mongod server on CentOS the result of npm start is this error:
root#server[Taxi]# npm start
> vframework#0.0.1 start /home/user/public_html/Taxi
> node server
/home/user/public_html/Taxi/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:72
const MongoParseError = function(message) {
^^^^^
the version of mongod is 2.4.14 and when i run the #mongod -v command i got this error
root#server [Taxi]# mongod -v
Fri Mar 30 19:07:42.038 BackgroundJob starting: DataFileSync
Fri Mar 30 19:07:42.038 versionArrayTest passed
Fri Mar 30 19:07:42.069 shardKeyTest passed
Fri Mar 30 19:07:42.069 isInRangeTest passed
Fri Mar 30 19:07:42.069 shardObjTest passed
Fri Mar 30 19:07:42.096 [initandlisten] MongoDB starting : pid=24586 port=27017 dbpath=/data/db/ 64-bit host=server
Fri Mar 30 19:07:42.096 [initandlisten] db version v2.4.14
Fri Mar 30 19:07:42.096 [initandlisten] git version: nogitversion
Fri Mar 30 19:07:42.096 [initandlisten] build info: Linux buildvm-11.phx2.fedoraproject.org 4.7.2-201.fc24.x86_64 #1 SMP Fri Aug 26 15:58:40 UTC 2016 x86_64 BOOST_LIB_VERSION=1_41
Fri Mar 30 19:07:42.096 [initandlisten] allocator: tcmalloc
Fri Mar 30 19:07:42.096 [initandlisten] options: { verbose: true }
Fri Mar 30 19:07:42.138 [initandlisten] User Assertion: 10310:Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?
Fri Mar 30 19:07:42.176 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?, terminating
Fri Mar 30 19:07:42.177 dbexit:
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: going to close listening sockets...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: going to flush diaglog...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: going to close sockets...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: waiting for fs preallocator...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: lock for final commit...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: final commit...
Fri Mar 30 19:07:42.177 [initandlisten] shutdown: closing all files...
Fri Mar 30 19:07:42.179 [initandlisten] closeAllFiles() finished
Fri Mar 30 19:07:42.179 dbexit: really exiting now
i added a mongod.config file to path /etc/ fo specify the server adress and this is it's content
root#server [etc]# cat mongod.conf
logpath=/var/log/mongo/mongod.log
port=27027
bind_ip=0.0.0.0
dbpath=/var/lib/mongo
replSetName: rs0

MongoDB Start several mongod with different ports

I can't change port in second mongod in my cmd
1 I'm starting mongod in c:\mongodb\bin
2 I'm starting cmd and writing
cd c:\mongodb\bin
mongod --port 10003
But second mongod not work.
Help me.Thank you!
This is error what show me
C:\Windows\system32> cd c:\mongodb\bin
c:\mongodb\bin>mongod --port 10003
Wed Apr 16 22:15:56.619
Wed Apr 16 22:15:56.620 warning: 32-bit servers don't have journaling enabled by
default. Please use --journal if you want durability.
Wed Apr 16 22:15:56.622
Wed Apr 16 22:15:56.635 [initandlisten] MongoDB starting : pid=8240 port=10003 d
bpath=\data\db\ 32-bit host=Danil
Wed Apr 16 22:15:56.637 [initandlisten]
Wed Apr 16 22:15:56.638 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
.
Wed Apr 16 22:15:56.640 [initandlisten] ** 32 bit builds are limited to le
ss than 2GB of data (or less with --journal).
Wed Apr 16 22:15:56.641 [initandlisten] ** Note that journaling defaults t
o off for 32 bit and is currently off.
Wed Apr 16 22:15:56.643 [initandlisten] ** See http://dochub.mongodb.org/c
ore/32bit
Wed Apr 16 22:15:56.645 [initandlisten]
Wed Apr 16 22:15:56.646 [initandlisten] db version v2.4.10
Wed Apr 16 22:15:56.648 [initandlisten] git version: e3d78955d181e475345ebd60053
a4738a4c5268a
Wed Apr 16 22:15:56.650 [initandlisten] build info: windows sys.getwindowsversio
n(major=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST
_LIB_VERSION=1_49
Wed Apr 16 22:15:56.651 [initandlisten] allocator: system
Wed Apr 16 22:15:56.653 [initandlisten] options: { port: 10003 }
Wed Apr 16 22:15:56.655 [initandlisten] exception in initAndListen: 13627 Unable
to create/open lock file: \data\db\mongod.lock ??????? ?? ????? ???????? ??????
? ?????, ??? ??? ???? ???? ????? ?????? ?????????.. Is a mongod instance alread
y running?, terminating
Wed Apr 16 22:15:56.657 dbexit:
Wed Apr 16 22:15:56.658 [initandlisten] shutdown: going to close listening socke
ts...
Wed Apr 16 22:15:56.660 [initandlisten] shutdown: going to flush diaglog...
Wed Apr 16 22:15:56.662 [initandlisten] shutdown: going to close sockets...
Wed Apr 16 22:15:56.663 [initandlisten] shutdown: waiting for fs preallocator...
Wed Apr 16 22:15:56.665 [initandlisten] shutdown: closing all files...
Wed Apr 16 22:15:56.666 [initandlisten] closeAllFiles() finished
Wed Apr 16 22:15:56.668 dbexit: really exiting now
c:\mongodb\bin>
try to start mongod with admin option as it is not able to open the file mongod.lock
You can't start multiple MongoDB processes on the same database.
What you need to do is:
mongod --dbpath c:\database1 --port 27017
mongod --dbpath c:\database2 --port 27018
Remember that you must manually create the database folders.
Usually if you read carefully the error log you will find the problem:
"13627 Unable to create/open lock file: \data\db\mongod.lock.
Is a mongod instance already running?"

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

Start mongo failed

I get an error when I try to start mongo using the "mongod" command (on Macintosh).
all output going to: /usr/local/var/log/mongodb/mongo.log
My logs :
***** SERVER RESTARTED *****
Tue Oct 29 13:15:48.783 [initandlisten] MongoDB starting : pid=859 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=MacBook-Pro-de-Anthony
Tue Oct 29 13:15:48.784 [initandlisten] db version v2.4.4
Tue Oct 29 13:15:48.784 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2
Tue Oct 29 13:15:48.784 [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
Tue Oct 29 13:15:48.784 [initandlisten] allocator: system
Tue Oct 29 13:15:48.784 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }
Tue Oct 29 13:15:48.784 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Tue Oct 29 13:15:48.784 [initandlisten] recover : no journal files present, no recovery needed
Tue Oct 29 13:15:48.801 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:27017
Tue Oct 29 13:15:48.801 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:28017
Tue Oct 29 13:15:48.801 [initandlisten] ERROR: addr already in use
Tue Oct 29 13:15:48.801 [websvr] ERROR: addr already in use
Tue Oct 29 13:15:48.801 [initandlisten] now exiting
Tue Oct 29 13:15:48.801 dbexit:
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to close sockets...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: lock for final commit...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: final commit...
Tue Oct 29 13:15:48.802 [initandlisten] shutdown: closing all files...
Tue Oct 29 13:15:48.802 [initandlisten] closeAllFiles() finished
Tue Oct 29 13:15:48.802 [initandlisten] journalCleanup...
Tue Oct 29 13:15:48.802 [initandlisten] removeJournalFiles
Tue Oct 29 13:15:48.803 [initandlisten] shutdown: removing fs lock...
Tue Oct 29 13:15:48.803 dbexit: really exiting now
UPDATE:
When I execute the "mongo" command :
MacBook-Pro-de-Anthony:Sites anthonycluse$ mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings:
Tue Oct 29 11:43:15 [initandlisten]
Tue Oct 29 11:43:15 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show dbs;
anthonycluse (empty)
local (empty)
>
It means that the username is "test" no?
UPDATE 2 :
The "show users;" command :
MacBook-Pro-de-Anthony:Sites anthonycluse$ mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings:
Tue Oct 29 11:43:15 [initandlisten]
Tue Oct 29 11:43:15 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show users;
>
Is there another process listening on those ports? Try finding out with:
netstat -tulpen | grep 017 # 017 for both port 27017 and 28017
Kill that process if you're sure you don't need it. As answered below by Lix, there may already be a mongo process running.
The answer is right there in side the log file:
Tue Oct 29 13:15:48.801 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:28017
Specifically this part: "Address already in use for socket: 127.0.0.1:28017"
It seems that there is already a mongo instance running on that default port 27017. It might not even be a mongo instance but some other application that is using that port.
As per the logs it is clear that there is another mongodb instance running on default, i believe you installed mongodb using rpm and started this service using service mongodb start. so when the server restarts by default it starts some of the services, using defaultconfiguration which will be avialble in /etc/mongod.config edit this file or stop the one which is running already so you can avoid the mongod default instamce and made ur version to up and running

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