Puzzled why the error “log file ./ib_logfile0 is of different size” occurs?
A few days ago, while installing the MySQL and moving MySQL databases we got stuck with this error. And we had to increase the log file size in the configuration file to rectify this error.
At Bobcares, we often fix error log file ./ib_logfile0 is of different size, as a part of our Server Management Services.
Today, let’s have a look for the reason of this error. We’ll also see how our Support Engineers fix this error.
Why error log file ./ib_logfile0 is of different size?
We’ve seen many of our customers experiencing this error in many situations which include while trying to install MySQL, change InnoDB parameters, restoring backup MySQL and many more.
The possible common reasons for this error are.
- Either due to corrupted log file or there is no enough disk space.
- Due to an incorrect log file used or changes made in the size of the log file.
Here, is an example error that appeared in the log,
Let’s get in detail on how our Support Engineers fix this error.
How can we get rid of this error?
At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face this error.
Now, let’s see how our Support Engineers fix this error.
Editing etc/my.cnf
Recently one of the customers approached us with the error: “InnoDB: Error: log file ./ib_logfile0 is of different size“.
He received the error while moving MySQL databases. We’ve analyzed the logs and could trace the same.
1. Initially, we logged in to the configuration file, etc/my.cnf and commented out the InnoDB log file size settings in it.
For example:
#innodb_log_file_size = 64M
2. After that, we altered the below variable as,
innodb_fast_shutdown to 0
3. Then we restarted the MySQL service multiple times.
4. After restarting we removed the comment added to InnoDB log file size in the configuration file etc/my.cnf.
5. Finally, we set InnoDB fast shutdown back to default, or we can also remove it from users my.cnf altogether.
Thus, the error successfully fixed. On further checking, there was no such error in the log file.
Altering innodb_log_file_size value
Frequently, some customers were receiving the error “log file ./ib_logfile0 are of different size 0 5242880 bytes”. We resolved the error by altering the innodb_log_file_size value.
In CentOS, the configuration file is :
vi /etc/my.cnf
Whereas, in Debian/Ubuntu:
vi /etc/mysql/my.cnf
Initially, we logged into the configuration file and searched for the directive innodb_log_file_size.
Then we change the innodb_log_file_size value according to customers requirement(the default value is 48M)
After that, we moved the redo log files ib_logfile0 and ib_logfile1 to another directory. Here, we moved the files to /root.
mv /var/lib/mysql/ib_log* /root
Finally, we started the MySQL service, which in turn resolved the error.
service mysql start
Then when we checked for server log file again, we could trace that the old files were removed and the new one were been created.
Removing old log file
In addition, after changing the innodb_log_file_size value in MySQL configuration, some customers get back with the same error.
The issue is due to old log files ib_logfile0 and ib_logfile1 still exist with a different size on the server. The location of log files is in:
/var/lib/mysql
So here, we have to rename or delete the old log files ib_logfile0 and ib_logfile1 and this will fix the error.
[Need more assistance to fix this error? We’ll help you.]
Conclusion
In short, “error log file ./ib_logfile0 is of different size” error occurs due to many reasons which include insufficient space for log files, corrupted log file, increased log file size, and many more. Today, we saw how our Support Engineers fix this error.
0 Comments