数据库
首页 > 数据库> > Mysql 实列结构-进程

Mysql 实列结构-进程

作者:互联网

一、MySQL后台进程简介

master thread与四大I/O线程:read thread、write thread、redo log thread、change buffer thread与

page cleaner thread、purge thread、checkpoint、error monitor thread、lock monitor thread。

 

二、master thread

master thread是后台线程中的主线程,优先级别最高。此线程内部有四个循环,分别为:

主循环lopp、后台循环background loop、刷新循环flush loop、暂停循环suspend loop

1、主循环loop包含两个操作

1s操作

1)日志缓冲刷新到磁盘,即使这个事务没有提交

2)刷新脏页到磁盘

3)执行和并插入缓冲的操作

4)产生checkpoint

5)清除无用的table cache

6)如果当前没有用户活动,就可能切换到background loop

10s操作

1)日志缓冲刷新到磁盘,即使事务还没有提交

2)执行和并插入缓冲的操作

3)刷新脏页到磁盘

4)删除无用的undo页

5)产生checkpoint

 

三、log buffer thread

log buffer thread负责把日志缓冲中的内容刷新到redo log文件中。

 

四、change buffer thread

change buffer thread负责把插入缓冲(change buffer)中的内容刷新到磁盘。

 

五、read/write thread

read/write thread是数据库的读写线程,默认值都是4个。

如果使用高转速的磁盘,可以适当调大该值。

 

六、page cleaner thread

page cleaner thread是负责脏页刷新的线程。

MySQL5.7之后可以增加多个。

 

七、purge thread

purge thread负责删除无用的undo页。由于进行DML语句的操作都会生成undo,系统需要定期

对undo页进行清理,这是需要purge操作。

MySQL5.6开始,把purge thread专门从master thread中分离出来,通过innodb_purge_thread参数

来控制purge的线程个数。默认为1个,最大可以调整为32个。

 

八、checkpoint线程

checkpoint线程的作用是在redo log发生切换时,执行checkpoint。redo log发生切换或者文件快写

满时,会触发把脏页刷新到磁盘。还有就是确保redo log刷新到磁盘,实现真正的持久化,避免数据丢失。

 

九、error monitor thread

error monitor thread时负责数据库报错的监控线程

 

十、lock monitor thread

lock monitor thread是负责锁的监控线程

 

标签:log,thread,刷新,实列,purge,线程,Mysql,进程,磁盘
来源: https://www.cnblogs.com/xibuhaohao/p/10718120.html