The Internet
The Internet

Reputation: 8123

where is mongo db database stored on local hard drive?

I'm scraping tweets and inserting them into a mongo database for analysis work in python. I want to check the size of my database so that I won't incur additional charges if I run this on amazon. How can I tell how big my current mongo database is on osx? And will a free tier cover me?

Upvotes: 8

Views: 19771

Answers (5)

anonymous
anonymous

Reputation: 1

if you are running node.js in windows, make sure to install the windows mongodb setup. it does not come with node.js.

http://www.mongodb.org/

Upvotes: -1

Sean McClory
Sean McClory

Reputation: 4283

For posterity:

Run 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 from two machines I have running mongo.

"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",
},

Upvotes: 19

snez
snez

Reputation: 2480

> 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 - the mongo db file containing all of the collections

indexSize - is the size of any indexes you have created on that collection

nsSizeMB - a limit on how big your collection can be (this is not a mongo limitation, it is just there to stop developers bombarding collections in infinite loops)

Upvotes: 0

Mike Brant
Mike Brant

Reputation: 71414

I believe on OSX the default location would be /data/db. But you can check your config file for the dbpath value to verify.

Upvotes: 3

Chris Down
Chris Down

Reputation: 1795

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

Upvotes: 0

Related Questions