innodb_online_alter_log_max_size这个参数是mysql 5.6.6引入的,因为在online ddl过程中需要保持delete、update、insert这些数据,所以需要一个日志去保持,这个参数就是限制这个日志的最大大小,当ddl过程中需要的这个日志的大小比这个限制还大的时候就会报错。
具体的错误:
ERROR 1799 (HY000) at line 1: Creating index 'PRIMARY' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again.
解决方法:
该参数为动态参数且全局的,可通过如下命令加大(不一定是我下面设置的大小,这个根据你的情况)
mysql> set global innodb_online_alter_log_max_size=402653184;
5.7中的官方文档关于这个参数的解释:
innodb_online_alter_log_max_size
Command-Line Format | --innodb_online_alter_log_max_size=#
|
||
System Variable | Name | innodb_online_alter_log_max_size
|
|
Variable Scope | Global | ||
Dynamic Variable | Yes | ||
Permitted Values | Type | integer
|
|
Default | 134217728
|
||
Min Value | 65536
|
||
Max Value | 2**64-1
|
Specifies an upper limit on the size of the temporary log files used during online DDL operations for InnoDB
tables. There is one such log file for each index being created or table being altered. This log file stores data inserted, updated, or deleted in the table during the DDL operation. The temporary log file is extended when needed by the value of innodb_sort_buffer_size, up to the maximum specified by innodb_online_alter_log_max_size
. If any temporary log file exceeds the upper size limit, the ALTER TABLE operation fails and all uncommitted concurrent DML operations are rolled back. Thus, a large value for this option allows more DML to happen during an online DDL operation, but also causes a longer period at the end of the DDL operation when the table is locked to apply the data from the log.
关于更多的online ddl可以看看5.6和5.7的官方文档。
/doc/refman/5.6/en/
/doc/refman/5.7/en/