How to change the number or size of InnoDB Log Files
This week I was approached by a friend who was not aware of the resource available in 5.6 although it’s being very well commented and has been used by many that received that as a very good new feature. In fact, it was a bit intrusive to change transaction log sizes and the # of files when using old versions of MySQL; this is something that sometimes was able to put someone else at risk.
With the 5.6++ that operation became simple since it will resize and create new files automatically after detect new configurations related to the redo/transaction logs files and one doesn’t need to move files anymore, as was done using prior 5.6 versions. From now on, one will just need to change configuration dynamically/using configuration file and restart mysqld.
On 5.6 it’s just a matter of adjust innodb system variables globally, in case of innodb_fast_shutdown to sync log buffer and log files, edit my.cnf to add or update the values of the system variables that handle transaction log behaviour and then, give mysql a restart. I’ve got some log output of all the action that are involved in doing that.
Below you’ll be able to check that innodb_fast_shutdown was configured to make mysqld sync all the buffer content with disk files and then, shutdown. This is the moment in which the adjusts on system variables innodb related was done. When mysqld was started, it read the new configurations and adjusted sizes and the # of transaction logs files.
[root@localhost ~]# mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.15-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like 'innodb_log_%'; +-----------------------------+----------+ | Variable_name | Value | +-----------------------------+----------+ | innodb_log_file_size | 50331648 | | innodb_log_files_in_group | 2 | | innodb_log_group_home_dir | ./ | +-----------------------------+----------+ 5 rows in set (0.00 sec) mysql> set global innodb_fast_shutdown=1; Query OK, 0 rows affected (0.01 sec) # stopped mysql # edited configuration file [mysqld] innodb_log_file_size=16M innodb_log_files_in_group=4 # mysqld restart [root@localhost ~]# /etc/init.d/mysql restart Shutting down MySQL.. SUCCESS! Starting MySQL... SUCCESS! # logs and auto adjust of files [root@localhost ~]# tail -f /var/lib/mysql/localhost.localdomain.err 2014-02-27 07:10:29 2266 [Note] InnoDB: 128 rollback segment(s) are active. 2014-02-27 07:10:29 2266 [Note] InnoDB: Waiting for purge to start 2014-02-27 07:10:29 2266 [Note] InnoDB: 5.6.15 started; log sequence number 1828674 2014-02-27 07:10:30 2266 [Note] Server hostname (bind-address): '*'; port: 3306 2014-02-27 07:10:30 2266 [Note] IPv6 is available. 2014-02-27 07:10:30 2266 [Note] - '::' resolves to '::'; 2014-02-27 07:10:30 2266 [Note] Server socket created on IP: '::'. 2014-02-27 07:10:30 2266 [Note] Event Scheduler: Loaded 0 events 2014-02-27 07:10:30 2266 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.6.15-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) 2014-02-27 07:11:29 2266 [Note] /usr/sbin/mysqld: Normal shutdown [...] 2014-02-27 07:11:30 2266 [Note] Shutting down plugin 'binlog' 2014-02-27 07:11:30 2266 [Note] /usr/sbin/mysqld: Shutdown complete 140227 07:11:30 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended 140227 07:11:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2014-02-27 07:11:31 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2014-02-27 07:11:31 2488 [Warning] No argument was provided to --log-bin, and --log-bin-index was not used; so replication may break when this MySQL server acts as a master and has his hostname changed!! Please use '--log-bin=localhost-bin' to avoid this problem. 2014-02-27 07:11:31 2488 [Note] Plugin 'FEDERATED' is disabled. 2014-02-27 07:11:32 2488 [Note] InnoDB: Completed initialization of buffer pool 2014-02-27 07:11:32 2488 [Note] InnoDB: Highest supported file format is Barracuda. 2014-02-27 07:11:32 2488 [Warning] InnoDB: Resizing redo log from 2*3072 to 4*1024 pages, LSN=1828684 2014-02-27 07:11:32 2488 [Warning] InnoDB: Starting to delete and rewrite log files. 2014-02-27 07:11:32 2488 [Note] InnoDB: Setting log file ./ib_logfile101 size to 16 MB 2014-02-27 07:11:32 2488 [Note] InnoDB: Setting log file ./ib_logfile1 size to 16 MB 2014-02-27 07:11:33 2488 [Note] InnoDB: Setting log file ./ib_logfile2 size to 16 MB 2014-02-27 07:11:33 2488 [Note] InnoDB: Setting log file ./ib_logfile3 size to 16 MB 2014-02-27 07:11:33 2488 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2014-02-27 07:11:33 2488 [Warning] InnoDB: New log files created, LSN=1828684 2014-02-27 07:11:33 2488 [Note] InnoDB: 128 rollback segment(s) are active. 2014-02-27 07:11:33 2488 [Note] InnoDB: Waiting for purge to start 2014-02-27 07:11:33 2488 [Note] InnoDB: 5.6.15 started; log sequence number 1828684 2014-02-27 07:11:33 2488 [Note] Server hostname (bind-address): '*'; port: 3306 2014-02-27 07:11:33 2488 [Note] IPv6 is available. 2014-02-27 07:11:33 2488 [Note] - '::' resolves to '::'; 2014-02-27 07:11:33 2488 [Note] Server socket created on IP: '::'. 2014-02-27 07:11:33 2488 [Note] Event Scheduler: Loaded 0 events 2014-02-27 07:11:33 2488 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.6.15-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) [...] # checking system variables again mysql> show variables like 'innodb_log%'; +-----------------------------+----------+ | Variable_name | Value | +-----------------------------+----------+ | innodb_log_buffer_size | 8388608 | | innodb_log_compressed_pages | ON | | innodb_log_file_size | 16777216 | | innodb_log_files_in_group | 4 | | innodb_log_group_home_dir | ./ | +------------------------
More information about you can find clicking the link below:
http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html
I hope that help!
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply