{"id":4195,"date":"2020-09-15T17:33:29","date_gmt":"2020-09-15T09:33:29","guid":{"rendered":"https:\/\/www.webteach.tw\/?p=4195"},"modified":"2020-09-15T17:33:29","modified_gmt":"2020-09-15T09:33:29","slug":"show-mongodb-size","status":"publish","type":"post","link":"https:\/\/www.webteach.tw\/?p=4195","title":{"rendered":"[ Mongodb ] &#8211; How to show Mongodb size \u5982\u4f55\u67e5\u8a62 Mongodb \u5bb9\u91cf"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Mongodb \u5728\u6211\u7684\u4f7f\u7528\u60c5\u5883\u4e0b\u90fd\u62ff\u4f86\u5b58\u7d71\u8a08\u7684\u8cc7\u6599\uff0c\u4f46\u70ba\u907f\u514d\u5132\u5b58\u7a7a\u9593\u4e0d\u8db3\u9020\u6210\u7db2\u7ad9\u639b\u6389\uff0c\u6240\u4ee5\u5b9a\u6642\u7684\u53bb\u6aa2\u67e5\u6bcf\u500b\u8cc7\u6599\u5eab\u4f7f\u5927\u5c0f\u662f\u4e00\u5b9a\u8981\u7684\u3002<\/p>\n\n\n<p class=\"wp-block-paragraph\">Mongodb is used to store statistical data in my use situation, but in order to avoid insufficient storage space and cause the website to hang up, it is necessary to check the size of each database regularly.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\ndb.stats();\n{\n\t\"db\" : \"op_log\",\/\/Database name \u8cc7\u6599\u5eab\u540d\u7a31\n\t\"collections\" : 1,\/\/table \u8cc7\u6599\u8868\n\t\"views\" : 0,\n\t\"objects\" : 44,\/\/\u8cc7\u6599\u7b46\u6578\n\t\"avgObjSize\" : 293.1136363636364,\n\t\"dataSize\" : 12897,\/\/\u8cc7\u6599\u5927\u5c0f\n\t\"storageSize\" : 36864,\/\/\u5132\u5b58\u5927\u5c0f\n\t\"numExtents\" : 0,\n\t\"indexes\" : 1,\/\/\u7d22\u5f15\n\t\"indexSize\" : 36864,\/\/\u7d22\u5f15\u5927\u5c0f\n\t\"fsUsedSize\" : 196529012736,\n\t\"fsTotalSize\" : 977370820608,\n\t\"ok\" : 1\n}<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u8981\u67e5\u770bKB \/ MB \/ GB\u7b49\u4e0d\u540c\u683c\u5f0f\u7684\u5927\u5c0f\uff0c\u53ef\u4ee5\u8f38\u5165\u4e0b\u5217\u9078\u9805\u3002<\/p>\n\n\n<p class=\"wp-block-paragraph\">If you want to view the size of different formats such as KB \/ MB \/ GB, you can enter the following options.<\/p>\n\n\n<p class=\"wp-block-paragraph\">db.stats(options);<\/p>\n\n\n<p class=\"wp-block-paragraph\">options\uff1a<br \/>1024\uff08KB\uff09<br \/>1048576 (MB)<br \/>1073741824 (GB)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mongodb \u5728\u6211\u7684\u4f7f\u7528\u60c5\u5883\u4e0b\u90fd\u62ff\u4f86\u5b58\u7d71\u8a08\u7684\u8cc7\u6599\uff0c\u4f46\u70ba\u907f\u514d\u5132\u5b58\u7a7a\u9593\u4e0d\u8db3\u9020\u6210\u7db2\u7ad9\u639b\u6389\uff0c\u6240\u4ee5\u5b9a\u6642\u7684\u53bb\u6aa2\u67e5\u6bcf\u500b\u8cc7\u6599\u5eab\u4f7f\u5927\u5c0f\u662f\u4e00\u5b9a\u8981\u7684\u3002<br \/>\nMongodb is used to store statistical data in my use situation, but in order to avoid insufficient storage space and cause the website to hang up, it is necessary to check the size of each database regularly.<\/p>\n","protected":false},"author":1,"featured_media":3825,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[395,513,516],"class_list":["post-4195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb","tag-mongodb","tag-show","tag-size","hvn-theme-has-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/4195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4195"}],"version-history":[{"count":0,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/4195\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/media\/3825"}],"wp:attachment":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}