In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
MongoDB log is how to work, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Good idea, Patrick!
So how does the MongoDB log work?
We use the following figure to show the data files and log files on the hard disk:
When you start MongoDB using mongod, the data files will be loaded into the shared view. Basically, the operating system says, "OK, your data takes up 2000bytes disk space, and I will load them to a memory address of 1000000-1002000. So, if you read the memory address of 1meme2000 042, you can get the data of the 42nd byte of this file." (in fact, unless you actually access these memory addresses, there is no need to load the data.)
The memory is still occupied by the data file: if you make changes in this memory, the operating system will refresh the file and modify the data. This is how mongod does not turn on logging: the process notifies the operating system to flush this memory every 60 seconds.
However, by enabling logging, mongod establishes another memory map to use as a private view. This is why you need to allocate twice as much memory as mongod to log operations.
It should be noted that the private view is not directly associated with the data file, and the operating system used cannot write data to disk by refreshing the private view.
Now, when you have a write operation, the mongod process writes the operation to the private view.
The mongod process writes this operation to the log file and describes which file and which byte has been modified.
Log each modification operation.
At this time, the write operation is safe. If the mongod process crashes, the log can reproduce the modification, even if no updates have been made to the data file.
The mongod process then remaps the shared view to the private view, which prevents the private view from being too "dirty" (with too many modifications relative to the mapped shared view).
Finally, after a series of lengthy validation, the shared view data will be flushed to disk. By default, mongod requests a refresh operation on OS every 60 seconds.
And that's how journaling works. Thanks to Richard, who gave the best explanation of this I've heard (Richard is going to be teaching an online course on MongoDB this fall, if you're interested in more wisdom from the source).
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.