当前位置:网站首页>Read mysql45 the next day
Read mysql45 the next day
2022-06-25 16:24:00 【Hurry to Friday】
mysql The medium log system has the following functions: server Layer. binlog journal ( Archive log ), also InnoDB In the engine layer redolog journal ( Redo log );binlog Is stored in sql Modified logical log .
show binary logs Commands can be viewed binlog Log files , I am here dbeaver Use this command to view the display 860 and 861
show binglog events in 'mysql-bin.000861’ You can view the contents of specific log files , But I read it for a while and didn't understand what was in it .
redolog The physical log is stored , That is, which rows change the value . I still don't know what the log content is , Just remember that one is a physical log and the other is a logical log .
show variables like ‘innodb_log%’
You can see redo Log related configuration :
Here, the log size log is configured as 524288000,524288000/1024/1024 Is almost 500MB, One group is 2 File , So the size that this group of files can record is 1000MB about ;

In the figure write pos What is recorded is where the log is currently written , Move back as you write , When moved to ib_logfile_3 At the end of , It will start from ib_logfile_0 restart ;
check point It is the place that needs to be erased at present . Every time an update statement is executed ,InnoDB It doesn't have to be done immediately , Instead, store the records in redolog In the Journal , Then update the memory ,
At this time, it is finished , In fact, it has not been updated to the disk . If every time an update statement comes , Write to the disk immediately , Repetitive operations can also be costly , So first record it in redolog In the Journal ,
Then execute when the database is idle , Such execution efficiency will be relatively high , It's kind of similar IO Buffer in .
When there are data records that need to be changed ,InnoDB The engine will first write the change value in redolog In the Journal , And then update it to memory , When the database is idle, update it to the disk , This process is called WAL,
The full name is Write-Ahead Loggin The key point is to write a log first And then update it to disk .redolog The log makes the database restart abnormally , No records submitted before will be lost , This can become Crash-Safe.
redo Logs are fixed size , It's recycled , So it will keep overwriting the previous logs ,binlog You can add log files by appending , Therefore, the previous log files will not be overwritten .
General process of updating records :
1. actuator : take id=2 The record of num Liega 2
2. Engine layer : The engine interface is based on id=2 Find that record , If the record is in memory, it will be returned directly , If not, read from the disk to the memory and return ( In this place, I am curious that the record is not in the memory, so I look for it from the disk , So what happens
Invalidate previous records in memory ? There are too many things to be stored in the memory, which will delete the things that first existed in the memory ?)
3. actuator : After getting this line of value , to num+2 Then return to the engine layer
4. Engine layer : take num+2 The value of is written to memory , At the same time, write this value to redolog In the log , here redolog be in prepare state , Then inform the actuator that it has finished , You can commit a transaction .
5. The actuator generates this update operation binglog journal , Then write to binglog In the disk file of
6. The executor calls the commit transaction interface of the engine to commit transactions
7. When the engine interface receives the request to commit a transaction, it will send the following message redolog Change the status of the log to the submission status , Update complete .
You can see that redolog There are two log operations , The first write is prepare state , The second, commit state . This is the two-stage submission .
Two phase commit can prevent abnormal restart of the database , Give Way redolog and binglog Inconsistent operation records appear , That is, two-phase submission is to make redolog and binglog Try to keep the log records consistent .
innodb_flush_log_at_trx_commit This parameter is set to 1 Every time said redolog When logging, it will be persisted to the disk , This prevents the loss of operation records ;
sync_binlog Parameter is 1 Every time said binlog Log operations are persisted to disk files .
边栏推荐
- File operation, serialization, recursive copy
- White screen, how fouc is formed, and how to avoid it
- DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection翻译
- Linux-MySQL数据库之高级SQL 语句一
- 什么是骨干网
- MySQL installation tutorial
- 加密潮流:时尚向元宇宙的进阶
- Most commonly used SQL statements
- The textfield is encapsulated by the flutter itself, which causes the data display to be disordered when the data in the list is updated.
- 数据存储和传输文件之XML使用和解析详解
猜你喜欢

Based on neural tag search, the multilingual abstracts of zero samples of Chinese Academy of Sciences and Microsoft Asiatic research were selected into ACL 2022
Practice of geospatial data in Nepal graph
Mixed density network (MDN) for multiple regression explanation and code example
Classic deadlock scenario of multithreading and its solution (philosopher dining problem)
Golang open source streaming media audio and video network transmission service -lal

GO语言-锁操作

说下你对方法区演变过程和内部结构的理解

The style of the mall can also change a lot. DIY can learn about it!

Reverse series to obtain any wechat applet code

mysql整体架构和语句的执行流程
随机推荐
Div element
Catheon Gaming任命Activision Blizzard前亚太区负责人Mark Aubrey担任首席执行官
Lifeifei's team applied vit to the robot, increased the maximum speed of planning reasoning by 512 times, and also cued hekaiming's MAE
What is backbone network
Based on neural tag search, the multilingual abstracts of zero samples of Chinese Academy of Sciences and Microsoft Asiatic research were selected into ACL 2022
深度学习 pytorch cifar10数据集训练「建议收藏」
Error: homebrew core is a shallow clone
What can one line of code do?
Go development team technical leader Russ Cox sends a document to share go's version control history
Beginner bug set
Uncover gaussdb (for redis): comprehensive comparison of CODIS
Precautions for function default parameters (formal parameter angle)
Day21 multithreading
Dino: Detr with improved detecting anchor boxes for end to end object detection
Message format of Modbus (PLC)
Problems caused by using ApplicationContext to render layout
一行代码可以做什么?
数据存储和传输文件之XML使用和解析详解
Flutter assembly
Learning notes of rxjs takeuntil operator