0

Please help me to find correct MongoDB size.

db version v3.4.10

I have also executed below command to check if there are any ghost file. The below command output is zero.

lsof | grep deleted | grep mongo | wc -l
  1. In db.stats, the data size is showing 1236GB

    "collections" : 23, "views" : 0, "objects" : 702876605, "avgObjSize" : 1914.5578033287934, "dataSize" : 1253.2788225263357, "storageSize" : 374.982120513916, "numExtents" : 0, "indexes" : 52, "indexSize" : 21.016620635986328, "ok" : 1

  2. Disk used is showing as 916GB (/data/mongo/) out of 1.4T

  3. In show dbs output, DB size is showing as 396B

admin 0.000GB

local 15.906GB

abcd 396.008GB

I need to sync DB from primary site to secondary (replication), How much free space is required on secondary site (915 GB or 1236GB)? Also why it's showing DB size different in point 1,2 & 3? Which value/size is correct DB size?

Thanks in advance.

4
  • mongo is the (legacy) mongo shell, it does not store any data. I guess you need to search for mongod which is the database process. Oct 27, 2022 at 11:30
  • 916GB from /data/mongo/ would be correct. Apart from raw datasize you also need some space for the oplog, temp files, etc. Oct 27, 2022 at 11:34
  • I have executed below command, the Ghost file count is zero. lsof | grep deleted | grep mongod | wc -l
    – Sridhar G
    Oct 27, 2022 at 11:35
  • Can you please help to add ghost file creation date time in above command. I found Ghost files on Secondary server, need to check when these files are created
    – Sridhar G
    Oct 27, 2022 at 11:37

1 Answer 1

1

The size on disk is represented by the storageSize + indexSize metrics in db.stats() (or totalSize in modern versions of MongoDB) or by checking the actual contents on disk. The dataSize is the size of uncompressed documents, so can be significantly larger than storage size with the WiredTiger storage engine. Note that there will also be some differences if you are comparing binary Gigibytes (1GiB = 1024^3) to decimal Gigabytes (1GB = 1000^3).

I need to sync DB from primary site to secondary (replication), How much free space is required on secondary site (915 GB or 1236GB)? Also why it's showing DB size different in point 1,2 & 3? Which value/size is correct DB size?

If you are re-syncing a secondary, it will usually take similar or less storage space than the member it is syncing from. Less space would be a result of building fresh data files that do not have any space available for reuse from deleted documents.

db version v3.4.10

MongoDB 3.4 was first released in 2016 (3.4.10 was Oct 2017) and reached end of life in Jan 2020. There are some important stability and security improvements since then, and at a minimum you should upgrade to the final 3.4.24 release as there are no backward breaking changes. See: Release Notes for MongoDB 3.4 for release highlights.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.