长话短说:
我有一个 Mongo 数据库,它使用 Kitematic.app 在 Docker.app (Mac GUI) 中运行,我愚蠢地在没有备份的情况下运行了更新(我知道!),然后 Docker 因错误而无法启动。然后愚蠢地按照本网站其他地方的一些说明单击重置 Docker.app,这会删除所有容器。
Mongo 的数据文件夹没有保存在容器中,所以我认为理论上数据是安全的,我再次知道我应该这样做,mongodump
但我没有......
我尝试用相同的卷重新创建容器,但似乎不起作用,因为没有数据,因此我尝试安装 Mongo 并使用 Homebrew 运行它,但我收到有关运行版本 3 而不支持版本 2 的错误。
我已经尝试了带有和不带有修复标志的 2.6、3.0、3.2 和 3.4 版本,并且在 3.2 之前出现与存储引擎相关的各种错误,但如果我运行,--storageEngine wiredTiger
似乎总是出现与 wireTiger 的不兼容版本相关的错误,错误如下:
命令
mongod --dbpath=/path/to/files/db
日志
2018-12-01T20:24:07.182+0000 I CONTROL [initandlisten] MongoDB starting : pid=16537 port=27017 dbpath=/Users/tom/Desktop/mongo/db 64-bit host=mb-b1945
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] db version v3.6.5
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2p 14 Aug 2018
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] allocator: system
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] modules: none
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] build environment:
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] distarch: x86_64
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-12-01T20:24:07.183+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/Users/tom/Desktop/mongo/db" } }
2018-12-01T20:24:07.184+0000 I - [initandlisten] Detected data files in /Users/tom/Desktop/mongo/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-12-01T20:24:07.184+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),cache_cursors=false,log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2018-12-01T20:24:07.840+0000 E STORAGE [initandlisten] WiredTiger error (-31802) [1543695847:840468][16537:0x111cf25c0], txn-recover: unsupported WiredTiger file version: this build only supports versions up to 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error
2018-12-01T20:24:07.840+0000 E STORAGE [initandlisten] WiredTiger error (0) [1543695847:840561][16537:0x111cf25c0], txn-recover: WiredTiger is unable to read the recovery log.
2018-12-01T20:24:07.840+0000 E STORAGE [initandlisten] WiredTiger error (0) [1543695847:840605][16537:0x111cf25c0], txn-recover: This may be due to the log files being encrypted, being from an older version or due to corruption on disk
2018-12-01T20:24:07.840+0000 E STORAGE [initandlisten] WiredTiger error (0) [1543695847:840640][16537:0x111cf25c0], txn-recover: You should confirm that you have opened the database with the correct options including all encryption and compression options
2018-12-01T20:24:07.840+0000 E STORAGE [initandlisten] WiredTiger error (-31802) [1543695847:840692][16537:0x111cf25c0], txn-recover: Recovery failed: WT_ERROR: non-specific WiredTiger error
2018-12-01T20:24:07.906+0000 E - [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 416
2018-12-01T20:24:07.908+0000 I STORAGE [initandlisten] exception in initAndListen: Location28595: -31802: WT_ERROR: non-specific WiredTiger error, terminating
2018-12-01T20:24:07.908+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-12-01T20:24:07.908+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2018-12-01T20:24:07.909+0000 I CONTROL [initandlisten] now exiting
2018-12-01T20:24:07.909+0000 I CONTROL [initandlisten] shutting down with code:100
所以问题是,我能撤消我的愚蠢行为吗?如何撤消?当我查找错误时,错误指向一个损坏的数据库,但我不明白这是怎么可能的,因为它是安全关闭的,问题更多的是我不知道docker设置的是什么版本/配置,以及如何再次设置它,以便我可以导出数据。
更新
感谢@Stennie,我用 mongo 4.0.4 运行了相同的过程并让服务运行但没有数据库,然后像以前一样运行修复,关于验证的消息全部显示为肯定的,但服务器运行时仍然没有数据,即“显示数据库”为空。
2018-12-03T10:35:30.155+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] MongoDB starting : pid=7754 port=27017 dbpath=/Users/tom/Desktop/mongo/db 64-bit host=mb-b1945.local
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] db version v4.0.4
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] git version: f288a3bdf201007f3693c58e140056adf8b04839
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] allocator: system
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] modules: none
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] build environment:
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] distarch: x86_64
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-12-03T10:35:30.168+0000 I CONTROL [initandlisten] options: { repair: true, storage: { dbPath: "/Users/tom/Desktop/mongo/db" } }
2018-12-03T10:35:30.169+0000 I STORAGE [initandlisten] Detected data files in /Users/tom/Desktop/mongo/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-12-03T10:35:30.169+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,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),
2018-12-03T10:35:30.958+0000 I STORAGE [initandlisten] WiredTiger message [1543833330:958888][7754:0x10d14d5c0], txn-recover: Main recovery loop: starting at 12/6016 to 13/256
2018-12-03T10:35:31.070+0000 I STORAGE [initandlisten] WiredTiger message [1543833331:70882][7754:0x10d14d5c0], txn-recover: Recovering log 12 through 13
2018-12-03T10:35:31.149+0000 I STORAGE [initandlisten] WiredTiger message [1543833331:149910][7754:0x10d14d5c0], txn-recover: Recovering log 13 through 13
2018-12-03T10:35:31.212+0000 I STORAGE [initandlisten] WiredTiger message [1543833331:212736][7754:0x10d14d5c0], txn-recover: Set global recovery timestamp: 0
2018-12-03T10:35:31.353+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-12-03T10:35:31.355+0000 I STORAGE [initandlisten] Repairing size cache
2018-12-03T10:35:31.356+0000 I STORAGE [initandlisten] Verify succeeded on uri table:sizeStorer. Not salvaging.
2018-12-03T10:35:31.357+0000 I STORAGE [initandlisten] Repairing catalog metadata
2018-12-03T10:35:31.358+0000 I STORAGE [initandlisten] Verify succeeded on uri table:_mdb_catalog. Not salvaging.
2018-12-03T10:35:31.382+0000 I CONTROL [initandlisten]
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten]
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten]
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten]
2018-12-03T10:35:31.383+0000 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-12-03T10:35:31.383+0000 I STORAGE [initandlisten] repairDatabase admin
2018-12-03T10:35:31.383+0000 I STORAGE [initandlisten] Repairing collection admin.system.version
2018-12-03T10:35:31.384+0000 I STORAGE [initandlisten] Verify succeeded on uri table:collection-0-5156503814533425908. Not salvaging.
2018-12-03T10:35:31.434+0000 I INDEX [initandlisten] build index on: admin.system.version properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "admin.system.version" }
2018-12-03T10:35:31.434+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-12-03T10:35:31.485+0000 I STORAGE [initandlisten] repairDatabase config
2018-12-03T10:35:31.485+0000 I STORAGE [initandlisten] Repairing collection config.system.sessions
2018-12-03T10:35:31.485+0000 I STORAGE [initandlisten] Verify succeeded on uri table:collection-4-5156503814533425908. Not salvaging.
2018-12-03T10:35:31.538+0000 I INDEX [initandlisten] build index on: config.system.sessions properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "config.system.sessions" }
2018-12-03T10:35:31.538+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 250 megabytes of RAM
2018-12-03T10:35:31.576+0000 I INDEX [initandlisten] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2018-12-03T10:35:31.576+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 250 megabytes of RAM
2018-12-03T10:35:31.647+0000 I STORAGE [initandlisten] repairDatabase local
2018-12-03T10:35:31.647+0000 I STORAGE [initandlisten] Repairing collection local.startup_log
2018-12-03T10:35:31.648+0000 I STORAGE [initandlisten] Verify succeeded on uri table:collection-2-5156503814533425908. Not salvaging.
2018-12-03T10:35:31.697+0000 I INDEX [initandlisten] build index on: local.startup_log properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2018-12-03T10:35:31.697+0000 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-12-03T10:35:31.737+0000 W ASIO [initandlisten] No TransportLayer configured during NetworkInterface startup
2018-12-03T10:35:31.737+0000 I STORAGE [initandlisten] finished checking dbs
2018-12-03T10:35:31.737+0000 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2018-12-03T10:35:31.925+0000 I STORAGE [initandlisten] shutdown: removing fs lock...
2018-12-03T10:35:31.926+0000 I CONTROL [initandlisten] now exiting
2018-12-03T10:35:31.926+0000 I CONTROL [initandlisten] shutting down with code:0