简体   繁体   中英

What is the difference between journal and non journal Mongodb database

i just installed mongodb 32 bit version, this is the message which prints in my terminal when i start mongodb

Server has startup warnings: 
Wed Jul 16 09:53:43.759 [initandlisten] 
Wed Jul 16 09:53:43.759 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary. 
Wed Jul 16 09:53:43.759 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Wed Jul 16 09:53:43.759 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Wed Jul 16 09:53:43.759 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Wed Jul 16 09:53:43.759 [initandlisten] 
>

From here i noticed or understood 2 things, my mongodb database is limited to storage of less than 2gb database

it is non journalized,

Journalizing makes the space decrease much further

I was wondering

  1. what is this journal/non-journal mongodb database

  2. what is the advantage of journal database over nonjournal database or vice versa?

  3. Is it necessary to journal my database?

Please help me in this

Thanks

In MongoDB it uses write ahead logging to check whether a write operation is performed or to write a crash report this called journaling

If there is no journaling say you work on millions of transaction . if some transaction may be crashed or incompletely terminated . there will be no trace for you to know the issue. so how can one find the where does the issue occurred and recover it

other situations are like if db has exists unexpectedly you will not able to know the reason

From docs it clearly states that

Without a journal, if mongod exits unexpectedly, you must assume your data is in an inconsistent state, and you must run either repair or, preferably, resync from a clean member of the replica set. With journaling enabled, if mongod stops unexpectedly, the program can recover everything written to the journal, and the data remains in a consistent state. By default, the greatest extent of lost writes, ie, those not made to the journal, are those made in the last 100 milliseconds. See commitIntervalMs for more information on the default.

Journaling is a concept where you take a backup, before you write your data in your data files.

The reason we do this is for durability. And journaling is highly recommended in production environment.

The advantage of using journal is when there is dirty shutdown or crash, you may loose your data entry operations in general you may loose your data.

Without Journaling

When a write operation happens your data is written to data drive every 60 seconds from your memory mapped shared view.

With Journaling

Your write operations are first written to journal files every 100- 200 ms. and after journal commit it is copied to shared view and from there after 60 seconds data is flushed to your actual data drive.

What do we get here? So what happens here is

  1. we took a back up of your data before writing to actual data files.
  2. we reduced the time from 60 sec to 200 ms. so every 100 - 200 ms your data operations are logged in journal so in case of shutdown we can replay those operations and can avoid message loss.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM