首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >brew服务启动mongodb社区@4.2错误:未知命令:服务

brew服务启动mongodb社区@4.2错误:未知命令:服务
EN

Stack Overflow用户
提问于 2020-03-13 12:27:31
回答 2查看 10.3K关注 0票数 5

我试图通过运行MongoDB来运行brew services start mongodb-community@4.2,但是我得到了如下所示的错误:

代码语言:javascript
运行
复制
jaimes-mbp:SMR jaimemontoya$ brew services start mongodb-community@4.2
==> Tapping homebrew/services
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 27 (delta 0), reused 16 (delta 0), pack-reused 0
Unpacking objects: 100% (27/27), done.
Checking connectivity... done.
Tapped 0 formulae (63 files, 276K)
Error: Unknown command: services
jaimes-mbp:SMR jaimemontoya$ 

brew不是命令,而services不是一个参数吗?我不明白为什么错误说services是一个未知的命令。谢谢。

更新1:当我再次尝试运行brew install mongodb-community@4.2时会看到两个警告。也许这和问题有关吧?

代码语言:javascript
运行
复制
jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community@4.2
Warning: mongodb/brew/mongodb-community-4.2.3 already installed
Warning: You are using OS X 10.15.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.

更新2:当我使用mongo时,它正在做一些事情:

代码语言:javascript
运行
复制
jaimes-mbp:SMR jaimemontoya$ mongo
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-03-13T06:41:22.073-0600 E  QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-03-13T06:41:22.076-0600 F  -        [main] exception: connect failed
2020-03-13T06:41:22.076-0600 E  -        [main] exiting with code 1
jaimes-mbp:SMR jaimemontoya$  

也许我不需要使用brew services start mongodb-community@4.2?我认为有必要运行MongoDB Community。

更新3:我运行ps aux | grep -v grep | grep mongod,它什么也不返回。我试图验证MongoDB是否在运行,所以我在运行过程中搜索mongod,但它没有返回任何内容,这意味着MongoDB没有运行。

更新4:查看运行brew doctor --verbose时会发生什么

代码语言:javascript
运行
复制
Warning: You are using OS X 10.15.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

您可能应该将/usr/local的所有权和权限更改回您的用户帐户。sudo $(whoami):admin /usr/local

当我运行sudo chown -R $(whoami):admin /usr/local时,我得到了这样的信息:

代码语言:javascript
运行
复制
jaimes-mbp:SMR jaimemontoya$ sudo chown -R $(whoami):admin /usr/local
Password:
chown: /usr/local: Operation not permitted
jaimes-mbp:SMR jaimemontoya$ 

brew update不起作用:

代码语言:javascript
运行
复制
jaimes-mbp:SMR jaimemontoya$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local
jaimes-mbp:SMR jaimemontoya$ 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-03-13 14:12:34

我遵循了MikeMcQuaid在https://github.com/Homebrew/brew/issues/3665上提供的建议

您需要使用https://github.com/Homebrew/install卸载和安装自制的

正如在https://github.com/Homebrew/install上解释的那样,我首先运行了/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"。之后,我运行了/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

然后我做了这个:

代码语言:javascript
运行
复制
jaimes-mbp:SMR jaimemontoya$ brew tap mongodb/brew
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.

==> Tapping mongodb/brew
Cloning into '/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew'...
remote: Enumerating objects: 86, done.
remote: Counting objects: 100% (86/86), done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 145 (delta 41), reused 21 (delta 10), pack-reused 59
Receiving objects: 100% (145/145), 30.18 KiB | 2.16 MiB/s, done.
Resolving deltas: 100% (68/68), done.
Tapped 6 formulae (33 files, 83.0KB).
jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community@4.2
==> Installing mongodb-community from mongodb/brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.3.tgz
######################################################################## 100.0%
==> Caveats
To have launchd start mongodb/brew/mongodb-community now and restart at login:
  brew services start mongodb/brew/mongodb-community
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
  /usr/local/Cellar/mongodb-community/4.2.3: 21 files, 304.3MB, built in 1 minute 54 seconds
jaimes-mbp:SMR jaimemontoya$ brew services start mongodb-community@4.2
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 88, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 691 (delta 31), reused 69 (delta 25), pack-reused 603
Receiving objects: 100% (691/691), 192.79 KiB | 1.68 MiB/s, done.
Resolving deltas: 100% (270/270), done.
Tapped 1 command (39 files, 266.3KB).
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
jaimes-mbp:SMR jaimemontoya$ ps aux | grep -v grep | grep mongod
jaimemontoya     17763   0.1  0.2  5544164  38300   ??  S     8:11AM   0:00.65 /usr/local/opt/mongodb-community/bin/mongod --config /usr/local/etc/mongod.conf
jaimes-mbp:SMR jaimemontoya$ 

它起作用了!

票数 1
EN

Stack Overflow用户

发布于 2020-03-13 13:04:15

似乎您正面临着brew的问题。

运行brew doctor --verbose以检查brew是否正常工作。

然后brew update更新brew版本。

在此运行之后,brew services list将显示brew中的所有服务。

如果在列表中看到mongodb@4.2,则运行brew services start mongodb-community@4.2

应该管用的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60670469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档