【问题标题】:MongoDB-Community not starting on Mac and giving errorsMongoDB-Community 未在 Mac 上启动并出现错误
【发布时间】:2020-12-24 06:27:44
【问题描述】:

我写信通知我已经使用 brew (High Sierra) 安装了 mongodb-community 并且它正在运行。然后最近我升级了,它似乎没有连接起来。当我在终端运行 mongo 时,出现错误:

MongoDB shell version v4.4.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
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:362:17
@(connect):2:6
exception: connect failed
exiting with code 1

当我检查日志以启动 mongodb-community 服务时,我收到以下错误:

{"t":{"$date":"2020-09-04T21:01:35.015-07:00"},"s":"W",  "c":"CONTROL",  "id":20698,   "ctx":"main","msg":"***** SERVER RESTARTED *****","tags":["startupWarnings"]}
{"t":{"$date":"2020-09-04T21:01:35.021-07:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-04T21:01:35.027-07:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-04T21:01:35.027-07:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2020-09-04T21:01:35.028-07:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":58706,"port":27017,"dbPath":"/Users/my_username/homebrew/var/mongodb","architecture":"64-bit","host":"SC-*"}}
{"t":{"$date":"2020-09-04T21:01:35.029-07:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-04T21:01:35.029-07:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"17.7.0"}}}
{"t":{"$date":"2020-09-04T21:01:35.029-07:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/Users/my_username/homebrew/etc/mongod.conf","net":{"bindIp":"127.0.0.1"},"storage":{"dbPath":"/Users/my_username/homebrew/var/mongodb"},"systemLog":{"destination":"file","logAppend":true,"path":"/Users/my_username/homebrew/var/log/mongodb/mongo.log"}}}}
{"t":{"$date":"2020-09-04T21:01:35.038-07:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/Users/my_username/homebrew/var/mongodb","storageEngine":"wiredTiger"}}
{"t":{"$date":"2020-09-04T21:01:35.038-07:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=7680M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
{"t":{"$date":"2020-09-04T21:01:36.177-07:00"},"s":"W",  "c":"STORAGE",  "id":22347,   "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."}
{"t":{"$date":"2020-09-04T21:01:36.178-07:00"},"s":"F",  "c":"STORAGE",  "id":28595,   "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"45: Operation not supported"}}
{"t":{"$date":"2020-09-04T21:01:36.178-07:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":1100}}
{"t":{"$date":"2020-09-04T21:01:36.178-07:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

我可以请你帮忙解决这个问题吗?我没有 sudo 权限,无法升级操作系统,但我愿意使用任何方法使用 mongo

【问题讨论】:

  • 你是从哪个版本升级的?
  • 我将它升级到 4.4,它应该是我升级的 4.2。我还检查了brew services list 命令,它不是绿色而是黄色。如果可能的话,我可以寻求进一步的帮助吗?我也尝试过像 3.64.0 这样的低版本,但我得到了相同的行为。
  • 实际上,您的日志几乎与您忘记设置功能兼容性时的输出完全相同。我可以说出来,因为我也只是在从 4.2 升级到 4.4 时忘记了它......对于这种情况,@Eddy 的答案是正确的。

标签: mongodb macos homebrew


【解决方案1】:

类似问题,最终解决方案:

  1. 卸载(最新但无法使用的版本:4.4.3

brew uninstall mongodb-community

  1. 重新安装,旧的但可以工作4.2.1

brew install mongodb-community@4.2

  1. 运行
  • 现在:brew services run mongodb-community@4.2
  • 现在设置可启动:brew services start mongodb-community@4.2
  1. 检查状态

brew services

【讨论】:

    【解决方案2】:

    日志告诉你发生了什么

    "Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."
    

    因此您可能需要阅读旧 mongoDB 版本的文档以查看它是否可以升级到 4.4.0 版本,如果不是,请考虑升级到与您当前使用的 WiredTiger 版本兼容的最新版本

    这个link 可能有用。要升级到 mongoDB v4.0 或更高版本,您必须至少运行 mongoDB v3.6,否则您必须先升级到 v3.6

    【讨论】:

    【解决方案3】:

    卸载mongodb
    删除 /var/lib/mongodb/ # 因为 WiredTiger 没有完全卸载
    重新安装mongodb

    【讨论】:

      【解决方案4】:

      我的 mongodb docker 容器重新启动时也出现了同样的问题。我所做的是在存储数据库数据的根文件夹中删除 mongod.lock 。

      尝试以下步骤:

      首先复制您的数据库文件夹以确保您有备份。

      然后执行以下命令:

      mongod --dbpath /data/db --repair
      

      现在检查它是否有效,如果仍然无效

      尝试暂时将 mongod.lock 移动到其他位置以测试 mongod.lock 是否导致问题。启动 mongodb 并检查它是否有效。如果没有,您应该降级。

      要降级到正确的版本,您可以执行以下操作:

      bsondump mongo/diagnostic.data/metrics.2021-10-06T08-41-05Z-00000  | jq -s '.[] | select(.type == {"$numberInt": "0"})| .doc.buildInfo.version'
      

      请记住,指标文件可以有不同的日期,这只是一个示例。

      获得版本后,您可以使用该特定版本启动容器,它应该可以工作。

      【讨论】:

        猜你喜欢
        • 2022-12-11
        • 2018-11-02
        • 1970-01-01
        • 2022-01-13
        • 2011-04-08
        • 2015-10-21
        • 2023-01-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多