mysql innodb_log_buffer_size,在mysql中设置正确的innodb_log_file_size-程序员宅基地

技术标签: mysql innodb_log_buffer_size  

We ran an alter table today today that took down the DB. We failed over to the slave, and in the post-mortem, we discovered this in the mysql error.log

InnoDB: ERROR: the age of the last checkpoint is 90608129,

InnoDB: which exceeds the log group capacity 90593280.

InnoDB: If you are using big BLOB or TEXT rows, you must set the

InnoDB: combined size of log files at least 10 times bigger than the

InnoDB: largest such row.

This error rings true because we were working on a very large table that contains BLOB data types.

The best answer we found online said

To solve it, you need to stop MySQL cleanly (very important), delete the existing InnoDB log files (probably lb_logfile* in your MySQL data directory, unless you've moved them), then adjust the innodb_log_file_size to suit your needs, and then start MySQL again. This article from the MySQL performance blog might be instructive.

and in the comments

Yes, the database server will effectively hang for any updates to InnoDB tables when the log fills up. It can cripple a site.

which is I guess what happened, based on our current (default) innodb_log_file_size of 48mb?

SHOW GLOBAL VARIABLES LIKE '%innodb_log%';

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

| Variable_name | Value |

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

| innodb_log_buffer_size | 8388608 |

| innodb_log_compressed_pages | ON |

| innodb_log_file_size | 50331648 |

| innodb_log_files_in_group | 2 |

| innodb_log_group_home_dir | ./ |

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

So, this leads me to two pointed questions and one open-ended one:

How do we determine the largest row so we can set our innodb_log_file_size to be bigger than that?

What is the consequence of the action in step 1? I'd read about long recovery times with bigger logs.

Is there anything else I should worry about regarding migrations, considering that we have a large table (650k rows, 6169.8GB) with unrestrained, variable length BLOB fields.

We're running mysql 5.6 and here's our my.cnf.

[mysqld]

#defaults

basedir = /opt/mysql/server-5.6

datadir = /var/lib/mysql

port = 3306

socket = /var/run/mysqld/mysqld.sock

tmpdir = /tmp

bind-address = 0.0.0.0

#logs

log_error = /var/log/mysql/error.log

expire_logs_days = 4

slow_query_log = on

long_query_time = 1

innodb_buffer_pool_size = 11G

#http://stackoverflow.com/a/10866836/182484

collation-server = utf8_bin

init-connect ='SET NAMES utf8'

init_connect ='SET collation_connection = utf8_bin'

character-set-server = utf8

max_allowed_packet = 64M

skip-character-set-client-handshake

#cache

query_cache_size = 268435456

query_cache_type = 1

query_cache_limit = 1048576

```

As a follow-up to the suggestions listed below, I began investigation into the file size of the table in question. I ran a script that wrote the combined byte size of the three BLOB fields to a table called pen_sizes. Here's the result of getting the largest byte size:

select pen_size as bytes,·

pen_size / 1024 / 1024 as mb,·

pen_id from pen_sizes

group by pen_id

order by bytes desc

limit 40

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

| bytes | mb | pen_id |

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

| 3542620 | 3.37850571 | 84816 |

| 3379107 | 3.22256756 | 74796 |

| 3019237 | 2.87936878 | 569726 |

| 3019237 | 2.87936878 | 576506 |

| 3019237 | 2.87936878 | 576507 |

| 2703177 | 2.57795048 | 346965 |

| 2703177 | 2.57795048 | 346964 |

| 2703177 | 2.57795048 | 93706 |

| 2064807 | 1.96915340 | 154627 |

| 2048592 | 1.95368958 | 237514 |

| 2000695 | 1.90801144 | 46798 |

| 1843034 | 1.75765419 | 231988 |

| 1843024 | 1.75764465 | 230423 |

| 1820514 | 1.73617744 | 76745 |

| 1795494 | 1.71231651 | 650208 |

| 1785353 | 1.70264530 | 74912 |

| 1754059 | 1.67280102 | 444932 |

| 1752609 | 1.67141819 | 76607 |

| 1711492 | 1.63220596 | 224574 |

| 1632405 | 1.55678272 | 76188 |

| 1500157 | 1.43066120 | 77256 |

| 1494572 | 1.42533493 | 137184 |

| 1478692 | 1.41019058 | 238547 |

| 1456973 | 1.38947773 | 181379 |

| 1433240 | 1.36684418 | 77631 |

| 1421452 | 1.35560226 | 102930 |

| 1383872 | 1.31976318 | 77627 |

| 1359317 | 1.29634571 | 454109 |

| 1355701 | 1.29289722 | 631811 |

| 1343621 | 1.28137684 | 75256 |

| 1343621 | 1.28137684 | 75257 |

| 1334071 | 1.27226925 | 77626 |

| 1327063 | 1.26558590 | 129731 |

| 1320627 | 1.25944805 | 636914 |

| 1231918 | 1.17484856 | 117269 |

| 1223975 | 1.16727352 | 75103 |

| 1220233 | 1.16370487 | 326462 |

| 1220233 | 1.16370487 | 326463 |

| 1203432 | 1.14768219 | 183967 |

| 1200373 | 1.14476490 | 420360 |

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

This makes me believe that the average row size is closer to 1mb than the 10 suggested. Maybe the table size I listed earlier includes the indexes, too?

I ran

SELECT table_name AS "Tables",

round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"

FROM information_schema.TABLES

WHERE table_schema = 'codepen'

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

| Tables | Size in MB |

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

...snip

| pens | 6287.89 |

...snip

解决方案

0. Preliminary information

Your settings:

innodb_log_file_size = 50331648

innodb_log_files_in_group = 2

Therefore your "log group capacity" = 2 x 50331648 = 96 MB

1. How to determine the largest row

There is no direct method. But one can easily calculate the size of one given row based on these tables (compression should not matter to us here, if, as I assume, rows are not compressed in the log files).

2. Impact of innodb_log_file_size

The larger the value, the less checkpoint flush activity is needed in the buffer pool, saving disk I/O. Larger log files also make crash recovery slower, although improvements to recovery performance in MySQL 5.5 and higher make the log file size less of a consideration.

3. Anything else to worry about

6169.8 GB / 650k rows = about 10 MB per row on average

This is a serious problem per se if you intend to use your database in a transactional, multi-user situation. Consider storing your BLOB's as files outside of the database. Or, at least, store them in a separate MyISAM (non-transactional) table.

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42380646/article/details/118812658

智能推荐

Springboot/java/node/python/php基于springboot+vue手机售后管理系统【2024年毕设】-程序员宅基地

文章浏览阅读779次,点赞19次,收藏24次。springboot微信小程序的小疾病问诊服务系统的设计与实现。springboot基于spring的物业管理系统的设计与实现。springboot基于Java的高校学生请假系统。ssm基于Android的购物商场APP设计与实现。springboot基于微信小程序的智慧校园系统。ssm基于Android的英语词典的设计与开发。ssm基于SSM+Vue的学生实践管理平台开发。ssm基于android的企业员工考勤系统。ssm基于web的暗香小店系统的设计与实现。ssm基于Web的高等学校公费医疗管理系统。

css中hover属性的使用技巧_css hover的用法-程序员宅基地

文章浏览阅读2.3w次,点赞15次,收藏63次。hover属性用不同的书写方式,来改变不同关系的元素样式。元素:hover 表示聚焦后改变自己元素:hover 元素 表示聚焦后改变其子元素元素:hover + 元素 表示聚焦后改变其指定的“亲兄弟”(条件是该兄弟元素与其相邻)元素元素:hover ~ 元素 表示聚焦后改变其指定的兄弟元素,两个元素相不相邻都行。示例:.first:hover {color: white;}/* 聚焦我改变自己 */.three:hover .three-son {font-size: 20px._css hover的用法

coursera-斯坦福-机器学习-吴恩达-第8周笔记-无监督学习_pca反向压缩-程序员宅基地

文章浏览阅读6k次,点赞3次,收藏15次。coursera-斯坦福-机器学习-吴恩达-第8周笔记-无监督学习coursera-斯坦福-机器学习-吴恩达-第8周笔记-无监督学习1聚类算法clutering1聚类算法简介2K-means21kmeans的目标函数22随机初始化23选择类别数3考试quiz维数约减 dimensionality reduction1数据压缩2数据可视化3维度约简-主成分分析法PCA1 PCA_pca反向压缩

vim插件安装及常用技巧_bxbx.vim-程序员宅基地

文章浏览阅读5.2k次。一、插件安装Vundle是vim的一个插件管理器, 同时它本身也是vim的一个插件。插件管理器用于方便、快速的安装、删除、Vim更新插件。mkdir -p ~/.vim/bundlegit clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim管理器安装完成后,vim ~/.vimrc命令创建.vimrc文件syntax on" tab宽度和缩进同样设置为4set tabstop=4set softta_bxbx.vim

java.lang.ClassNotFoundException:如何解决-程序员宅基地

文章浏览阅读7.2w次,点赞10次,收藏41次。本文适用于当前面临java.lang.ClassNotFoundException挑战的Java初学者。 它将为您提供此常见Java异常的概述,这是一个示例Java程序,可支持您的学习过程和解决策略。 如果您对与更高级的类加载器相关的问题感兴趣,我建议您复习有关java.lang.NoClassDefFoundError的文章系列,因为这些Java异常密切相关。 java.lang..._java.lang.classnotfoundexception:

串口通信数据帧_一帧数据-程序员宅基地

文章浏览阅读1.2k次,点赞9次,收藏17次。不同的设备间建立连接往往需要通信,而串口通信是十分常用的一种。UART串口通信需要两根线来实现,一根用于串口发送,另外一更用于串口接收。UART串口发送或者接收过程中一帧数据包括1位起始位、8位数据位、1位停止位,为了提高数据的可靠性可以在停止位前加上1位奇偶校验位。串口通信虽然十分简单,但是在不同设备间发送的数据往往不止1个字节,往往需要多个字节组成的数据包。当我们按照数据包发送时我们需要考虑到以及,因此我们可以采用定义数据帧的方式解决上述两个问题。_一帧数据

随便推点

Android四大组件之Activity--管理方式_android activityrecord中的activitytype-程序员宅基地

文章浏览阅读1.7k次。1. 概览Activity的管理有静态和动态两层涵义: 静态是指Activity的代码组织结构,即Application中声明的Activity的集合,这些Activity被组织在一个APK中,有特定的包名。 在编写应用程序时,Activity对应到用户界面,它定义了用户界面的布局、交互行为、启动方式等,最重要的,是Activity的生命周期函数。 在应用进程看来,只需要按照Android定义的规范,实现生命周期函数的具体逻辑即可,所有的用户界面都遵循同一个规范。 编写完一个应用程序的所有用户界面_android activityrecord中的activitytype

[LINUX]sed查找不包含某个字符串的行,并进行替换_sed不包含字符串-程序员宅基地

文章浏览阅读5.5k次,点赞3次,收藏7次。sed 查找不包含某个特性 sed -i "/src/!s/xxx/bbb/g" xxx将不包含src的行中的xxx替换为bbb_sed不包含字符串

问题解决:shared_ptr Assertion px != 0 failed 及debug经验分享_typename boost::detail::sp_dereference<t>::type bo-程序员宅基地

文章浏览阅读6.8k次,点赞11次,收藏18次。问题解决:shared_ptr Assertion px != 0 failed及debug经验分享问题详细描述:/usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference::type boost::shared_ptr::operator*() const [with T = pcl::PointCloudpcl::pointxyz; typename boost::detail::sp_typename boost::detail::sp_dereference::type boost::shared_ptr::operat

看不见的“网” ,一文读懂阿里云基础设施网络_阿里云网络基线理解-程序员宅基地

文章浏览阅读553次。编者按:在这个万物智联的时代,无论是在线网络购物,还是网络强国、数字中国建设,都离不开一张“看不见的网”——基础设施网络。2009年,首届双11每秒交易订单创建峰值400;2021年,双11每秒交易订单创建峰值58.3万,12年交易数字量猛增的背后,是阿里云在庞大分布式系统上计算和IO能力的飞跃,更离不开阿里云基础设施底层网络技术的支撑。图|阿里云全球基础设施网络系统作为阿里云基础设施的重要组成部分,阿里云基础设施网络团队负责整个阿里云全球基础设施网络,包括大规模高性能数据中心网络,全球数据中心互联_阿里云网络基线理解

TCP/UDP常见端口参考_怎么查看端口映射的是tcp还是udp-程序员宅基地

文章浏览阅读1.7k次。端口列表一览端口号码 / 层 名称 注释 1 tcpmux TCP 端口服务多路复用 5 rje 远程作业入口 7 echo Echo 服务 9 discard 用于连接测试的空服务 11 systat 用于列举连接了的端口的系统状态 13 daytime 给请求主机发送日期和时间 17 qotd 给连接了的主机发送每日格言 18 msp 消息发送协议 19 _怎么查看端口映射的是tcp还是udp

推荐文章

热门文章

相关标签