Mongodb 启动时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23983708/
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 13:44:20  来源:igfitidea点击:

Mongodb error on starting

mongodbterminal

提问by Ewan

When i start mongo db it instantly crashes and goes back to the normal command line. I am on Mac runing the MEAN stack if that helps. Below is the error:

当我启动 mongo db 时,它立即崩溃并返回到正常的命令行。如果有帮助,我在 Mac 上运行 MEAN 堆栈。下面是错误:

$sudo mongod

$sudo mongod

Sun Jun  1 21:01:01.728 [initandlisten] MongoDB starting : pid=47937 port=3000 dbpath=/usr/local/var/mongodb 64-bit host=NoHax4You
Sun Jun  1 21:01:01.728 [initandlisten] 
Sun Jun  1 21:01:01.729 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Sun Jun  1 21:01:01.729 [initandlisten] db version v2.4.9
Sun Jun  1 21:01:01.729 [initandlisten] git version: nogitversion
Sun Jun  1 21:01:01.729 [initandlisten] build info: Darwin minimavericks.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Sun Jun  1 21:01:01.729 [initandlisten] allocator: tcmalloc
Sun Jun  1 21:01:01.729 [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", port: 3000 }
Sun Jun  1 21:01:01.729 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /usr/local/var/mongodb/mongod.lock. Is a mongod instance already running?, terminating
Sun Jun  1 21:01:01.729 dbexit: 
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: going to close listening sockets...
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: going to flush diaglog...
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: going to close sockets...
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: waiting for fs preallocator...
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: lock for final commit...
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: final commit...
Sun Jun  1 21:01:01.729 [initandlisten] shutdown: closing all files...
Sun Jun  1 21:01:01.729 [initandlisten] closeAllFiles() finished
Sun Jun  1 21:01:01.729 dbexit: really exiting now

Thanks, Ewan

谢谢,伊万

回答by displayName

First of all, look for other instances of mongod running on the system using the age-old command:

首先,使用 age-old 命令查找系统上运行的其他 mongod 实例:

ps ax | grep mongod

If you see a line like -

如果你看到这样的一行 -

98555   ??  S      4:40.89 mongod --dbpath /Volumes/ComputerName/data/db 
-PID-                      -name-          -------------path------------

then there is a mongod process running already. If so kill it and then start mongod again.

那么已经有一个 mongod 进程正在运行。如果是这样,请杀死它,然后再次启动 mongod。

To kill a process with PID = 0000, in Unix like environment use -

要杀死 PID = 0000 的进程,请在类 Unix 环境中使用 -

kill -9 0000

If your console returns something like, -bash: kill: (98555) - Operation not permitted, use

如果您的控制台返回类似的内容-bash: kill: (98555) - Operation not permitted,请使用

sudo !! 

to repeat the command as super user. This should get you going.

超级用户身份重复该命令。这应该能让你继续前进。



PS: If you haven't stored any data in your db yet, delete /dataand then create the /data/dbdirectory again. Do a sudo mongodand it should work.

PS:如果您的数据库中还没有存储任何数据,请删除/data然后重新创建/data/db目录。做一个sudo mongod,它应该工作。

回答by EsterlingAccime Youtuber

I had the same issue, and this one liner fix my issue

我有同样的问题,这个班轮解决了我的问题

killall mongod

Run the above command inside your Terminal

终端中运行上述命令

Hope that helps!

希望有帮助!

回答by mjenn

I first opened the /data/db/mongod.lock file, found my process number there, then killed it with kill -9 <processnumber>. That worked for me.

我首先打开 /data/db/mongod.lock 文件,在那里找到我的进程号,然后用kill -9 <processnumber>. 那对我有用。