开发者

unable to start mongodb local server

开发者 https://www.devze.com 2023-03-15 14:33 出处:网络
I am new to mongodb .. when i tried running mongodb local server with mongod command it failed to run and threw this error..

I am new to mongodb .. when i tried running mongodb local server with mongod command it failed to run and threw this error..

/usr/lib/mongodb/mongod --help for help and startup options
Sat Jun 25 09:38:51 MongoDB starting : pid=1782 port=27017 dbpath=/data/db/ 32-bit 

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
**       see http://blog.mongodb.org/post/137788967/32-bit-limitations

Sat Jun 25 09:38:51 db version v1.6.3, pdfile version 4.5
Sat Jun 25 09:38:51 git version: nogitversion
Sat Jun 25 09:38:51 sys info: Linux vernadsky 2.6.24-27-server #1 SMP Fri Mar 12 01:45:06 UTC 2010 i686 BOOST_LIB_VERSION=1_42
Sat Jun 25 09:38:51 [initandlisten] *** warning: spider monkey build without utf8 support.  consider rebuilding with utf8 support
Sat Jun 25 09:38:51 [initandlisten] waiting for connections on port 27017
Sat Jun 25 09:38:51 [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Sat Jun 25 09:38:51 [initandlisten]   addr already in use
Sat Jun 25 09:38:51 [initandlisten] now exiting
Sat Jun 25 09:38:51 dbexit: 

Sat Jun 25 09:38:51 [initandlisten] shutdown: going to close listening sockets...
Sat Jun 25 09:38:51 [initandlisten] shutdown: going to flush oplog...
Sat Jun 25 09:38:51 [initandlisten] shutdown: going to close sockets...
Sat Jun 25 09:38:51 [initandlisten] shutdown: waiting for fs preallocator...
Sat Jun 25 09:38:51 [initandlisten] shutdown: closing all files...
Sat Jun 25 09:38:51     closeAllFiles() finished

Sat Jun 25 09:38:51 [initandlisten] shutdown: removing fs lock...
Sat Jun 25 09:3开发者_StackOverflow中文版8:51 dbexit: really exiting now

I tried deleting mongod.lock file... I ran mongod --repair.. I also changed permissions to mongod.lock file.

but nothing seems to work.. it keeps showing the same error.. what should i do.?

I also have installed git version 1.7.4.1 but it shows nogitversion in error..


Try:

sudo service mongod stop
sudo mongod

To stop current active mongodb service, allowing you to then start a new one


Don't kill the process using the -9 signal as it would cause damage: http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo#StartingandStoppingMongo-SendingaUnixINTorTERMsignal

Use sudo killall -15 mongod instead


Andreas Jung:

"Sat Jun 25 09:38:51 [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017

is self-speaking.

Another instance of mongod is already running and allocating the MongoDB default port which is 27017.

Either kill the other process or use a different port."

In this case, type the following command

ps wuax | grep mongo

You should see something that looks like this

User           31936   0.5 0.4 2719784 35624   ?? S     7:34pm   0:09.98 mongod
User           31945   0.0 0.0 2423368   184 s000 R+   8:24pm   0:00.00 grep mongo

Now enter the kill command for the mongod instance (31936 in this case):

kill 31936


Sat Jun 25 09:38:51 [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017

is self-speaking.

Another instance of mongod is already running and allocating the MongoDB default port which is 27017.

Either kill the other process or use a different port.


Find out from netstat which process is running mongodb port (27017)

command:

sudo netstat -tulpn | grep :27017

Output will be:

tcp        0      0 0.0.0.0:27017           0.0.0.0:* 
LISTEN      6432/mongod

In my case "6432" is the pid, it may be different in your case. Then kill that process using following command:

sudo kill <pid>

Thats it!


Use:

sudo killall mongod

It will stop the server.

Then restart mongod by:

sudo service mongod restart

it should work.


You already have a process running. You can kill it with the command :

killall mongod


You want to do killall -15 mongod because it is still running: Address already in use for socket: 0.0.0.0:27017.

Then you can run mongod again.


Try a different port if you can't find any current running processes or killing them doesn't work. For example, try 27018 because the default is 27017.

mongod  --port 27018

I found this out with the command, mongod --help


I suggest use instead:

$sudo service mongodb stop

That could work.


Try either killall -15 mongod/ killall mongod Even after this if this doesnt work then remove the db storage folder by typing the following commands sudo rm -rf /data/db sudo mkdir /data/db sudo chmod 777 /data/db


OS X. Activity Monitor, look for mongod, cross it . then run again mongod. problem Solved.


Open the terminal and type:

mkdir -p /data/db

Then enter:

mongod


MongoDB unable to start is mainly due to unclean shutdown. To remedy, delete the mongod.lock file. This file is located in the data folder.

Find out where your data folder is by looking in the mongodb.conf or mongod.conf file. (Conf file under /etc on Linux systems.)

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb

For example using the above configuration, the file is at /var/lib/mongodb/mongod.lock. Simply remove it and restart mongodb.


I had the same problem were I tried to open a new instance of mongod and it said it was already running.

I checked the docs and it said to type

mongo
use admin
db.shutdownServer()


I've faced the same issue. Though the mongodb service is not running, the log showed address already in use message.

 $netstat -tulpn | grep :27017 

returns nothing

On further analysis found that the issue was due to lock file. The service is running fine, after deleting the lock file and restarting it.

$grep "dbpath" /etc/mongodb.conf

dbpath =/var/lib/mongodb

$ls /var/lib/mongodb/mongod.lock

$service mongod start


Check for logs at /var/log/mongodb/mongod.log and try to deduce the error. In my case it was

Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted

Deleted /tmp/mongodb-27017.sock and it worked.


try

/usr/lib/mongodb/mongod.exe --dbpath c:data\db

--dbpath (should be followed by the path of your db)


It may be possible that the server is already running. Please check it by the command mongo is working or not.


To resolve the issue in Windows, the below steps work for me:

For example mongoDB version 3.6 is installed, and the install path of MongoDB is "D:\Program Files\MongoDB".

Create folder D:\mongodb\logs, then create file mongodb.log inside this folder.

Run cmd.exe as administrator,

D:\Program Files\MongoDB\Server\3.6\bin>taskkill /F /IM mongod.exe
D:\Program Files\MongoDB\Server\3.6\bin>mongod.exe --logpath D:\mongodb\logs\mongodb.log --logappend --dbpath D:\mongodb\data --directoryperdb --serviceName MongoDB --remove
D:\Program Files\MongoDB\Server\3.6\bin>mongod --logpath "D:\mongodb\logs\mongodb.log" --logappend --dbpath "D:\mongodb\data" --directoryperdb --serviceName "MongoDB" --serviceDisplayName "MongoDB" --install

Remove these two files mongod.lock and storage.bson under the folder "D:\mongodb\data".

Then type net start MongoDB in the cmd using administrator privilege, the issue will be solved.


It shows error listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017 i.e. 27017 address is already in used by some other service. please check this by "netstat -apt| grep "27017"" command


(If your're using linux,) if

mongod --shutdown --config=path/to/your/configFile.conf 

or

mongod --repair --config=path/to/your/configFile.conf 

didn't fix the issue, logout and re-login. That solved my problem.

Or you can kill the process manually from terminal, I guess.


It looks like the same error is showed in logs when you're missing LC_ALL environment setting. It's confusing, but you may execute mongo client to see that it's a problem.


if you are running mongo for first time you might wanna set the path first

mongod --dbpath <path to the directory>


Killing process did not solve my issue. My mac had crashed and on restart some of lock files (mongod.lock, WiredTiger.lock) were present in mongo dbPath. I moved these files to different folder (I did not delete to avoid more issues) and then it worked. On successul star, I deleted the moved lock files.

0

精彩评论

暂无评论...
验证码 换一张
取 消