我刚刚在macOS上安装了MongoDB,我在多个线程上编写了数十亿个文档(使用我们自己的真实数据进行实际的基准测试 - 每个文档平均包含大约500个字节,包含整数,浮点数和二进制数据字段)。 在写完了10到2千万个文档之后,MongoDB服务突然停止了工作。
brew services restart mongodb
刚启动mongodb,它会在~10秒后自动停止。 Activity Monitor表示它在这10秒内向磁盘写入大约700mb的数据并读取几乎相同数量的数据。
mongo
命令失败,输出如下:
$ mongo
MongoDB shell version v3.6.2
connecting to: mongodb://127.0.0.1:27017
***TIME*** W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
***TIME*** E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
当我尝试brew services restart mongodb
时,这是日志文件:
***TIME*** I CONTROL [main] ***** SERVER RESTARTED *****
***TIME*** I CONTROL [initandlisten] MongoDB starting : pid=58235 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=***HOST***
***TIME*** I CONTROL [initandlisten] db version v3.6.2
***TIME*** I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
***TIME*** I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
***TIME*** I CONTROL [initandlisten] allocator: system
***TIME*** I CONTROL [initandlisten] modules: none
***TIME*** I CONTROL [initandlisten] build environment:
***TIME*** I CONTROL [initandlisten] distarch: x86_64
***TIME*** I CONTROL [initandlisten] target_arch: x86_64
***TIME*** I CONTROL [initandlisten] options: { config: "/usr/local/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/usr/local/var/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/logs/mongodb.log" } }
***TIME*** I - [initandlisten] Detected data files in /usr/local/var/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
***TIME*** I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1536M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
***TIME*** I STORAGE [initandlisten] WiredTiger message [1524603520:902878][58235:0x7fffc82c43c0], txn-recover: Main recovery loop: starting at 91/768
***TIME*** I STORAGE [initandlisten] WiredTiger message [1524603521:64660][58235:0x7fffc82c43c0], txn-recover: Recovering log 91 through 92
***TIME*** I STORAGE [initandlisten] WiredTiger message [1524603521:280503][58235:0x7fffc82c43c0], txn-recover: Recovering log 92 through 92
***TIME*** I CONTROL [initandlisten]
***TIME*** I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
***TIME*** I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
***TIME*** I CONTROL [initandlisten]
***TIME*** F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
***TIME*** I NETWORK [initandlisten] shutdown: going to close listening sockets...
***TIME*** I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
***TIME*** I REPL [initandlisten] shutdown: removing all drop-pending collections...
***TIME*** I REPL [initandlisten] shutdown: removing checkpointTimestamp collection...
***TIME*** I STORAGE [initandlisten] WiredTigerKVEngine shutting down
***TIME*** I STORAGE [initandlisten] WiredTiger message [1524603524:5088][58235:0x7fffc82c43c0], txn-recover: Main recovery loop: starting at 92/3072
***TIME*** I STORAGE [initandlisten] WiredTiger message [1524603524:182001][58235:0x7fffc82c43c0], txn-recover: Recovering log 92 through 93
***TIME*** I STORAGE [initandlisten] WiredTiger message [1524603524:408698][58235:0x7fffc82c43c0], txn-recover: Recovering log 93 through 93
***TIME*** I STORAGE [initandlisten] shutdown: removing fs lock...
***TIME*** I CONTROL [initandlisten] now exiting
***TIME*** I CONTROL [initandlisten] shutting down with code:62
如何解决问题并再次启动mongodb服务?