【问题标题】:MongoDb MacOS cannot connectMongoDb MacOS 无法连接
【发布时间】:2020-09-28 20:20:10
【问题描述】:

运行 MacOS 10.13.6,MongoDb 存在巨大问题。 本质上是一个简单的终端 (mongo) 连接导致

MongoDB shell version v4.2.7
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-06-09T18:31:51.654+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:341:17
@(connect):2:6
2020-06-09T18:31:51.659+0300 F  -        [main] exception: connect failed
2020-06-09T18:31:51.659+0300 E  -        [main] exiting with code 1

当 brew services 显示 mongodb-community 正在运行时。我试过停止它并手动运行 mongod(启动 mongodb 服务器)

2020-06-09T18:33:18.787+0300 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-
enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-06-09T18:33:18.808+0300 W  ASIO     [main] No TransportLayer configured during NetworkInterface startup
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] MongoDB starting : pid=6184 port=27017 dbpath=/data/db 64-bit host=Alekseis-MacBook-Pro.local
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] db version v4.2.7
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] allocator: system
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] modules: none
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] build environment:
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten]     distarch: x86_64
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten]     target_arch: x86_64
2020-06-09T18:33:18.815+0300 I  CONTROL  [initandlisten] options: {}
2020-06-09T18:33:18.824+0300 I  STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-06-09T18:33:18.824+0300 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3584M,cache_overflow=(file_max=0M),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],
2020-06-09T18:33:19.336+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716799:336368][6184:0x7fff89c6b380], txn-recover: Recovering log 18 through 19
2020-06-09T18:33:19.422+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716799:422618][6184:0x7fff89c6b380], txn-recover: Recovering log 19 through 19
2020-06-09T18:33:19.531+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716799:531967][6184:0x7fff89c6b380], txn-recover: Main recovery loop: starting at 18/896 to 19/256
2020-06-09T18:33:19.628+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716799:628451][6184:0x7fff89c6b380], txn-recover: Recovering log 18 through 19
2020-06-09T18:33:19.687+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716799:687127][6184:0x7fff89c6b380], txn-recover: Recovering log 19 through 19
2020-06-09T18:33:19.729+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716799:729488][6184:0x7fff89c6b380], txn-recover: Set global recovery timestamp: (0, 0)
2020-06-09T18:33:19.781+0300 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-06-09T18:33:19.796+0300 I  STORAGE  [initandlisten] Timestamp monitor starting
2020-06-09T18:33:19.796+0300 I  CONTROL  [initandlisten] 
2020-06-09T18:33:19.796+0300 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-06-09T18:33:19.796+0300 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-06-09T18:33:19.796+0300 I  CONTROL  [initandlisten] 
2020-06-09T18:33:19.796+0300 I  CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2020-06-09T18:33:19.797+0300 I  CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2020-06-09T18:33:19.797+0300 I  CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2020-06-09T18:33:19.797+0300 I  CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2020-06-09T18:33:19.797+0300 I  CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2020-06-09T18:33:19.797+0300 I  CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2020-06-09T18:33:19.797+0300 I  CONTROL  [initandlisten] 
2020-06-09T18:33:19.861+0300 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-06-09T18:33:19.906+0300 F  CONTROL  [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See https://docs.mongodb.com/manual/release-notes/4.2-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at https://docs.mongodb.com/manual/release-notes/4.2/#upgrade-procedures.
2020-06-09T18:33:19.914+0300 I  NETWORK  [initandlisten] shutdown: going to close listening sockets...
2020-06-09T18:33:19.914+0300 I  -        [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-06-09T18:33:19.915+0300 I  STORAGE  [initandlisten] Deregistering all the collections
2020-06-09T18:33:19.916+0300 I  STORAGE  [initandlisten] Timestamp monitor shutting down
2020-06-09T18:33:19.916+0300 I  STORAGE  [initandlisten] WiredTigerKVEngine shutting down
2020-06-09T18:33:19.916+0300 I  STORAGE  [initandlisten] Shutting down session sweeper thread
2020-06-09T18:33:19.916+0300 I  STORAGE  [initandlisten] Finished shutting down session sweeper thread
2020-06-09T18:33:19.916+0300 I  STORAGE  [initandlisten] Shutting down journal flusher thread
2020-06-09T18:33:19.985+0300 I  STORAGE  [initandlisten] Finished shutting down journal flusher thread
2020-06-09T18:33:19.985+0300 I  STORAGE  [initandlisten] Shutting down checkpoint thread
2020-06-09T18:33:19.985+0300 I  STORAGE  [initandlisten] Finished shutting down checkpoint thread
2020-06-09T18:33:19.985+0300 I  STORAGE  [initandlisten] Downgrading WiredTiger datafiles.
2020-06-09T18:33:20.054+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716800:54770][6184:0x7fff89c6b380], txn-recover: Recovering log 19 through 20
2020-06-09T18:33:20.100+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716800:100076][6184:0x7fff89c6b380], txn-recover: Recovering log 20 through 20
2020-06-09T18:33:20.173+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716800:173585][6184:0x7fff89c6b380], txn-recover: Main recovery loop: starting at 19/2176 to 20/256
2020-06-09T18:33:20.253+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716800:253342][6184:0x7fff89c6b380], txn-recover: Recovering log 19 through 20
2020-06-09T18:33:20.309+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716800:309550][6184:0x7fff89c6b380], txn-recover: Recovering log 20 through 20
2020-06-09T18:33:20.360+0300 I  STORAGE  [initandlisten] WiredTiger message [1591716800:360523][6184:0x7fff89c6b380], txn-recover: Set global recovery timestamp: (0, 0)
2020-06-09T18:33:20.498+0300 I  STORAGE  [initandlisten] shutdown: removing fs lock...
2020-06-09T18:33:20.499+0300 I  CONTROL  [initandlisten] now exiting
2020-06-09T18:33:20.499+0300 I  CONTROL  [initandlisten] shutting down with code:62

这很奇怪,我试过停止brew服务,重新安装mongodb-community版等,都没有效果...无法连接数据库。

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    根据日志:

    2020-06-09T18:33:19.906+0300 F  CONTROL  [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See https://docs.mongodb.com/manual/release-notes/4.2-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at https://docs.mongodb.com/manual/release-notes/4.2/#upgrade-procedures.
    

    看起来您以前使用过 mongodb 3.6 版,它在 /data/db 中创建了数据文件,然后您升级到 4.2 版,所以 mongod 表示 /data/db 中的文件不兼容。

    您可以执行以下操作之一:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-23
      • 2012-02-01
      • 2019-06-08
      • 2017-02-02
      • 2016-07-31
      • 1970-01-01
      相关资源
      最近更新 更多