Database Reference
In-Depth Information
In this example, repair detected that the admin database was probably created under an older version of
MongoDB and that it required an upgrade of its storage format to match the currently running server.
it is normal for the server to exit after running the mongod utility with the --repair option; to bring it back
online, just start it up again without specifying the --repair option.
Note
Once the repair process finishes, you should be able to start up the server as usual, and then restore any missing
data from your backups.
If you're trying to repair a large database, you may find that your drive runs out of disk space because MongoDB
may need to make a temporary copy of the database files on the same drive as the data (see the .../$tmp_
repairDatabase_0/.. directory in the preceding example).
To overcome this potential issue, the MongoDB repair utility supports an additional command-line parameter
called --repairpath . You can use this parameter to specify a drive with enough space to hold the temporary files it
creates during the rebuild process, as in the following example:
$ mongod -f /etc/mongodb.conf --repair --repairpath /mnt/bigdrive/tempdir
Validating a Single Collection
Occasionally, you may suspect there is a problem with the data on a running server. In this case, you can use a handful
of tools that ship with MongoDB to help you determine whether the server in question is corrupted or damaged.
You can use the validate option to validate the contents of a collection in a database. The next example shows
how to run the validate option against a collection with one million records in it:
$mongo
> use blog
switched to db blog
>db.posts.ensureIndex({Author:1})
> db.posts.validate()
{
"ns" : "blog.posts",
"firstExtent" : "0:f000 ns:blog.posts",
"lastExtent" : "0:2b9000 ns:blog.posts",
"extentCount" : 6,
"datasize" : 6717520,
"nrecords" : 29997,
"lastExtentSize" : 8388608,
"padding" : 1,
"firstExtentDetails" : {
"loc" : "0:f000",
"xnext" : "0:11000",
"xprev" : "null",
"nsdiag" : "blog.posts",
"size" : 8192,
"firstRecord" : "0:f0b0",
"lastRecord" : "0:10e50"
},
 
 
Search WWH ::




Custom Search