Mongodb: Directory Per DB

启动MongoDB的时候,通常会使用--dbpath来指定存放mongodb数据文件的目录,但是--dbpath不能够带多个目录,所以当一台机器上总的磁盘空间很大但是每个分区空间都无法满足要求的时候,在不考虑加磁盘或者sharding模式外的办法,目前就只用使用--directoryperdb这个参数为每个db设定其归属目录,但是需要注意的是当我们只有一个db,而它需要占用很多空间的时候,这个参数也没有办法了!

--directoryperdb的使用场景就是我们有不同的物理磁盘,每个db的大小能够很好的放在相应的磁盘上的时候,可以通过这种配置方式提高访问磁盘的速度。


本文来自mongodb官方文档:http://www.mongodb.org/display/DOCS/Directory+Per+DB

Overview

MongoDB supports a "directory per DB" option.

By default data files for MongoDB are all created in a single directory. This directory is defined by the --dbpath variable.

The "directory per DB" option (--directoryperdb) allows for a separate directory for the files of each database.

Uses

The most common use for this option is to enable data to be stored on different physical disks. This is generally accomplished by creating a symbolic link to the appropriate underlying hardware.

Example

The following sample demonstrates the difference in directory structures. The db/ directory is run without "directory per DB", the db2/directory is run with "directory per DB".

db:
total 417M
-rw------- 1 mongo mongo  64M 2011-04-05 12:50 foo.0
-rw------- 1 mongo mongo 128M 2011-04-05 12:50 foo.1
-rw------- 1 mongo mongo  16M 2011-04-05 12:50 foo.ns
-rw------- 1 mongo mongo  64M 2011-04-05 12:48 test.0
-rw------- 1 mongo mongo 128M 2011-04-05 12:48 test.1
-rw------- 1 mongo mongo  16M 2011-04-05 12:48 test.ns
-rwxr-xr-x 1 mongo mongo    5 2011-04-05 12:47 mongod.lock

db2:
total 16K
drwxr-xr-x 2 mongo mongo 4.0K 2011-04-05 12:50 foo
-rwxr-xr-x 1 mongo mongo    5 2011-04-05 12:47 mongod.lock
drwxr-xr-x 2 mongo mongo 4.0K 2011-04-05 12:48 test

db2/foo:
total 209M
-rw------- 1 mongo mongo  64M 2011-04-05 12:50 foo.0
-rw------- 1 mongo mongo 128M 2011-04-05 12:50 foo.1
-rw------- 1 mongo mongo  16M 2011-04-05 12:50 foo.ns

db2/test:
total 209M
-rw------- 1 mongo mongo  64M 2011-04-05 12:48 test.0
-rw------- 1 mongo mongo 128M 2011-04-05 12:48 test.1
-rw------- 1 mongo mongo  16M 2011-04-05 12:48 test.ns
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值