db文件在哪里?在 /var/lib/mongodb 我找不到任何增加的大小。我运行了非常大的循环来创建十万个对象

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12915898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:58:07  来源:igfitidea点击:

Where are the db files? at /var/lib/mongodb I cant find any increase in size. I ran very big loop to create lakhs of objects

mongodb

提问by user1653509

I am using UBUNTU, from /etc/mongod.conf, I found that /var/lib/mongdb is the path for data.

我正在使用 UBUNTU,从 /etc/mongod.conf,我发现 /var/lib/mongdb 是数据的路径。

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

我在该目录中找到了一些文件,例如 collectionname.0、.1、.ns。但是当我运行一个非常大的循环(lakhs)时,我可以使用 mongo shell 将它们取回,但是 mongodb 目录大小没有增加,所以必须有其他地方存储这些数据

What is that place?

那是什么地方?

采纳答案by Mark Hillick

There is no another place. As indicated by @itsbruce, in Ubuntu it's /var/lib/mongodb.

没有其他地方。正如@itsbruce 所指出的,在 Ubuntu 中它是 /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).

在非打包安装(在 Linux 上),即没有 /etc/mongodb.conf 文件时,默认为 /data/db/(除非另有说明)。

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.

您可以修改命令行上的开关“--dbpath”,为 mongod 实例指定不同的目录来存储其数据。典型的位置包括:/srv/mongodb、/var/lib/mongodb 或 /opt/mongodb。

(Windows systems use the \data\db directory.) If you installed using a package management system.

(Windows 系统使用\data\db 目录。)如果您使用包管理系统进行安装。

I recommend using the db.collection.statscommand as outlined hereto monitor the size of your collection as you insert data. The link also explains what each field (in the output) means.

我建议使用此处db.collection.stats概述的命令插入数据时监视集合的大小。该链接还解释了每个字段(在输出中)的含义。

回答by itsbruce

That is the correct data location for MongoDB on Ubuntu. MongoDB pre-allocatesfilespace. 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.

这是 Ubuntu 上 MongoDB 的正确数据位置。MongoDB预分配文件空间。您确定您生成的数据比初始预分配文件多吗?尝试清除所有现有数据文件并使用 --noprealloc 标志重新启动 Mongo。然后添加数据。