mysql innodb_log_buffer_size_MySQL - innodb - How to size innodb_log_buffer_size

Discussion

The MySQL InnoDB log buffer allows transactions to run without having to write the log to disk before the transactions commit. The size of this buffer is configured with the innodb_log_buffer_size variable.

Sensible values range from 1 MB to 8 MB. The default is 1 MB. The minimum value is 256 kB. A setting of 8M is often big enough for most database needs, but some setups with 20 to 30 MB have been seen.

A large log buffer allows large transactions to run without a need to write the log to disk before the transactions commit. Thus, if you have big transactions, making the log buffer larger saves disk I/O.

The innodb_log_buffer_size can be determined with the following command:SHOW GLOBAL VARIABLES

LIKE 'innodb_log_buffer_size';

+------------------------+---------+

| Variable_name | Value |

+------------------------+---------+

| innodb_log_buffer_size | 1048576 |

+------------------------+---------+

Since MySQL 5.0 there is a status called Innodb_log_waits. This status shows the number of times that the log buffer was too small. A wait is required for it to be flushed before continuing.SHOW GLOBAL STATUS

LIKE 'innodb_log_waits';

+------------------+-------+

| Variable_name | Value |

+------------------+-------+

| Innodb_log_waits | 0 |

+------------------+-------+

If this value is 0 or near innodb_log_buffer_size is defined well. If it is high and continuously growing, increase it or reduce the size of your transactions.

A rough estimate of the transaction size can be found on a system

by running the command below before and after the transaction. This gives you a rough feeling about the size.

But keep in mind that on the production system you have concurrency. And your transaction could run the same time several times.SHOW GLOBAL STATUS

LIKE 'innodb_os_log_written';

+-----------------------+---------+

| Variable_name | Value |

+-----------------------+---------+

| Innodb_os_log_written | 4423680 |

+-----------------------+---------+

Please see the external resources links in the margin for more information.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 MySQL 标准的 my.cnf 配置文件示例: ``` # For advice on how to change settings please see # http://dev.mysql.com/doc/mysql/en/server-configuration-defaults.html [client] port = 3306 socket = /var/run/mysqld/mysqld.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql pid-file = /var/run/mysqld/mysqld.pid log-error = /var/log/mysql/error.log # Enable binary logging #log-bin = /var/log/mysql/mysql-bin.log # Point the following paths to different dedicated disks #tmpdir = /tmp/ #log-update = /path-to-dedicated-directory/hostname # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /var/lib/mysql #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /var/lib/mysql #innodb_log_arch_dir = /var/lib/mysql # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M #innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqldump] quick quote-names max_allowed_packet = 16M [mysql] #no-auto-rehash # faster start of mysql but no tab completition [isamchk] key_buffer = 16M # Following values assume you have at least 32M ram [myisamchk] key_buffer = 16M # InnoDB settings [innodb] innodb_file_per_table=1 innodb_buffer_pool_size=2G innodb_log_file_size=256M innodb_flush_log_at_trx_commit=1 innodb_lock_wait_timeout=50 [mysqld_safe] err-log=/var/log/mysql/mysql.err pid-file=/var/run/mysqld/mysqld.pid ``` 注意:该示例仅供参考,具体的配置需要根据实际情况进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值