【问题标题】:MongoDB on macOS: How do I resolve chown: data/db: No such file or directorymacOS 上的 MongoDB:如何解决 chown: data/db: No such file or directory
【发布时间】:2021-12-18 08:48:13
【问题描述】:

我通过 Homebrew 安装了 MongoDB,并创建了 /data/db 目录。

当我运行sudo chown -R id -un /data/db 时。我收到此错误:

chown: data/db: 没有那个文件或目录

我已经尝试了所有可以在网上找到的解决方案,我发现该目录存在,但我不确定发生了什么。当我运行 mongod 这就是我得到的结果:

Solomons-MacBook-Pro:expense-tracker Solomon$ mongod {"t":{"$date":"2021-11-07T19:02:47.741-08:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"-","msg":"初始化线 规范","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":13},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":13},"传出":{"minWireVersion":0,"maxWireVersion":13},"isInternalClient":true}}} {"t":{"$date":"2021-11-07T19:02:47.747-08:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"自动 禁用 TLS 1.0,强制启用 TLS 1.0 指定 --sslDisabledProtocols 'none'"} {"t":{"$date":"2021-11-07T19:02:47.748-08:00"},"s":"W", "c":"ASIO ",
"id":22601, "ctx":"main","msg":"期间没有配置 TransportLayer 网络接口启动"} {"t":{"$date":"2021-11-07T19:02:47.748-08:00"},"s":"I", "c":"NETWORK", "id":4648602, "ctx":"main","msg":"隐式 TCP FastOpen 正在使用中。"} {"t":{"$date":"2021-11-07T19:02:47.754-08:00"},"s":"W", "c":"ASIO",
"id":22601, "ctx":"main","msg":"期间没有配置 TransportLayer 网络接口启动"} {"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"REPL",
"id":5123008, "ctx":"main","msg":"注册成功 PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","ns":"config.tenantMigrationDonors"}} {"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"REPL",
"id":5123008, "ctx":"main","msg":"注册成功 PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","ns":"config.tenantMigrationRecipients"}} {"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB 开始","attr":{"pid":3449,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"Solomons-MacBook- Pro.local"}} {"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", “c”:“控制”,“id”:23403,“ctx”:“initandlisten”,“msg”:“构建 Info","attr":{"buildInfo":{"version":"5.0.3","gitVersion":"657fea5a61a74d7a79df7aff8e4bcf0bc742b748","modules":[],"allocator":"system","environment": {"distarch":"x86_64","target_arch":"x86_64"}}}} {"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"操作中 系统","attr":{"os":{"name":"Mac OS X","version":"21.1.0"}}} {"t":{"$date":"2021-11-07T19:02:47.756-08:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"选项集 通过命令行","attr":{"options":{}}} {"t":{"$date":"2021-11-07T19:02:47.758-08:00"},"s":"E", "c":"NETWORK", "id":23024, "ctx":"initandlisten","msg":"失败 取消链接套接字 文件","attr":{"path":"/tmp/mongodb-27017.sock","error":"权限 拒绝"}} {"t":{"$date":"2021-11-07T19:02:47.758-08:00"},"s":"F", “c”:“-”,“id”:23091,“ctx”:“initandlisten”,“msg”:“致命 断言","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":960}} {"t":{"$date":"2021-11-07T19:02:47.758-08:00"},"s":"F", "c":"-",
"id":23092, "ctx":"initandlisten","msg":"\n\n***后中止 fassert() 失败\n\n"}

【问题讨论】:

  • 究竟是什么问题?意思是/data/db 不是文件。而且我认为在大多数 GNU/Linux 发行版中,/data 不是标准目录。请澄清您的问题并告诉我们您想要达到的目标。

标签: mongodb macos chown


【解决方案1】:

在您的 Mac 上,如果您使用 Homebrew 安装 MongoDB,则会在安装时创建数据目录。但是,它不是data/db。相反,在 Intel Mac 上是 /usr/local/var/mongodb,在 M1 Mac 上是 /opt/homebrew/var/mongodb

要使用 Homebrew 正确安装 MongoDB(当然,请检查最新版本):

 brew tap mongodb/brew
 brew install mongodb-community@5.0

首先,通过使用brew 列出正在运行的服务来检查您的 MongoDB 是否运行正常:

brew services list

您应该会看到如下内容:

Name              Status  User File
MongoDB-community started root

如果没有,尝试停止、启动或重启服务:

 brew services stop mongodb/brew/mongodb-community
 brew services start mongodb/brew/mongodb-community
 brew services restart mongodb/brew/mongodb-community

有关可能出现的问题的更多信息,请查看日志文件:

 tail $(brew --prefix)/var/log/mongodb/mongo.log

更多详情请关注official documentation

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 2014-12-02
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 2020-02-14
    • 2018-06-07
    • 2018-05-19
    • 2016-01-05
    相关资源
    最近更新 更多