如果开启journal,在dbpath选项指定的目录下会创建journal目录来存放journal文件,文件名形如j._<n>。journal文件用于数据库异常退出时恢复数据。这里是解析journal文件的示例代码。
journal文件的大小定义如下,smallfiles选项可以指定为128M。
// Rotate after reaching this data size in a journal (j._<n>) file // We use a smaller size for 32 bit as the journal is mmapped during recovery (only) // Note if you take a set of datafiles, including journal files, from 32->64 or vice-versa, it must // work. (and should as-is) // --smallfiles makes the limit small. #if defined(_DEBUG) unsigned long long DataLimitPerJournalFile = 128 * 1024 * 1024; #elif defined(__APPLE__) // assuming a developer box if OS X unsigned long long DataLimitPerJournalFile = 256 * 1024 * 1024; #else unsigned long long DataLimitPerJournalFile = (sizeof(void*)==4) ? 256 * 1024 * 1024 : 1 * 1024 * 1024 * 1024; #endif