当前位置:网站首页>The difference between journal log and oplog log
The difference between journal log and oplog log
2022-07-19 10:55:00 【I want to become a monk】
Catalog
Two 、 The data range is different
I'm learning mongoDB When it comes to basic knowledge , Some concepts may be confused , such as Journal Journal and oplog What's the difference between logs .
The following content is mainly extracted from 《MongoDB Principle and practice 》 Written by Zhang Youdong
One 、 Different concepts
1、Journal journal
Journal The journal is MongoDB The mechanism of the storage engine layer , ⽬ front MongoDB All storage engines ⽀ Holding configuration Journal, since 2.0 Start default on . stay MongoDB Write all the data in ⼊、 Reading is ultimately implemented by calling the interface of the storage engine layer , and Journal Logs are used to record write operations , To achieve the purpose of data failure recovery and persistent data .
With wiredtiger For example , If you don't configure Journal, Write ⼊ wiredtiger The data of , It's not ⽴ Persistent storage ; ⽽ I do it every minute ⼀ Sub total checkpoint(storage.syncPeriodSecs Configuration item , The default is 1 minute ) , Make all data persistent . If there is an outage in the middle , Then the data can only be restored to the latest ⼀ Time checkpoint, In this way, you may lose the most recent 1 Minute data . And when you turn on Journal After the log , Every operation written to the database will be recorded , In the event of downtime , After recovering to the latest checkpoint After the point , You can continue to replay the subsequent operation logs , Restore data .
2、Oplog journal
Oplog The log defaults to mongoDB Enabled in replica set mode .Oplog Logs are mainly used for Primary Nodes and Secondary Data synchronization of nodes ,Oplog Recorded Primary All write operations of the node ,Secondary Nodes are copied on a regular basis Primary Node Oplog Achieve incremental backup .
since mongoDB3.6 Newly added changestream The mechanism is also based on oplog Realized .ChangeStreams stay Oplog A layer of application is wrapped on it , Provide a API Interface , Push the data in real time .

FIG selected 《mongodb Introduction of actual combat 》
Two 、 The data range is different
With mongoDB For example, insert data once in the replica set , At the data level, it is divided into the following three steps :
1. take ⽂ File data write ⼊ Corresponding set
2. Update all index information of the collection
3. Write ⼊⼀ strip oplog⽤ In sync
On ⾯3 Modification operations , You need to make sure that it's either successful , Or they all failed .MongoDB Writing ⼊ Data time , Will put the above 3 Put operations into ⼀ individual wiredtiger The business of ⾥, Make sure 「 primary ⼦ sex 」 . As shown below :
// Start business
beginTransaction();
// Three steps to insert data
writeDataToColleciton();
writeCollectionIndex();
writeOplog();
// Commit transaction
commitTransaction();The execution sequence is shown in the figure below :

wiredtiger When committing a transaction , All modifications will be ⽤, And put the above 3 Operation write ⼊ To ⼀ strip journal In the operation log ; The backstage will be cyclical checkpoint, Persist changes , And remove the useless journal. From the data layout , oplog And journal The relationship is as follows :

边栏推荐
- Opencv programming: opencv3 X trains its own classifier
- Scala在Idea中的配量
- 【CSP-J 2021】总结
- 移植吴恩达深度学习01机器学习和神经网络第二周神经网络基础编程作业选修作业到pycharm
- Beego框架实现文件上传+七牛云存储
- Brush questions with binary tree (2)
- 金鱼哥RHCA回忆录:CL210描述OPENSTACK控制平面--识别overclound控制平台服务+章节实验
- [csp-j 2021] summary
- [leetcode weekly replay] 302 weekly 20220717
- Pytorch. NN implementation of multi-layer perceptron
猜你喜欢

Mobile keyboard (simulation question)

Journal日志与oplog日志的区别

ROS duplicate name

常见集合特性

Pytorch学习记录2 线性回归(Tensor,Variable)

vulnhub inclusiveness: 1

从预测到决策,九章云极DataCanvas推出YLearn因果学习开源项目

ENVI_ Idl: use the inverse distance weight method to select the nearest n points for interpolation (bottom implementation) and output them to GeoTIFF format (the effect is equivalent to the inverse di

【在vivado中调ila IP核】

Leetcode丑数题解
随机推荐
SVN学习
LeetCode 2325. Decrypt message (map)
About hping streaming test tool
关于hping打流测试工具
LeetCode 2319. 判断矩阵是否是一个 X 矩阵
antd 下拉多选传值到后台做查询操作
6G智慧内生:技术挑战、架构和关键特征
企业远程办公如何更高效?
[leetcode weekly replay] 302 weekly 20220717
博弈论(depu)与投资(40/100)
从预测到决策,九章云极DataCanvas推出YLearn因果学习开源项目
Aike AI frontier promotion (7.17)
[design process] Net ORM FreeSQL wheredynamicfilter dynamic table query function
How to use SVG to make text effects arranged along any path
Win10安装Apache Jena 3.17
ENVI_ Idl: use the inverse distance weight method to select the nearest n points for interpolation (bottom implementation) and output them to GeoTIFF format (the effect is equivalent to the inverse di
High number__ Relationship between equation and function
Structure the combat battalion | module 7
vulnhub inclusiveness: 1
Pytoch realizes multi-layer perceptron manually