本文介绍了MySQL如何更改innodb-log-file-size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据mysql文档(文档),为了在步骤4中更改innodb-log-file-size,我需要删除二进制日志.我对此有一些担忧和疑问.我当前的innodb-log-file-size值为5MB.因此,我假设我的二进制日志文件均为5MB(最大).当我查看bin-log目录时,我有一堆文件名,例如'mysql-bin.000001','mysql-bin.000002'等.我相信这些是二进制日志文件,但是它们全都相当大于5MB.有2个文件(ib_logfile0,ib_logfile1),它们均为5 MB.所以我的问题是

According to the mysql documentation (Docs), in order to change innodb-log-file-size in step #4 I need to delete the binary logs. I have some concerns and questions about this. My current value for innodb-log-file-size is 5MB. So I would assume my binary log files are 5MB each (max). When I look at the bin-log directory I have a bunch of file names like 'mysql-bin.000001', 'mysql-bin.000002', etc. I believe these are the binary log files, but they are all quite a bit larger than 5MB. There are 2 files (ib_logfile0, ib_logfile1) that are 5 MB. So my question is

  1. 其中哪些文件是我的二进制日志"?
  2. 我需要删除哪些?

预先感谢

推荐答案

InnoDB日志位于ib_logfile0和ib_logfile1中.这些文件的大小为innodb_log_file_size.

The InnoDB log is in ib_logfile0 and ib_logfile1. These are the files sized by innodb_log_file_size.

要调整InnoDB日志的大小,首先需要干净地关闭mysqld .这样可以确保日志中的所有更改都已刷新到您的表空间中.干净关闭很重要,因为如果不执行此步骤,则丢失数据的可能性很大.

To resize the InnoDB logs, you first need to shut down mysqld cleanly. That will make sure that any changes in the log have already been flushed into your tablespaces. The clean shutdown is important, because if you don't do this step, you have a high chance of losing data.

干净地关闭mysqld之后,不需要ib_logfiles.您必须rm它们才能更改其大小.

After you have shut down mysqld cleanly, the ib_logfiles are superfluous. You must rm them to change their size.

重新启动mysqld时,InnoDB注意到文件丢失,并根据my.cnf文件中的innodb_log_file_size变量以新大小创建新文件.因此,请确保在重新启动之前编辑该文件,否则它将仅创建新的5MB文件.

As you restart mysqld, InnoDB notices that the files are missing, and creates new file at the new size according to the innodb_log_file_size variable in your my.cnf file. So make sure you edit that file before you restart, or else it'll just create new 5MB files.

MySQL 5.6使此过程更加简单.您不需要rm日志文件,但是您确实需要重新启动mysqld才能使新的日志文件大小生效.在5.6中的工作方式是,如果这些文件的大小与config变量不同,MySQL会自动执行另一次干净的重启(以确保文件不包含未更改的任何更改),然后InnoDB调整文件的大小在最终启动时.

MySQL 5.6 makes this process a little bit simpler. You don't need to rm the log files, but you do need to restart mysqld to make a new log file size take effect. The way it works in 5.6 is that if the size of these files is different from the config variable, MySQL automatically does another clean restart (to make sure the files don't contain any changes that are unflushed), and then InnoDB resizes the files upon the final startup.

其他文件(mysql-bin.000001等)是二进制日志.这些可能会增长到max_binlog_size(默认为1GB),但是二进制日志的大小会有所不同,因为每当您重新启动mysqld或执行FLUSH LOGS时都会创建新的日志.无论如何,它们与InnoDB日志无关.

The other files (mysql-bin.000001, etc.) are binary logs. These may grow up to max_binlog_size (which is 1GB by default), but the binary logs vary in size because new logs are created whenever you restart mysqld or execute FLUSH LOGS. Anyway, they have nothing to do with the InnoDB logs.

PS:您可能喜欢这篇文章:如何计算良好的InnoDB日志文件大小.

PS: You might like this article: How to calculate a good InnoDB log file size.

这篇关于MySQL如何更改innodb-log-file-size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 08:23