Journal Files (e.g. journal/j._0)Journal files are append-only and are written to the journal/ directory under the dbpath directory (which is /data/db/ by default). Journal files are named j._0, j._1, etc. When a journal file reached 1GB in size, a new file is created. Old files which are no longer needed are rotated out (automatically deleted). Unless your write bytes/second rate is extremely high, you should have only two or three journal files. Note: in more recent versions, the journal files are only 128MB apiece when using the --smallfiles command line option. Prealloc Files (e.g. journal/prealloc.0)mongod will create prealloc files in the journal directory under some circumstances to minimize journal write latency. On some filesystems, appending to a file and making it larger can be slower than writing to a file of a predefined size. mongod checks this at startup and if it finds this to be the case will use preallocated journal files. If found to be helpful, a small pool of prealloc files will be created in the journal directory before startup begins. This is a one time initiation and does not occur with future invocations. Approximately 3GB of files will be preallocated (and truly prewritten, not sparse allocated) - thus in this situation, expect roughly a 3 minute delay on the first startup to preallocate these files. If you don't want to wait three minutes on startup, you can preallocate the files using another instance of mongod and then move them to your normal dbpath before starting with journaling. For example, if you had an instance of mongod running on port 27017 with a dbpath of /data/db (the defaults), you could preallocate journal files for it with: $ mkdir ~/tmpDbpath $ mongod --port 10000 --dbpath ~/tmpDbpath --journal # startup messages # . # . # . # wait for prealloc to finish Thu Mar 17 10:02:52 [initandlisten] preallocating a journal file ~/tmpDbpath/journal/prealloc.0 Thu Mar 17 10:03:03 [initandlisten] preallocating a journal file ~/tmpDbpath/journal/prealloc.1 Thu Mar 17 10:03:14 [initandlisten] preallocating a journal file ~/tmpDbpath/journal/prealloc.2 Thu Mar 17 10:03:25 [initandlisten] flushing directory ~/tmpDbpath/journal Thu Mar 17 10:03:25 [initandlisten] flushing directory ~/tmpDbpath/journal Thu Mar 17 10:03:25 [initandlisten] waiting for connections on port 10000 Thu Mar 17 10:03:25 [websvr] web admin interface listening on port 11000 # then Ctrl-C to kill this instance ^C $ mv ~/tmpDbpath/journal /data/db/ $ # restart mongod on port 27017 with --journal prealloc files do not contain data, but are rather simply preallocated files that are ready to use that are truly preallocated by the file system (i.e. they are not "sparse"). It is thus safe to remove them, but if you restart mongod with journaling, it will create them again if they are missing. serverStatus commandThe serverStatus command now includes some statistics regarding journaling. journalLatencyTest CommandYou can use the journalLatencyTest command to measure how long it takes on your volume to write to the disk (including fsyncing the data) in an append-only fashion. > use admin
> db.runCommand("journalLatencyTest")
You can run this command on an idle system to get a baseline sync time for journaling. In addition, it is safe to run this command on a busy system to see the sync time on a busy system (which may be higher if the journal directory is on the same volume as the data files). In version 1.9.2+ you can set the group commit interval, using --journalCommitInterval command-line option, to between 2 and 300 milliseconds (default is 100ms). The actual interval will be the maximum of this setting and your disk latency as measured above. journalLatencyTest is also a good way to check if your disk drive is buffering writes in its local cache. If the number is very low (e.g., less than 2ms) and the drive is non-ssd, the drive is probably buffering writes. In that case, you will want to enable cache write-through for the device in your operating system. (Unless you have a disk controller card with battery backed ram, then this is a good thing.) |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus