当前位置: 首页 >数据库 > 52.MySQL Innodb_fast_shutdown参数

52.MySQL Innodb_fast_shutdown参数

1.前言

  上周在公司主要做了从mysql5.7.21迁移到mysql8.0.25的版本升级迁移,其中在迁移文档中就有这个参数

2.参数介绍

  这里就直接看官方文档上面的介绍说

  52.MySQL Innodb_fast_shutdown参数 _ JavaClub全栈架构师技术笔记

  从这里看出该系统变量有三个可选值,其中1是默认值,然后再来看看它的解释:

The InnoDB shutdown mode. If the value is 0, InnoDB does a slow shutdown, a full purge and a change buffer merge before shutting down. If the value is 1 (the default), InnoDB skips these operations at shutdown, a process known as a fast shutdown. If the value is 2, InnoDB flushes its logs and shuts down cold, as if MySQL had crashed; no committed transactions are lost, but the crash recovery operation makes the next startup take longer.The slow shutdown can take minutes, or even hours in extreme cases where substantial amounts of data are still buffered. Use the slow shutdown technique before upgrading or downgrading between MySQL major releases, so that all data files are fully prepared in case the upgrade process updates the file format.Use innodb_fast_shutdown=2 in emergency or troubleshooting situations, to get the absolute fastest shutdown if data is at risk of corruption.

    如果该值是0的话,innodb会做一个慢的关闭过程(为什么慢呢?) --->这是因为在关闭innodb之前首先会做一个完全清除和更改缓冲区合并操作(这句话等会再解释)

    如果该值是1的话,innodb会在关闭之前会跳过这些操作进行关闭,因为这种关闭过程也可以被称为快速关闭。

  如果该值是2的话,innodb会刷新它的日志(这里的日志指的是重做日志redo log)并且进行一个冷关闭(这里我不也不知道什么是冷关闭),就好像mysql发生宕机了一样(就会导致没有提交的事务会丢失),但是在恢复启动的时候它可能需要比较的长的时间。

    在有大量的缓冲数据的时候,使用慢关闭可能需要几分钟甚至几小时。一般使用慢关闭技术会在升级或者降级mysql主流版本的时候使用以便在升级过程更新文件格式时做好所有数据文件的准备

    在紧急情况或故障排除情况下使用 innodb_fast_shutdown=2,以便在数据存在损坏风险时获得绝对最快的关闭速度。

 3.补充

  这里需要补充一些知识,因为只是看上面的官方文档解释可能有点不全面(以下来自于互联网)

  • 0表示在innodb关闭的时候,需要purge all,merge insert buffer,flush dirty pages. 这是一种最慢的关闭方式,但是restart的时候也是最快的
  • 1表示在innodb关闭的时候,它不需要purge all,merge insert buffer,只需要flush dirty page,在缓冲池中的一些数据脏页会刷新到磁盘
  • 2表示在innodb关闭的时候,它不需要purge all,merge insert buffer,也不进行flush dirty page,只将log buffer 里面的日志刷新到日志文件log files,mysql下次启动时,会执行恢复操作   

   如果在上次关闭innodb的时候是在innodb_fast_shutdown=2或是mysql crash这种情况,那么它会利用redo log 重做那些已经提交了的事务

     接下来的操作过程是:

  1. Rollback uncompleted transitions 取消那些没有提交的事务
  2. Purge all 清除无用的undo页
  3. Merge insert buffer 合并插入缓冲

       

 

来源链接:https://www.cnblogs.com/zmc60/p/15889243.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/117899.html

标签:MySQL升级
分享给朋友:

“52.MySQL Innodb_fast_shutdown参数” 的相关文章

JDBC工具类(DButil) 2022年05月13日 09:13:25
MYSQL的存储过程 2022年05月16日 21:54:19
sql递归查询 2022年05月17日 21:40:33
mysql查询最新的一条记录 2022年06月06日 16:04:12
Mysql查询用户最后一次登陆时间 2022年06月12日 13:54:22
MySQL查询指定行的记录 2022年06月14日 06:02:58