8.5.4 Optimizing InnoDB Redo Logging 优化InnoDB Redo Logging

8.5.4 Optimizing InnoDB Redo Logging 优化InnoDB Redo Logging

考虑优化重做日志:

使你的redo log 文件变大, 甚至和Buffer pool一样大。

当InnoDB 把redo log文件写满, 它必须把修改的内容从Buffer pool 写到disk 在一个检查点。

小的redo log 文件导致很多不必要的磁盘读写,尽管历史上大的redo log文件导致漫长的恢复时间,

恢复显示是更快了 你可以放心的使用大的redo log files.

redo log files 的大小和数量使用innodb_log_file_size and innodb_log_files_in_group 配置选项。

see Section 14.4.2, “Changing the Number or Size of InnoDB Redo Log Files”.

mysql> show variables like ‘%innodb_log_file_size%’;
+———————-+———-+
| Variable_name | Value |
+———————-+———-+
| innodb_log_file_size | 50331648 |
+———————-+———-+
1 row in set (0.00 sec)

mysql> show variables like ‘%innodb_log_files_in_group%’;
+—————————+——-+
| Variable_name | Value |
+—————————+——-+
| innodb_log_files_in_group | 2 |
+—————————+——-+
1 row in set (0.00 sec)

考虑增加 log_buffer大小,一个大的log buffer 可以让大的事务运行不需要在事务提交前

写日志到磁盘。因此,如果你有事务 update, insert, or delete many rows,

让log buffer 足够大来节省磁盘I/O. log buffer 通过innodb_log_buffer_size configuration option.

14.4.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的 Number和Size

To change the number or the size of your InnoDB redo log files, perform the following steps:

改变InnoDB redo log files的size和number,执行下面的步骤:

Stop the MySQL server and make sure that it shuts down without errors.

停止MySQL server ,保证关闭没有报错

Edit my.cnf to change the log file configuration. To change the log file size, configure innodb_log_file_size. To increase the number of log files, configure innodb_log_files_in_group.

编辑my.cnf ,改变log file 的配置,改变log file的大小 configure innodb_log_file_size.

增加 log files的数量, configure innodb_log_files_in_group.

Start the MySQL server again.

重启MySQL server

If InnoDB detects that the innodb_log_file_size differs from the redo log file size, it will write a log checkpoint, close and remove the old log files, create new log files at the requested size,

and open the new log files.

如果 InnoDB 检查到 innodb_log_file_size不同于redo log file size, 它会写一个log 检查点,关闭和删除老的log files,

创建一个新的log files 按请求的大小,打开新的log fils

zjzc01:/data01/mysql# ls -ltrh
total 197M
drwx—— 2 mysql mysql 4.0K Aug 19 18:54 performance_schema
drwx—— 2 mysql mysql 4.0K Aug 19 18:54 mysql
-rw-rw—- 1 mysql mysql 56 Aug 19 18:58 auto.cnf
drwx—— 2 mysql mysql 4.0K Aug 20 00:56 quartz
drwx—— 2 mysql mysql 12K Oct 26 13:26 zjzc
-rw-rw—- 1 mysql mysql 25M Oct 27 15:24 zjzc01-slow.log
srwxrwxrwx 1 mysql mysql 0 Oct 27 15:24 mysql.sock
-rw-rw—- 1 mysql mysql 5 Oct 27 15:24 zjzc01.pid
-rw-rw—- 1 mysql mysql 48M Oct 28 10:49 ib_logfile0
-rw-rw—- 1 mysql mysql 48M Oct 28 10:49 ib_logfile1
-rw-rw—- 1 mysql mysql 76M Oct 28 10:49 ibdata1

zjzc01:/data01/mysql# ls -ltrh
total 1.1G
drwx—— 2 mysql mysql 4.0K Aug 19 18:54 performance_schema
drwx—— 2 mysql mysql 4.0K Aug 19 18:54 mysql
-rw-rw—- 1 mysql mysql 56 Aug 19 18:58 auto.cnf
drwx—— 2 mysql mysql 4.0K Aug 20 00:56 quartz
drwx—— 2 mysql mysql 12K Oct 26 13:26 zjzc
-rw-rw—- 1 mysql mysql 512M Oct 28 10:57 ib_logfile1
-rw-rw—- 1 mysql mysql 25M Oct 28 10:57 zjzc01-slow.log
-rw-rw—- 1 mysql mysql 5 Oct 28 10:57 zjzc01.pid
srwxrwxrwx 1 mysql mysql 0 Oct 28 10:57 mysql.sock
-rw-rw—- 1 mysql mysql 76M Oct 28 10:57 ibdata1
-rw-rw—- 1 mysql mysql 512M Oct 28 10:57 ib_logfile0
zjzc01:/data01/mysql#

原文地址:https://www.cnblogs.com/hzcya1995/p/13351262.html