在MySQL8.0.30之前
mysql> pager grep sequence PAGER set to 'grep sequence' mysql> show engine innodb statusG select sleep(60); show engine innodb statusG Log sequence number 84 3836410803 1 row in set (0.06 sec) 1 row in set (1 min 0.00 sec) Log sequence number 84 3838334638 1 row in set (0.05 sec)
根据上面的结果进行估算:
mysql> select (3838334638 - 3836410803) / 1024 / 1024 as MB_per_min; +------------+ | MB_per_min | +------------+ | 1.83471203 | +------------+
大概是1.8MB/min,根据该结果,最好是将redo日志容量设置成1.8*60(1小时),即110MB,取128MB。因为有两个redo日志文件,每个64MB即可:
innodb_log_file_size=64M
从MySQL5开始,也可以使用全局状态参数:
SHOW GLOBAL STATUS Innodb_os_log_written;
从MySQL8.0.30开始
mysql> SHOW GLOBAL STATUS LIKE 'Innodb_redo_log_current_lsn'; SELECT SLEEP(60); SHOW GLOBAL STATUS LIKE 'Innodb_redo_log_current_lsn';
根据上面的执行结果进行估算:
mysql > SELECT ABS(20641693317 - 20903377487) / 1024 / 1024 AS MB_per_min; +--------------+ | MB_per_min | +--------------+ | 249.56147194 | +--------------+ 1 row in set (0.00 sec)
大概是250MB/min,根据该结果,最好是将redo日志容量设置成250*60(1小时),即15GB。
mysql> SET GLOBAL innodb_redo_log_capacity = 15*1024*1024*1024;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/280268.html