Where is the mongo db database stored on the local hard drive?

I clear tweets and paste them into the mongo database for analysis work in python. I want to check the size of my database so that there are no additional charges if I run this on amazon. How can I tell how large my current mongo database is on osx? And a free tier covers me?

+4
source share
5 answers

I assume that in OSX, the default location will be /data/db . But you can check your configuration file for dbpath value for confirmation.

+3
source

For posterity:

Launch the mongo shell: mongo

In the shell run: db.adminCommand("getCmdLineOpts")

This will give the location of the relative files, including the db path. Here are the results of the two machines I work with mongo on.

 "parsed": { "config": "/usr/local/etc/mongod.conf", "dbpath": "/usr/local/var/mongodb", "logappend": "true", "logpath": "/usr/local/var/log/mongodb/mongo.log" }, "parsed" : { "config" : "/etc/mongodb.conf", "dbpath" : "/var/lib/mongodb", "logappend" : "true", "logpath" : "/var/log/mongodb/mongodb.log", }, 
+11
source

Databases are stored by default in /data/db (some environments override this and use /var/lib/mongodb , however). You can see the total size of db by looking at db.stats() (specifically fileSize ) in the MongoDB shell.

+1
source
 > use database switched to db database > db.stats() { "db" : "database", "collections" : 4, "objects" : 32, "avgObjSize" : 173.25, "dataSize" : 5544, "storageSize" : 24576, "numExtents" : 4, "indexes" : 3, "indexSize" : 24528, "fileSize" : 201326592, "nsSizeMB" : 16, "ok" : 1 } 

dataSize - the size that your data consumes

fileSize - mongo db file containing all collections

indexSize - the size of any indexes you created in this collection

nsSizeMB - the limit depends on how big your collection can be (this is not a limitation of mongo, just stop developers bombarding collections in endless cycles)

+1
source

if you are using node.js on windows, make sure you install windows mongodb installation. it does not come with node.js.

http://www.mongodb.org/

0
source

Source: https://habr.com/ru/post/1445882/


All Articles