mongodb 无法启动mongodb本地服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6478113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 12:08:01  来源:igfitidea点击:

unable to start mongodb local server

mongodb

提问by sakthig

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

我是 mongodb 的新手 .. 当我尝试使用mongod命令运行 mongodb 本地服务器时,它无法运行并抛出此错误..

/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:38:51 dbexit: really exiting now

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

我尝试删除mongod.lock文件...我跑了mongod --repair...我还更改了mongod.lock文件的权限。

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..

我也安装了 git 版本 1.7.4.1 但它显示 nogitversion 错误..

回答by morphy

Try:

尝试:

sudo service mongod stop
sudo mongod

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

停止当前活动的 mongodb 服务,然后允许您启动一个新服务

回答by R.S

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

不要使用 -9 信号终止进程,因为它会造成损坏:http: //www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo#StartingandStoppingMongo-SendingaUnixINTorTERMsignal

Use sudo killall -15 mongodinstead

使用sudo killall -15 mongod替代

回答by Sacha Nacar

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."

安德烈亚斯·荣格:

“周六 6 月 25 日 09:38:51 [initandlisten] listen(): bind() failed errno:98 地址已用于套接字:0.0.0.0:27017

是自言自语。

mongod 的另一个实例已经在运行并分配 MongoDB 默认端口 27017。

要么终止另一个进程,要么使用不同的端口。”

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):

现在输入 mongod 实例的 kill 命令(在本例中为 31936):

kill 31936

回答by kabirkukreti

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

从 netstat 找出哪个进程正在运行 mongodb 端口 (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:

在我的情况下,“6432”是pid,在你的情况下可能会有所不同。然后使用以下命令终止该进程:

sudo kill <pid>

Thats it!

就是这样!

回答by 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

周六 6 月 25 日 09:38:51 [initandlisten] listen(): bind() failed errno:98 地址已用于套接字:0.0.0.0:27017

is self-speaking.

是自言自语。

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

mongod 的另一个实例已经在运行并分配 MongoDB 默认端口 27017。

Either kill the other process or use a different port.

要么杀死另一个进程,要么使用不同的端口。

回答by Asutosh Hota

Use:

用:

sudo killall mongod

It will stop the server.

它将停止服务器。

Then restart mongodby:

然后mongod通过以下方式重新启动:

sudo service mongod restart

it should work.

它应该工作。

回答by Younux

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

您已经有一个正在运行的进程。您可以使用以下命令杀死它:

killall mongod

回答by John Ottenlips

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

你想这样做killall -15 mongod是因为它仍在运行:Address already in use for socket: 0.0.0.0:27017

Then you can run mongodagain.

然后你可以mongod再次运行。

回答by Nick Cuevas

I suggest use instead:

我建议改用:

$sudo service mongodb stop

$sudo service mongodb stop

That could work.

那可以工作。

回答by Samantha

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.

如果找不到任何当前正在运行的进程或杀死它们不起作用,请尝试不同的端口。例如,尝试 27018,因为默认值为 27017。

mongod  --port 27018

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

我用命令发现了这一点, mongod --help