MongoDB没有作为服务运行

时间:2018-09-19 14:13:08

标签: mongodb macos homebrew

我已经在OSX上安装了Mongo

$ brew info mongodb
mongodb: stable 4.0.2 (bottled)
...

我通过以下命令启动MongoDB服务:

$ brew services start mongodb

我可以观察mongodb的状态:

$ brew services list
Name    Status  User  Plist
mongodb started megas /Users/megas/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
...

但是当我运行mongo客户端时,会给我一个错误:

$ mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-19T15:18:22.490+0300 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:257:13
@(connect):1:6
exception: connect failed

当我手动启动mongod时,它应能正常工作。

我在这里缺少什么?

更新: 如果我手动运行它,它将通过消息并停止

$ mongod --config /usr/local/etc/mongod.conf
2018-09-19T21:47:51.531+0300 I CONTROL  [main] Automatically disabling 
TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'

$ cat /usr/local/etc/mongod.conf
# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb

# Append logs to /usr/local/var/log/mongodb/mongo.log
logpath = /usr/local/var/log/mongodb/mongo.log
logappend = true

# Only accept local connections
bind_ip = 127.0.0.1

0 个答案:

没有答案