Mongodb
無法將 mongodb 作為服務啟動 - 異常;集合在 KVDatalog 中沒有 UUID
我已經安裝了 Mongodb 4.2
並且在執行時
sudo service mongod start|restart
它不會啟動伺服器,我在 mongod.log 文件中有以下日誌。
Exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: local.startup_log, terminating
這裡有更多細節:
CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' CONTROL [initandlisten] MongoDB starting : pid=7434 port=27017 dbpath=/var/lib/mongodb 64-bit host=vm2851358555.bitcommand.com CONTROL [initandlisten] db version v4.2.0 CONTROL [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30 CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.0k 28 May 2019 CONTROL [initandlisten] allocator: tcmalloc CONTROL [initandlisten] modules: none CONTROL [initandlisten] build environment: CONTROL [initandlisten] distmod: debian92 CONTROL [initandlisten] distarch: x86_64 CONTROL [initandlisten] target_arch: x86_64 CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'. STORAGE [initandlisten] STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem STORAGE [initandlisten] wiredtiger_open config: create,cache_size=256M,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),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress], STORAGE [initandlisten] WiredTiger message [1567525272:967263][7434:0x7fb79a56f140], txn-recover: Recovering log 16 through 17 STORAGE [initandlisten] WiredTiger message [1567525273:183321][7434:0x7fb79a56f140], txn-recover: Recovering log 17 through 17 STORAGE [initandlisten] WiredTiger message [1567525273:257888][7434:0x7fb79a56f140], txn-recover: Main recovery loop: starting at 16/768 to 17/256 STORAGE [initandlisten] WiredTiger message [1567525273:401263][7434:0x7fb79a56f140], txn-recover: Recovering log 16 through 17 STORAGE [initandlisten] WiredTiger message [1567525273:492743][7434:0x7fb79a56f140], txn-recover: Recovering log 17 through 17 STORAGE [initandlisten] WiredTiger message [1567525273:557051][7434:0x7fb79a56f140], txn-recover: Set global recovery timestamp: (0,0) RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0) STORAGE [initandlisten] WiredTigerKVEngine shutting down STORAGE [initandlisten] Shutting down session sweeper thread STORAGE [initandlisten] Finished shutting down session sweeper thread STORAGE [initandlisten] Shutting down journal flusher thread STORAGE [initandlisten] Finished shutting down journal flusher thread STORAGE [initandlisten] Shutting down checkpoint thread STORAGE [initandlisten] Finished shutting down checkpoint thread STORAGE [initandlisten] Downgrading WiredTiger datafiles. STORAGE [initandlisten] WiredTiger message [1567525275:122312][7434:0x7fb79a56f140], txn-recover: Recovering log 17 through 18 STORAGE [initandlisten] WiredTiger message [1567525275:243324][7434:0x7fb79a56f140], txn-recover: Recovering log 18 through 18 STORAGE [initandlisten] WiredTiger message [1567525275:351715][7434:0x7fb79a56f140], txn-recover: Main recovery loop: starting at 17/2944 to 18/256 STORAGE [initandlisten] WiredTiger message [1567525275:482006][7434:0x7fb79a56f140], txn-recover: Recovering log 17 through 18 STORAGE [initandlisten] WiredTiger message [1567525275:576281][7434:0x7fb79a56f140], txn-recover: Recovering log 18 through 18 STORAGE [initandlisten] WiredTiger message [1567525275:642376][7434:0x7fb79a56f140], txn-recover: Set global recovery timestamp: (0,0) STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: local.startup_log, terminating NETWORK [initandlisten] shutdown: going to close listening sockets... NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock - [initandlisten] Stopping further Flow Control ticket acquisitions. CONTROL [initandlisten] now exiting CONTROL [initandlisten] shutting down with code:100
我該如何解決?
該問題可以通過以下方式解決:
- 備份所有數據庫(使用
mongodump
)- 刪除 中的每個文件
/data/db
,因為它們與較新版本不兼容:rm -rf /data/db/*
- 重啟 MongoDB 服務
- 恢復所有數據庫(使用
mongorestore
)
從舊的 mongodb 3.4 升級到 4.2 時,我遇到了與 admin db 類似的問題。
解決方案是 mongodump 所有 dbs 並刪除 /var/lib/mongodb,然後 mongorestore 所有 dbs 回來。
STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: admin.system.users, terminating 2019-09-24T21:59:55.274+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets... 2019-09-24T21:59:55.274+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock 2019-09-24T21:59:55.274+0000 I - [initandlisten] Stopping further Flow Control ticket acquisitions. 2019-09-24T21:59:55.274+0000 I CONTROL [initandlisten] now exiting 2019-09-24T21:59:55.274+0000 I CONTROL [initandlisten] shutting down with code:100
問題原因:mongodb 4.2 會在 system.user 集合中添加帶有 UUID 值的 userId。希望這會有所幫助。
升級另一個 mongo db 時,我在 startup_log 上遇到了與您完全相同的問題,似乎在刪除 /var/lib/mongodb 文件夾時我沒有停止 mongodb,在停止 mongod 並刪除 /var/lib/mongodb 併升級之後到 4.2,錯誤消失了。