Mongodb

清理失敗的修復數據庫:路徑:/var/lib/docker/wesfgr/repair/_tmp_repairDatabase_0

  • October 5, 2016

我們在 Docker 容器(單節點)中使用 MMAP 執行 MongoDB 3.0.6。文件系統已滿,我用其他路徑進行了修復。

2016-10-03T08:58:51.186+0200 I INDEX    [initandlisten]          building index using bulk method
2016-10-03T08:58:51.186+0200 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T08:58:51.186+0200 I INDEX    [initandlisten] build index on: 6JzeOdlsErBwx4Fc.fb31a88b-cdfc-440b-81f8-d333dcd9527bs properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "6JzeOdlsErBwx4Fc.fb31a88b-cdfc-440b-81f8-d333dcd9527bs" }
2016-10-03T08:58:51.186+0200 I INDEX    [initandlisten]          building index using bulk method
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] build index on: 6JzeOdlsErBwx4Fc.fb362dbf-a5d9-445b-a052-1166f0c522a7 properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "6JzeOdlsErBwx4Fc.fb362dbf-a5d9-445b-a052-1166f0c522a7" }
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten]          building index using bulk method
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] build index on: 6JzeOdlsErBwx4Fc.fb38d789-61a7-40ff-a63f-146244df4475 properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "6JzeOdlsErBwx4Fc.fb38d789-61a7-40ff-a63f-146244df4475" }
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten]          building index using bulk method
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] error: hashtable namespace index max chain reached:1335
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] error: hashtable namespace index max chain reached:1335
2016-10-03T08:58:51.349+0200 I STORAGE  [initandlisten] cleaning up failed repair db: 6JzeOdlsErBwx4Fc path: /var/lib/docker/wesfgr/repair/_tmp_repairDatabase_0
2016-10-03T08:58:51.570+0200 I STORAGE  [initandlisten] exception in initAndListen: 10081 too many namespaces/collections, terminating
2016-10-03T08:58:51.570+0200 I CONTROL  [initandlisten] now exiting
2016-10-03T08:58:51.570+0200 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2016-10-03T08:58:51.570+0200 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2016-10-03T08:58:51.570+0200 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2016-10-03T08:58:51.570+0200 I NETWORK  [initandlisten] shutdown: going to close sockets...
2016-10-03T08:58:51.570+0200 I STORAGE  [initandlisten] shutdown: waiting for fs preallocator...
2016-10-03T08:58:51.570+0200 I STORAGE  [initandlisten] shutdown: closing all files...
2016-10-03T08:58:51.579+0200 I STORAGE  [initandlisten] closeAllFiles() finished
2016-10-03T08:58:51.580+0200 I STORAGE  [initandlisten] shutdown: removing fs lock...
2016-10-03T08:58:51.580+0200 I CONTROL  [initandlisten] dbexit:  rc: 100

有很多錯誤,但修復後MongoDB成功啟動。這個錯誤是什麼意思?我們會長期存在不一致的數據庫嗎?

2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] error: hashtable namespace index max chain reached:1335
2016-10-03T08:58:51.187+0200 I INDEX    [initandlisten] error: hashtable namespace index max chain reached:1335
2016-10-03T08:58:51.349+0200 I STORAGE  [initandlisten] cleaning up failed repair db: 6JzeOdlsErBwx4Fc path: /var/lib/docker/wesfgr/repair/_tmp_repairDatabase_0
2016-10-03T08:58:51.570+0200 I STORAGE  [initandlisten] exception in initAndListen: 10081 too many namespaces/collections, terminating

重新啟動日誌中的許多這些行後:

2016-10-03T07:03:41.458+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.458+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.459+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.460+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.460+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.460+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.461+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.461+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.461+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.462+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.462+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.463+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.464+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.465+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.466+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.466+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain
2016-10-03T07:03:41.466+0000 I INDEX    [initandlisten] warning: hashtable namespace index long chain

看起來您的命名空間文件仍然損壞,當您達到 MMAPv1 中數據庫的最大集合數時,您會遇到類似的錯誤。要嘗試解決此問題並獲得處於更一致狀態的數據庫,您可以嘗試在新數據庫中重新創建您的集合。

如果您啟用了身份驗證,則需要在 admin 數據庫中執行此操作 - 請注意,這裡的真正關鍵是該to:欄位中的新數據庫:

use admin;
db.runCommand( { renameCollection: "db1.collection1", to: "db2.collection1" });

對目前數據庫中的每個集合重複此操作,並確保您有足夠的空間在現有文件系統上重新創建集合。完成後,我建議備份(以防萬一)並刪除舊數據庫。

引用自:https://dba.stackexchange.com/questions/151297