@@ -116,63 +116,64 @@ The data files in your data directory, which is the :file:`/data/db`
116
116
directory in default configurations, might be larger than the data set
117
117
inserted into the database. Consider the following possible causes:
118
118
119
- - Preallocated data files.
120
-
121
- In the data directory, MongoDB preallocates data files to a
122
- particular size, in part to prevent file system
123
- fragmentation. MongoDB names the first data file ``<databasename>.0``,
124
- the next ``<databasename>.1``, etc. The first file :program:`mongod`
125
- allocates is 64 megabytes, the next 128 megabytes, and so on, up to
126
- 2 gigabytes, at which point all subsequent files are 2
127
- gigabytes. The data files include files with allocated space but
128
- that hold no data. :program:`mongod` may allocate a 1 gigabyte data
129
- file that may be 90% empty. For most larger databases, unused
130
- allocated space is small compared to the database.
131
-
132
- - The :term:`oplog`.
133
-
134
- If this :program:`mongod` is a member of a replica set, the data
135
- directory includes the :term:`oplog.rs <oplog>` file, which is a
136
- preallocated :term:`capped collection` in the ``local``
137
- database. The default allocation is approximately 5% of disk space
138
- on 64-bit installations, see :ref:`Oplog Sizing
139
- <replica-set-oplog-sizing>` for more information. In most cases, you
140
- should not need to resize the oplog. However, if you do, see
141
- :doc:`/tutorial/change-oplog-size`.
142
-
143
- - The :term:`journal`.
144
-
145
- The data directory contains the journal files, which store write
146
- operations on disk prior to MongoDB applying them to databases. See
147
- :doc:`/core/journaling`.
148
-
149
- - Empty records.
150
-
151
- MongoDB maintains lists of empty records in data files when
152
- deleting documents and collections. MongoDB can reuse this space,
153
- but will never return this space to the operating system.
154
-
155
- To de-fragment allocated storage, use :dbcommand:`compact`, which
156
- de-fragments allocated space. By de-fragmenting storage, MongoDB
157
- can effectively use the allocated space. :dbcommand:`compact`
158
- requires up to 2 gigabytes of extra disk space to run. Do not
159
- use :dbcommand:`compact` if you are critically low on disk space.
160
-
161
- .. important:: :dbcommand:`compact` only removes fragmentation
162
- from MongoDB data files and does not return any disk space to
163
- the operating system.
164
-
165
- To reclaim deleted space, use :dbcommand:`repairDatabase`, which
166
- rebuilds the database which de-fragments the storage and may release
167
- space to the operating system. :dbcommand:`repairDatabase` requires
168
- up to 2 gigabytes of extra disk space to run. Do not use
169
- :dbcommand:`repairDatabase` if you are critically low on disk space.
170
-
171
- .. warning::
172
- :dbcommand:`repairDatabase` requires enough free disk space to
173
- hold both the old and new database files while the repair is
174
- running. Be aware that :dbcommand:`repairDatabase` will block
175
- all other operations and may take a long time to complete.
119
+ Preallocated data files
120
+ ~~~~~~~~~~~~~~~~~~~~~~~
121
+
122
+ MongoDB preallocates its data files, in part to avoid file system fragmentation.
123
+ The first file that :program:`mongod` creates, ``<databasename>.1``, will be 64
124
+ megabytes. The second, ``<databasename>.2``, will be 128 megabytes; and so on,
125
+ up to 2 gigabytes.
126
+
127
+ The proportion of the preallocated files that is unused is typically small.
128
+ However, The :option:`--smallfiles` option will reduce the size of these
129
+ preallocations, which may be useful if many small databases exist on a disk.
130
+
131
+ The ``oplog``
132
+ ~~~~~~~~~~~~~
133
+
134
+ If this :program:`mongod` is a member of a replica set, the data
135
+ directory includes the :term:`oplog.rs <oplog>` file, which is a
136
+ preallocated :term:`capped collection` in the ``local``
137
+ database.
138
+
139
+ The default allocation is approximately 5% of disk space
140
+ on 64-bit installations. In most cases, you should not need to resize the oplog.
141
+ See :ref:`Oplog Sizing <replica-set-oplog-sizing>` for more information.
142
+
143
+ The ``journal``
144
+ ~~~~~~~~~~~~~~~
145
+
146
+ The data directory contains the journal files, which store write
147
+ operations on disk before MongoDB applies them to databases. See
148
+ :doc:`/core/journaling`.
149
+
150
+ Empty records
151
+ ~~~~~~~~~~~~~
152
+
153
+ MongoDB maintains lists of empty records in data files as it deletes
154
+ documents and collections. MongoDB can reuse this space,
155
+ but will not, by default, return this space to the operating system.
156
+
157
+ To de-fragment allocated storage, use :dbcommand:`compact`. By de-fragmenting
158
+ storage, MongoDB can more effectively use the allocated space.
159
+ :dbcommand:`compact` requires up to 2 gigabytes of extra disk space to run. Do
160
+ not use :dbcommand:`compact` if you are critically low on disk space.
161
+
162
+ :dbcommand:`compact` only removes fragmentation from MongoDB data files within
163
+ a collection, and does not return any disk space to the operating system.
164
+
165
+ If you must reclaim disk space, you can use :dbcommand:`repairDatabase`. This
166
+ command rebuilds the database, de-fragmenting the associated storage in the
167
+ process. This may release space to the operating system.
168
+ :dbcommand:`repairDatabase` requires up to 2 gigabytes of extra disk space to
169
+ run. Do not use :dbcommand:`repairDatabase` if you are critically low on disk
170
+ space.
171
+
172
+ .. warning::
173
+ :dbcommand:`repairDatabase` requires enough free disk space to
174
+ hold both the old and new database files while the repair is
175
+ running. Be aware that :dbcommand:`repairDatabase` will block
176
+ all other operations and may take a long time to complete.
176
177
177
178
How can I check the size of a collection?
178
179
-----------------------------------------
0 commit comments