MySQL unble to lock ./ibdata1 error

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 案例一:   环境说明:mysql 5.6 用户连接不上mysql ,查看error 日志:unble to lock ./ibdata1 error,等待20分钟左右,在启动mysql恢复正常。

案例一:

 

环境说明:mysql 5.6

用户连接不上mysql ,查看error 日志:unble to lock ./ibdata1 error,等待20分钟左右,在启动mysql恢复正常。./ibdate1 文件 40G

 

解决方法:

1、查看slow log

2show procedure status  

#查看存储过程,该实例有很多存储过程

3show create procedure 存储过程名称 \G

 

结论:复杂的存储过程(数据库里的数据也不对),导致sql语句执行的时间很长,7万多秒。这时mysql hug住了 占用了./ibdate1 文件

 

案例二:

有一个线上库的ibdate1文件从1G,一直不断增长到100G,到底怎么回事呢?

 

ibdate1 文件暴增原因:

  1. 大量事务,产生大量来不及purgeundo log
  2. 有旧事务长时间未提交,产生大量旧undo log
  3. file i/o 性能差,purge进度慢
  4. 32bit系统下有bug
  5. 使用共享表空间方式,所有表数据放在一起

 

大量事务,产生大量来不及purgeundo log

ab37d7436654b858f2f0fb91b0496844f27c919f

最新事务ID21520177836

最新purged的事务ID21516167648

二者相差:4010188

等待purgeundo事务列表:41341108

 

有旧事务长时间未提交,产生大量旧undo log

8699b313c012b6511e0dbce8d45cb70fd495bbed

 

解决办法:

调度ibdate1的初始大小

innodb_date_file_path = ibdata1:1G:autoextend

升级到5.6及以上(64-bit),采用独立undo表空间

innodb_undo_directory = path

innodb_undo_logs = 128

innodb_undo_tablespaces = 126

 

启用独立表空间,ibdata1 只存放系统数据

  innodb_file_per_table =  1

增加purge线程数

  innodb_purge_threads = 4

 

提高file i/o能力

 raid 10 & wb & BBU

xfs

deadline/noop

ssd/pice ssd

 

事务及时提交,不要积压

  及时commit/rollback

注意事务自动提交设置

  默认打开autocommit = 1

检查开发框架,确认autocommit =0 的地方,事务结束后都有提交或回滚

 

mysql参数优化:

innodb_buffer_pool_size:约物理内存的50%~~70%

innodb_date_file_path:初始大小至少1G

设置独立数据表空间以及独立undo表空间(5.6+)

innodb_log_file_size ,5.5及以上1G以上,5.5以下建议不超过512M

innodb_flush_log_at_trx_commit,0 => 最快数据最不安全,1 =>最慢最安全,2=>折中

innodb_max_dirty_pages_pct: 25%~~50% 为宜

innodb_io_capacity :普通机械盘=>1000左右,ssd=>10000左右,PCle SSD=>20000以上

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4天前
|
缓存 关系型数据库 MySQL
error: Failed dependencies: mariadb-connector-c-config is obsoleted by mysql-community-server-8.0.36-1.el7.x86_64 问题解决
error: Failed dependencies: mariadb-connector-c-config is obsoleted by mysql-community-server-8.0.36-1.el7.x86_64 问题解决
30 19
|
3天前
|
关系型数据库 MySQL Linux
error: Failed dependencies: libncurses.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 libtinfo.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 如何解决?
error: Failed dependencies: libncurses.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 libtinfo.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 如何解决?
11 3
|
7天前
|
关系型数据库 MySQL 测试技术
MySQL 报错 ERROR 1709: Index column size too large
MySQL 报错 ERROR 1709: Index column size too large
34 4
|
13天前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
20 2
|
24天前
|
网络协议 关系型数据库 MySQL
启动mysql时的异常为:[ERROR] Can‘t start server: Bind on TCP/IP port. Got error: 98: Address already in used
启动mysql时的异常为:[ERROR] Can‘t start server: Bind on TCP/IP port. Got error: 98: Address already in used
|
23天前
|
SQL 关系型数据库 MySQL
You have an error in your SQL syntax;check the manual that corresponds to you Mysql server version
You have an error in your SQL syntax;check the manual that corresponds to you Mysql server version
|
24天前
|
关系型数据库 MySQL 数据库
mysql 中登录报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)ERROR
mysql 中登录报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)ERROR
|
29天前
|
SQL 存储 关系型数据库
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
|
1月前
|
SQL 关系型数据库 MySQL
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
|
1月前
|
存储 SQL 关系型数据库
【MySQL技术内幕】6.1-锁、lock和latch
【MySQL技术内幕】6.1-锁、lock和latch
29 0