签到成功

知道了

CNDBA社区CNDBA社区

Mysql innodb_log_file_size参数

2021-12-12 15:16 2434 0 原创 mysql
作者: hbhe0316

MySQL的InnoDB 存储引擎使用一个指定大小的Redo log空间(一个环形的数据结构),Redo log的空间通过innodb_log_file_size和innodb_log_files_in_group(默认为2)参数来调节。将这俩参数相乘即可得到总的可用Redo log 空间。尽管技术上并不关心你是通过innodb_log_file_size还是innodb_log_files_in_group来调整Redo log空间,不过多数情况下还是通过innodb_log_file_size 来调节。

  为InnoDB引擎设置合适的Redo log空间对于写敏感的工作负载来说是非常重要的,然而,这项工作是要做出权衡的。配置的Redo空间越大,InnoDB就能更好的优化写操作;然而,增大Redo空间也意味着更长的恢复时间当出现崩溃或掉电等意外时。

像许多数据库管理系统一样,MySQL使用日志来实现数据的持久性(当使用默认的InnoDB存储引擎时)。这确保了在提交事务时,即使发生崩溃或断电,数据也不会丢失。http://www.cndba.cn/hbhe0316/article/22738

http://www.cndba.cn/hbhe0316/article/22738

MySQL的InnoDB存储引擎使用固定大小(循环)的Redo日志空间。大小是由innodb_log_file_size和innodb_log_files_in_group(默认为2)控制的,你可以将这两个值相乘,得到可用的Redo日志空间。从技术上讲,不管你是改变innodb_log_file_size还是innodb_log_files_in_group变量来控制Redo空间大小,大多数人都只使用innodb_log_file_size,而不去管innodb_log_files_in_group。http://www.cndba.cn/hbhe0316/article/22738

配置InnoDB的Redo空间大小是对写密集型工作负载最重要的配置选项之一。然而,这是有代价的。配置的Redo空间越多,InnoDB就能更好地优化写IO。然而,增加Redo空间也意味着当系统断电或由于其他原因崩溃时,恢复时间更长。

http://www.cndba.cn/hbhe0316/article/22738
http://www.cndba.cn/hbhe0316/article/22738

查看日志大小

http://www.cndba.cn/hbhe0316/article/22738
http://www.cndba.cn/hbhe0316/article/22738

mysql> show variables like 'innodb_log_file_size';
+----------------------+----------+
| Variable_name        | Value    |
+----------------------+----------+
| innodb_log_file_size | 50331648 |
+----------------------+----------+
1 row in set (0.01 sec)

修改innodb_log_file_sizehttp://www.cndba.cn/hbhe0316/article/22738http://www.cndba.cn/hbhe0316/article/22738

http://www.cndba.cn/hbhe0316/article/22738

[root@mysql57 ~]# cat /etc/my.cnf | grep -i innodb_log_file_size
innodb_log_file_size = 1500M

[root@mysql57 ~]# service mysqld restart
Shutting down MySQL.... SUCCESS! 
Starting MySQL................................ SUCCESS! 

[root@mysql57 data]# mysql -uroot -pwwwwww -S /mysql/mysql.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 2
Server version: 5.7.36-log MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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_file_size';
+----------------------+------------+
| Variable_name        | Value      |
+----------------------+------------+
| innodb_log_file_size | 1572864000 |
+----------------------+------------+
1 row in set (0.01 sec)

版权声明:本文为博主原创文章,未经博主允许不得转载。

MYSQL

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:2646948次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ