奇怪的是,在MongoDB 3.0.3独立服务器上,在数据库上运行db.stats()命令后,我只得到这个输出,它没有显示我的数据库的文件大小的信息,除了不存在的信息:
> use MyBase
switched to db MyBase
> show collections
XmlCache
system.profile
> db.stats()
{
"db" : "MyBase",
"collections" : 2,
"objects" : 62228,
"avgObjSize" : 139963.13608022113,
"dataSize" : 8709626032,
"storageSize" : 3128832000,
"numExtents" : 0,
"indexes" : 9,
"indexSize" : 15106048,
"ok" : 1
}
> db.runCommand({ dbStats: 1, scale: 1 })
{
"db" : "MyBase",
"collections" : 2,
"objects" : 63765,
"avgObjSize" : 138065.89466007997,
"dataSize" : 8803771773,
"storageSize" : 3129327616,
"numExtents" : 0,
"indexes" : 9,
"indexSize" : 15286272,
"ok" : 1
}
> show dbs
ABase 0.035GB
AnotherBase 0.036GB
MyBase 2.929GB
local 0.000GB
> use dummy
switched to db dummy
> db.stats()
{
"db" : "dummy",
"collections" : 0,
"objects" : 0,
"avgObjSize" : 0,
"dataSize" : 0,
"storageSize" : 0,
"numExtents" : 0,
"indexes" : 0,
"indexSize" : 0,
"fileSize" : 0,
"ok" : 1
}
在具有相同数据库的replicaset中的2.6.9或3.0.3服务器上运行相同的命令将获得更多信息,我不明白为什么(并且因为我需要这些信息而困扰我对于某些脚本):
rs0:SECONDARY> use MyBase
switched to db MyBase
rs0:SECONDARY> show collections
XmlCache
system.indexes
system.profile
rs0:SECONDARY> db.stats()
{
"db" : "MyBase",
"collections" : 4,
"objects" : 127225,
"avgObjSize" : 36730.40902338377,
"dataSize" : 4673026288,
"storageSize" : 6541684736,
"numExtents" : 24,
"indexes" : 9,
"indexSize" : 49333984,
"fileSize" : 55741251584,
"nsSizeMB" : 16,
"extentFreeList" : {
"num" : 52,
"totalSize" : 45903593184
},
"dataFileVersion" : {
"major" : 4,
"minor" : 22
},
"ok" : 1
}
rs0:SECONDARY> show dbs
ABase 0.078GB
AnotherBase 0.453GB
MyBase 51.929GB
local 6.075GB
rs0:SECONDARY>
隐藏文件大小信息在哪里?