使用 Homebrew 启动/停止 MongoDB
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32974639/
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
Start / Stop MongoDB with Homebrew
提问by Knows Not Much
I am using mac osx 10.10.5
我使用的是 mac osx 10.10.5
This question has been asked many times before and after following the steps, I notice bizarre behavior.
在执行这些步骤之前和之后,这个问题已经被问过很多次,我注意到了奇怪的行为。
These are the steps which I have taken
这些是我采取的步骤
brew tap gapple/services
brew install mongodb
This installs the product and now when I do brew services list
I can see mongodb in a stopped state.
这将安装产品,现在当我安装时,brew services list
我可以看到 mongodb 处于停止状态。
When I tried to start the process by brew services start mongodb
I get an error
当我尝试通过brew services start mongodb
我收到错误来启动该过程时
Error: Could not read the plist for mongodb
!
错误:无法读取mongodb
!
OK. I googled a solution
好的。我用谷歌搜索了一个解决方案
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mongodb/3.0.6/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/
Now as soon as the file is copied, when I do brew services list
... the mongo process is automatically running.
现在,一旦文件被复制,当我这样做时brew services list
...... mongo 进程会自动运行。
Now when I do brew services stop mongodb
It says
现在当我这样做时brew services stop mongodb
它说
Error: Service `mongodb` not running, wanna start it? Try `brew services start mongodb`
Now this is bizarre, because just in the last step it said its running. Now when I do
现在这很奇怪,因为就在最后一步,它说它正在运行。现在当我做
mongodb services list
it says that the service is stopped. (so the stop command above did work. Even though it threw an error).
mongodb services list
它说服务已停止。(所以上面的停止命令确实有效。即使它抛出了一个错误)。
Now if I do
现在如果我这样做
brew services start mongodb
It gives error Error: Could not read the plist for mongodb
!
它给出了错误错误:无法读取mongodb
!
Now if I copy the file again
现在如果我再次复制文件
cp /usr/local/Cellar/mongodb/3.0.6/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/
The service automatically begins to run.
该服务自动开始运行。
I find this whole thing really bizarre. All I want is a clean way to start stop the mongo db service. And although there are many threads on this site (and elsewhere) ... they don't work or just have strange behavior.
我觉得这整件事真的很奇怪。我想要的只是一种开始停止 mongo db 服务的干净方式。尽管这个站点(和其他地方)上有很多线程……它们不起作用或只是有奇怪的行为。
回答by Trimal
For me I had multiple version of mongodb and when I tried to switching between them, I got this error
对我来说,我有多个版本的 mongodb,当我尝试在它们之间切换时,出现了这个错误
Error: Could not read the plist for `mongodb26`!
This is what I did to start mongodb26 service.
这就是我为启动 mongodb26 服务所做的。
brew unlink mongodb24
brew link mongodb26
brew services start mongodb26
回答by Abhilash
brew services start/restart/stop [email protected]
回答by DonRichards
回答by damdeez
You can list services by doing
brew services list
and then as one of the answers said brew service start [NAME]
or brew service stop [NAME]
您可以通过执行brew services list
然后作为答案之一列出服务
brew service start [NAME]
或brew service stop [NAME]