14.5.2 Changing the Number or Size of InnoDB Redo Log Files  改变InnoDB Redo Log Files的数量


改变InnoDB redo log files的数量 在MySQL 5.6.7或者更早版本,执行下面步骤:


1.如果 innodb_fast_shutdown设置为2,set innodb_fast_shutdown to 1:
mysql> show variables like '%innodb_fast_shutdown%';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| innodb_fast_shutdown | 1     |
+----------------------+-------+
1 row in set (0.00 sec)

2.确保 innodb_fast_shutdown 没有设置为2, 停止MySQL 服务器


3.复制old log 文件到一个安全的地方玩意出现问题在关闭你需要它们来恢复表空间

4.删除老的日志文件从log file 目录

5.编辑my.cnf 来改变log file 配置

6.再次启用MySQL 服务器, mysqld 没有InnoDB LOG 文件存在 在启动的时候,创建新的redo logs


在MySQL 5.6.8, innodb_fast_shutdown 不在设置相关值当改变InnoDB log files的数量或者大小。

此外,你不需要删除老的redo log files,尽管你仍旧需要拷贝它们到安全的地方作为百分。


改变InnoDB log files的数量和大小,执行下面的步骤:


1.停止MySQL 服务器确保关闭没有错误

2. 编辑my.cnf 该改变log file配置, 改变log file 大小,配置innodb_log_file_size. 

增加log files 的数量,配置innodb_log_files_in_group



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)

mysql> show variables like '%innodb_log_file_size%';
+----------------------+-----------+
| Variable_name        | Value     |
+----------------------+-----------+
| innodb_log_file_size | 536870912 |
+----------------------+-----------+
1 row in set (0.00 sec)


3.启动服务器


如果InnoDB检测 innodb_log_file_size  不同于redo log file size,

它会写一个log checkpoint,关闭和删除老的log files,创建新的log files按照请求的大小,

打开新的log files