停止:未知实例 mongodb (Ubuntu)

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

Stop: Unknown instance mongodb (Ubuntu)

mongodbubuntuservicerestart

提问by senthil

I am new to Mongodb. When I run the following command:

我是 Mongodb 的新手。当我运行以下命令时:

sudo service mongodb start

It shows me "mongodb start/running, process 3566". But when I try to stop by giving the below command:

它向我显示"mongodb start/running, process 3566"。但是当我尝试通过给出以下命令来停止时:

sudo service mongodb stop

It shows stop: Unknown instance:. Do anybody have any idea how to slove this issue.

它显示停止:未知实例:。有没有人知道如何解决这个问题。

And if I give sudo service mongodb restart, I'm getting the below message:

如果我给sudo service mongodb restart,我会收到以下消息:

stop: Unknown instance: 
mongodb start/running, process 3644

PS: If I'm using just mongod, I could start the server and could connect the mongo shell by giving mongo.

PS:如果我只使用mongod,我可以启动服务器并可以通过给mongo连接 mongo shell 。

Please suggest me how to fix the issue and how to connect mongo shell after giving service mongodb start. Thanks in advance.

请建议我如何解决问题以及如何在提供service mongodb start后连接 mongo shell 。提前致谢。

回答by GoingTharn

I just ran into this. Chances are the issue is in your conf file (obviously, since you reinstalled the seeded)

我刚遇到这个。问题很可能出在您的 conf 文件中(显然,因为您重新安装了种子)

In the mongodb.conf do not set fork = true if calling it as a service. This will prevent the service call from being able to access it with service mongodb.conf status/stop/restart.

如果将其作为服务调用,则在 mongodb.conf 中不要设置 fork = true。这将阻止服务调用能够通过 service mongodb.conf status/stop/restart 访问它。

Removing a fork=True line, however, will alleviate the issue.

但是,删除 fork=True 行将缓解该问题。

See comments; use the other solution even though this one is accepted.

看评论; 即使接受了这个解决方案,也要使用其他解决方案。

回答by Alex P.

The reason you get the Unknown instanceerror is because upstartis tracking the wrong PIDfor the instance of forked mongodprocess. But the proper solution to this is not running the process in foreground by removing fork=trueline from the config like @GoingTharn suggesting, but rather helping upstartto capture the right PIDof the forked process by adding

您收到Unknown instance错误的原因是因为upstart正在跟踪PID分叉mongod进程实例的错误。但是对此的正确解决方案不是通过fork=true从配置中删除行(如@GoingTharn 建议)来在前台运行进程,而是通过添加来帮助upstart捕获PID分叉进程的权利

expect daemon

to the /etc/init/mongodb.conf

/etc/init/mongodb.conf

回答by Tanvir

I faced exactly the same problem and did the followings:

我遇到了完全相同的问题并执行了以下操作:

  • Removed the file mongod.lock (in my case this file was located at /var/lib/mongodb/)
  • Used the following command from my mongo client
  • 删除文件 mongod.lock (在我的情况下,此文件位于 /var/lib/mongodb/)
  • 使用来自我的 mongo 客户端的以下命令

mongo --repair

蒙戈--修复

And that fixed the issue. It may be noted that I had a system crash prior to this problem appeared. Therefore, what I believe, the problem was caused due to the unclean shutdown of the server demon.

这解决了这个问题。可能会注意到,在出现此问题之前,我曾发生系统崩溃。因此,我相信,问题是由于服务器恶魔的不正常关闭造成的。

If you are unsure of the reason, you may wish to have a look at the log file (in my case I found it under /var/log/mongodb/). That might give you some useful hints.

如果您不确定原因,您可能希望查看日志文件(在我的情况下,我在 /var/log/mongodb/ 下找到了它)。这可能会给你一些有用的提示。

Thanks.

谢谢。

回答by wendy

I faced it as you had.Maybe it is because my computer crash unexpectedly.I use the command: sudo top(ubuntu), and I found mongo running.I killed it and start mongo.Every thing turns right.

我和你一样面对它。也许是因为我的电脑意外崩溃。我使用命令:sudo top(ubuntu),我发现mongo正在运行。我杀死它并启动mongo。一切都变好了。

回答by senthil

I fixed it by myself. Below is what I did:

我自己修好了。以下是我所做的:

 apt-get install mongodb

And overwrote .conf file. After that everything works fine. I hope this would help someone.

并覆盖 .conf 文件。之后一切正常。我希望这会帮助某人。