Mongodb stores data in two places
You seem to have installed mongo with Ubuntu APT.
If you just start the mongod server in a terminal with nohup
or just keep it in another terminal, it assumes the default db path as the default /data/db/
registration directory as /var/log/mongo
.
You may have started mongod
with a command like
./bin/mongod
which accepts the default data directory and logging.
mongorestore
works according to the server configuration mongod
. It is for this reason that you see a spike in space consumption by these directories after launch mongorestore
.
The correct way to start the server mongod
is with the following command
sudo service mongod start
If you don't want to start / stop as a service, you can also mongod
instruct to use the conf file correctly with the following command
./bin/mongod --config /etc/mongod.conf
Conf file mongod
is located in /etc/mongod.conf
. Change dbpath
and logpath
accordingly.
source to share
First of all, I can bring the question into two parts:
- why did the filesystem size decrease after mongorestore
- Why does mongodb store data in two locations?
Answer for the first Q:
Mongorestore only collects data, but the filesystem size may differ from the actual data size. Mogodb is designed in such a way that it will allocate more space than the actual size of the data in the database. For detailed explanation on mongodb website see this section in this link
Why are the files in my data directory larger than the data in my database?
The data files in your data directory, which is / data / db in the default configurations, can be larger than the installed dataset in the database. Consider the following possible causes:
Second Q:
Refer to the answer bsd
seems possible.
source to share