当前位置:网站首页>Interpretation of new features | MySQL 8.0 online adjustment REDO
Interpretation of new features | MySQL 8.0 online adjustment REDO
2022-08-04 08:04:00 【ActionTech】
作者:杨涛涛
资深数据库专家,专研 MySQL 十余年.擅长 MySQL、PostgreSQL、MongoDB 等开源数据库相关的备份恢复、SQL 调优、监控运维、高可用架构设计等.目前任职于爱可生,为各大运营商及银行金融企业提供 MySQL 相关技术支持、MySQL 相关课程培训等工作.
本文来源:原创投稿
*爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源.
MySQL 最新版本 8.0.30 The release brings one with REDO New feature points related to log files: 在线调整 REDO 日志文件的大小!It greatly simplifies the workload of operation and maintenance(Students who have experienced it know it)!
通常一台 MySQL After the instance is deployed,REDO The log file size is generally not kept at the default value,DBA Students will adjust it to an appropriate value according to the amount and frequency of data writing.match with the business REDO The log file size allows for optimal database performance(如何让 REDO Matching the size of the log file to an existing business is beyond the scope of this article).
下面对 MySQL 8.0.30 previous and subsequent versions,对比 REDO The log file change process,Experience the ease of use of the latest version.
8.0.30 之前,如何更改 REDO 日志文件大小?
针对这些版本,修改 REDO The log file size steps are cumbersome.Suppose you need to change its size to 2G ,步骤如下:
1、 REDO Changes to the log file involve two traditional parameters:Its final size is the multiplication of the values of these two parameters.
(1) innodb_log_files_in_group: REDO The number of files on the log disk,默认为2.
(2) innodb_log_file_size: REDO The size of a single file on the journal disk,默认为48M.
(3)The current log size is single48M,两个组,也就是一共96M.
[email protected]:~/sandboxes/msb_5_7_34/data# ls -sihl ib_logfile*
3277012 48M -rw-r----- 1 root root 48M 7月 29 16:18 ib_logfile0
3277013 48M -rw-r----- 1 root root 48M 7月 29 16:18 ib_logfile1
2、“关闭”Quick stop instance parameters:innodb_fast_shutdown = 0 以确保 InnoDB Flush all dirty pages to disk(See the official manual for other values of this parameter):
<mysql:(none):5.7.34-log>set global innodb_fast_shutdown=0;
Query OK, 0 rows affected (0.00 sec)
3、Wait until step 2 is completed,停掉MySQL实例.
4、Delete old log files in the data directory:
[email protected]:~/sandboxes/msb_5_7_34/data# rm -rf ib_logfile*
5、在配置文件 my.cnf 里修改参数 innodb_log_file_size ,Since there are two groups,设置这个参数为 1G 即可.
[mysqld]
innodb_log_file_size=1G
6、启动 MySQL 实例(如果没有报错,Indicates that the change was successful).
7、View the new log file size:
[email protected]:~/sandboxes/msb_5_7_34/data# ls -sihl ib_logfile*
3277898 1.1G -rw-r----- 1 root root 1.0G 7月 29 16:31 ib_logfile0
3277923 1.1G -rw-r----- 1 root root 1.0G 7月 29 16:31 ib_logfile1
8.0.30 之后,如何更改 REDO 日志文件大小?
最新版本 MySQL 8.0.30 发布后,Use new parametersinnodb_redo_log_capacityto replace the previous two parameters(Currently, these two parameters are still valid).Resizing with new parameters is very simple,Just set it to the value you want to adjust.For example, adjust its size to 2G:
调整之前,默认100M:
<mysql:(none):8.0.30>select @@innodb_redo_log_capacity;
+----------------------------+
| @@innodb_redo_log_capacity |
+----------------------------+
| 104857600 |
+----------------------------+
1 row in set (0.00 sec)
Resize it to 2G:
<mysql:(none):8.0.30>set persist innodb_redo_log_capacity=2*1024*1024*1024;
Query OK, 0 rows affected (0.20 sec)
Add the corresponding state variableinnodb_redo_log_capacity_resized,方便在 MySQL side monitor current REDO 日志文件大小:
<mysql:(none):8.0.30>show status like 'innodb_redo_log_capacity_resized';
+----------------------------------+------------+
| Variable_name | Value |
+----------------------------------+------------+
| Innodb_redo_log_capacity_resized | 2147483648 |
+----------------------------------+------------+
1 row in set (0.00 sec)
At the same time, the storage form of disk files is no longer similar ib_logfileN 这样的文件,instead of #ib_redoN This new file format.These new files are stored by default in subdirectories under the data directory’#innodb_redo’ 里.
1、There are a total of such files32个,按照参数 innodb_redo_log_capacity 来平均分配.
[email protected]:/var/lib/mysql/#innodb_redo# ls |wc -l
32
2、有两类文件:A class is not taken _tmp 后缀的,Represents the log file in use;带 _tmp The suffixes represent redundant log files,Wait until the file in use is full,Then use it.如下所示: The log file in use has15个,未使用的有17个.
[email protected]:/var/lib/mysql/#innodb_redo# ls | grep -v '_tmp' |wc -l
15
[email protected]:/var/lib/mysql/#innodb_redo# ls | grep '_tmp' |wc -l
17
同时 performance_schema Curry added tableinnodb_redo_log_files:获取当前使用的 REDO 日志文件 LSN 区间、实际写入大小、Statistics such as whether it is full.例如当前15个 REDO The log file statistics are as follows:一目了然!
<mysql:performance_schema:8.0.30>select * from innodb_redo_log_files;
+---------+---------------------------+------------+------------+---------------+---------+----------------+
| FILE_ID | FILE_NAME | START_LSN | END_LSN | SIZE_IN_BYTES | IS_FULL | CONSUMER_LEVEL |
+---------+---------------------------+------------+------------+---------------+---------+----------------+
| 7 | ./#innodb_redo/#ib_redo7 | 552208896 | 619315712 | 67108864 | 1 | 0 |
...
| 21 | ./#innodb_redo/#ib_redo21 | 1491704320 | 1558811136 | 67108864 | 0 | 0 |
+---------+---------------------------+------------+------------+---------------+---------+----------------+
15 rows in set (0.00 sec)
总结:
MySQL 8.0 The new version brings more and more feature points,to simplify development and operations,Please upgrade as soon as possible.
边栏推荐
猜你喜欢
随机推荐
图的基本概念
阿里云的数据库系统怎么升级更新的www.zgysffm.com怎么加快访问速度?
安装GBase 8c数据库的时候,报错显示“Resource:gbase8c already in use”,这怎么处理呢?
高等代数_证明_对称矩阵属于不同特征值的特征向量正交
金仓数据库KingbaseES客户端编程接口指南-JDBC(8. JDBC 元数据处理)
ConstraintSet of animation of ContrstrainLayout
Distributed Computing Experiment 4 Random Signal Analysis System
分布式计算实验3 基于PRC的书籍信息管理系统
The national vocational skills contest competition of network security emergency response
【NOI模拟赛】纸老虎博弈(博弈论SG函数,长链剖分)
redis分布式锁的实现
【虚幻引擎UE】UE5实现WEB和UE通讯思路
为什么手动启动GBase 8c数据库中GTM节点,起不来。显示“Run cmd failed:scp: /tmp/gtm_gtm1.server: Permission denied”
inject() can only be used inside setup() or functional components.
The sorting algorithm including selection, bubble, and insertion
千万级别的表分页查询非常慢,怎么办?
金仓数据库KingbaseES客户端编程接口指南-JDBC(9. JDBC 读写分离)
一天搞定JDBC02:开启事务
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
使用GBase 8c数据库的时候,遇到这种报错