maybe is a silly question but I am really wondering where is going to be stored the whole data? If I am looking for this /data/db there is no folder called like this in my root folder on MacOS. Can anyone explain to me how is this work?
Open your Database configuration file.
Look dbpath variable.
For example
dbpath = /srv/mongodb
You have to either create that directory yourself, or specify a different location with
mongod --dbpath=/path/to/dir/db
I usually create a directory called db in my project directory and use that
mongod --dbpath=/home/tim/project/db
Related
This is more of a general question about how MongoDB works.
But I've been using MongoDB for a while and everything seems to be working for me. The part that currently confuses me, though, is that when I visit the directory where the MongoDB data is saved (I'm using the default data/db) the directory is empty. The data is being persisted, I'm just confused - why does the directory appears empty on my computer?
I'm on Windows, if that's worth anything.
You can execute :
db.serverCmdLineOpts().parsed.storage.dbPath
from inside the mongo process and find what the dbPath startup parameter show to find where your data is saved
or alternatively check from the config file in windows:
<install directory>/bin/mongod.cfg
dbPath can be confusing.
When you run mongod without --dbpath option or unset it in config file then it defaults to \data\db
However, when you use the default config files which comes along the installation then the dpPath is different (I don't remember by heart which). So you should really check path with db.serverCmdLineOpts() as suggested by R2D2
I know, for Linux the default dbPath is /data/db but the pre-installed config file /etc/mongod.conf has set /var/lib/mongo
I am using mongo v2.6 I am trying to setup path in mongod.conf but not sure what parameter name is called or whether mongo has one ? For instance for data, mongo uses this parameter: dbpath and for mongo logs, it uses this parameter: logpath
I am trying to find the parameter path name for journal ? The goal is to separate the journal logs from getting created in the data path & put them on separate volume.. is this doable ?
Thanks.
I don't believe there is a way of specifying the journal path in the config file, but there is a a fair workaround for this matter.
As mentioned in this DB StackExchange Topic, the person who provided the top answer recommends creating a symbolic link to a new mountpoint for the default journal folder, which is a sub-directory of the dbpath folder, named journal.
I'd like to use a relative path for mongodb, so that each user has a separate data directory when running mongo.
I've tried setting
dbpath = ~/mongodb_data
in my config file, but for some reason that doesn't seem to work - I'm getting:
ERROR: dbpath (~/mongodb_data) does not exist.
At first I thought it might be a permissions error, but I'm running mongod under a user that has rw to ~/mongodb_data.
Is what I'm trying to do feasible, and, if so, how do I get to doing it?
Hello blueberryfields,
I was able to do that just like that on my windows machine:
mongod --dbpath ..\..\data\db
You can use a symbolic link as well.
But as already mentioned, a update on users start up script is the best manageable solution.
I would specify the full path from root rather than using the tilde. I'm not sure it can use that.
dbpath = /home/yourusername/mongodb_data
Sorry if my question is nooby, but I can't find any info about it over the net.
My situation is that I have only three files left from my previous DB (they are db_name.0, db_name.1 and db_name.ns), everything else from that system is lost. The DB version was 1.8 and the files were in /data/db.
Now I have a new DB (which is 2.0) on the new system, so I tried to put them to the new DB path, it seems that DB sees them, but doesn't eat (it doesn't say there's something wrong with DB, but records are nil). I know well there was some data. And I have it in app specs from the customer, so I can type manually this data in new DB again, but I'd like to know if there's a way to make this new DB see the old data in these files (not to do the work that had been done). I restarted mongod, tried mongod --repair — nothing. Is there a way to make MongoDB see these files?
And, now I have two pathes, /data/db and /var/lib/mongodb (which one is right to use?).
which one is right to use?
There is no "right one". When you start MongoDB, you have to point it to a DB folder by setting the --dbpath folder. It can really be any folder you want as long as the user who starts the mongod process also has access to that folder.
Is there a way to make MongoDB see these files?
The files you have listed are the default files created when a new DB is created. MongoDB allocates files in advance of needing them. So it's quite possible that these files are indeed empty.
I am using mongodb and I have changed the dbpath. Can I just copy all the files from the earlier dbpath to the new dbpath?
PS: I have come across the mongodump alternative which might be a bit tedious. So I am interested in knwoing whether plain copying work?
Yes, you can just do a normal copy if you shutdown your mongod first. You don't need to copy mongod.lock.