在復(fù)制集架構(gòu)primary上使用時(shí),如果不使用force參數(shù),則會(huì)報(bào)錯(cuò),如下:
若想要對(duì)著一個(gè)數(shù)據(jù)庫的所有collection集合進(jìn)行compact命令的話,可以參考使用repairDatabase命令哦>use testDB>db.runCommand({repairDatabase:1})注:這個(gè)命令一定要謹(jǐn)慎使用,能不用的情況下盡量不用,因?yàn)闀?huì)花費(fèi)很多時(shí)間和性能官網(wǎng)的一句話是這樣說的:The repairDatabase command compacts all collections in the database. It is identical to running the compact command on each collection individually新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注