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.
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
After a complete reinstall of mongo, it has still remembered the replica set configuration from before; where has it stored this?
I installed mongo on a linux server, using our project's user account, into a directory owned by that user. I set up replication and had it working fine. Then, to test out some finer install points, I removed the whole mongo directory and did a reinstall. Entering into mongo, I found that the replication was already set up as before; so it would appear that mongo is storing the information somewhere.
I have checked several areas which might have been holding the replica set config:
First, in the mongo directory, but that was deleted.
In some traditional linux structure probably owned by root, but the project user does not have root access and mongo, run by the same, should not either.
The project user's home directory. Now this does have a .dbshell file containing the command line history, but only that. I did not see any other files there that related.
Some location specified in the mongo configuration. But I only have two paths mentioned in there, one for the system log (systemLog.path) and the other for storage (storage.dbPath), and the both point to the mongo directory, which was deleted.
Does anyone know where mongo is storing this configuration information?
The replication data is stored in the local database in each node (as of MongoDB 3.2.9). This database contains information about the replica set, and also contains the oplog (the oplog.rs collection). The replica set information is stored in the system.replset collection in this local database.
The physical files for this database (and also for other databases) are stored in the dbPath directory, which can be configured using:
The --dbpath parameter when starting mongod
The storage.dbPath setting in the configuration file
The default dbpath value is /data/db
Your replica set setting will not be retained if you emptied the dbpath directory. If you find that the replication settings are being retained, it is possible that the dbpath setting is incorrect.
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
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
I am using UBUNTU, from /etc/mongod.conf, I found that /var/lib/mongdb is the path for data.
I have found some files like collectionname.0, .1, .ns in that directory. but when I run a very big loop(lakhs), I am able to get them back using mongo shell, but that mongodb directory size is not increasing, so there must be someother place where this data is being stored
What is that place?
There is no another place. As indicated by #itsbruce, in Ubuntu it's /var/lib/mongodb.
On a non-packaged installation (on Linux), i.e. without a /etc/mongodb.conf file, the default is /data/db/ (unless otherwise specified).
You can modify the switch "--dbpath" on the command line to designate a different directory for the mongod instance to store its data. Typical locations include: /srv/mongodb, /var/lib/mongodb or /opt/mongodb.
(Windows systems use the \data\db directory.) If you installed using a package management system.
I recommend using the db.collection.stats command as outlined here to monitor the size of your collection as you insert data. The link also explains what each field (in the output) means.
That is the correct data location for MongoDB on Ubuntu. MongoDB pre-allocates filespace. Are you sure you have generated more data than would fit into the initial pre-allocated files? Try blowing away any existing data files and restarting Mongo with the --noprealloc flag. Then add data.