MongoDB在哪里存储索引数据? [英] Where does MongoDB store index data?

查看:68
本文介绍了MongoDB在哪里存储索引数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个单独的磁盘来存储MongoDB数据库.但是我意识到,数据库也有索引.因此,我可能需要使磁盘的大小大于记录的大小.

I want to create a separate disk to store MongoDB Database. But I realized that, databases also have indexes. So I might need to have disk size more than the size of records.

问题是mongo db在哪里存储它的索引数据.在配置文件中,我们仅提及日志和db文件夹的路径.

The question is where does mongo db stores it's index data. In config file we only mention path of logs and db folder.

推荐答案

问题是mongo db在哪里存储它的索引数据.在配置中文件,我们只提到日志和db文件夹的路径.

The question is where does mongo db stores it's index data. In config file we only mention path of logs and db folder.

索引数据与收集数据一起存储在MongoDB Server安装目录的 data 目录中.您还可以使用-指定数据目录 mongod 时的-dbpath 存储选项.

The index data is stored along with the collection data in the data directory of the MongoDB Server installation. You can also specify the data directory using the --dbpath storage option when you start the mongod.

文件的存储名称如下:

collection-2-3986418375741882655.wt 
index-1-221874391618151955.wt

第一个是收集数据文件,第二个是索引数据文件.对于每个集合和索引,分别为每个创建一个文件.因此,如果有3个集合和5个索引,则将有8个文件(数据目录中还有其他文件).

The first one is a collection data file and the second one is an index data file. For each collection and index, one file for each is created respectively. So, if there are 3 collections and 5 indexes there will be 8 files (the data directory has other files too).

还有一个 --directoryperdb选项,当指定时:

There is also a --directoryperdb option, which when specified:

使用单独的目录存储每个数据库的数据.这目录位于--dbpath目录和每个子目录下名称与数据库名称相对应.

Uses a separate directory to store data for each database. The directories are under the --dbpath directory, and each subdirectory name corresponds to the database name.

:索引可以存储在单独的目录中

MongoDB配置文件选项-存储.wiredTiger.engineConfig.directoryForIndexes

storage.wiredTiger.engineConfig.directoryForIndexes 为true时, mongod 将索引和集合存储在单独子目录中在数据(即storage.dbPath)目录下.具体来说, mongod 将索引存储在名为 index 的子目录和集合中数据位于名为 collection 的子目录中.

When storage.wiredTiger.engineConfig.directoryForIndexes is true, mongod stores indexes and collections in separate subdirectories under the data (i.e. storage.dbPath) directory. Specifically, mongod stores the indexes in a subdirectory named index and the collection data in a subdirectory named collection.

这篇关于MongoDB在哪里存储索引数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆