当前位置:网站首页>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 .
边栏推荐
- Catheon Gaming任命Activision Blizzard前亚太区负责人Mark Aubrey担任首席执行官
- NFT元宇宙发展能做什么?
- Servlet详解
- Flutter assembly
- 一文带你搞懂 JWT 常见概念 & 优缺点
- What are the reasons why the game industry needs high defense servers?
- Navicat Premium 15 for Mac(数据库开发工具)中文版
- Activation and value transfer of activity
- Linux-MySQL数据库之高级SQL 语句一
- Check whether the port number is occupied
猜你喜欢

Alvaria announces Jeff cotten, a veteran of the customer experience industry, as its new CEO

DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection翻译

Geographic location data storage scheme - redis Geo

In the wechat environment, H5 jumps to the specified page of the applet

一行代码可以做什么?

Don't underestimate the integral mall, its role can be great!
Consumer and producer cases of inter thread synchronization (condition variable)

What exactly is a handler

绕过技术聊'跨端'......
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
随机推荐
Converting cifar10 datasets
Golang open source streaming media audio and video network transmission service -lal
Advanced SQL statement 1 of Linux MySQL database
f_read 函数[通俗易懂]
How to reload the win10 app store?
What are some tricks that novice programmers don't know?
Cocoapods installation in 2021
Process control and method
Coredata data persistence
This article will help you understand the common concepts, advantages and disadvantages of JWT
Hash table, generic
GridLayout evenly allocate space
Catheon gaming appointed mark Aubrey, former Asia Pacific head of Activision Blizzard, as CEO
What processes are needed to build a wechat applet from scratch?
炮打司令部,别让一个UI框架把你毁了
Introduction to MgO 256gb NAND flash chip
心楼:华为运动健康的七年筑造之旅
What can NFT metauniverse development do?
有哪些新手程序员不知道的小技巧?
Constructor Pattern