环境:

mysql5.6.2  主从同步(备注:需操作主库和从库)

一、InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_pool_size的值来解决这个问题,并且重启mysql服务。

遇到的问题:

mysql报错如下:

The total number of locks exceeds the lock table size错误

二、解决办法

2.1、登录主库查看buffer_pool_size大小

[root@a2 ~]# mysql -uroot -p  (备注:主库)
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 5.6.24 Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 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数据库buffer_pool大小为:8MB
mysql> show variables like "%_buffer%";
+-------------------------------------+----------------+
| Variable_name | Value |
+-------------------------------------+----------------+
| innodb_buffer_pool_size | 8388608 |
22 rows in set (0.00 sec) 需要调优为:2G-3G

2.2、调优方法

#关闭数据库(备注:主从同步状态正常的情况下关闭主库)

[root@a1 mysql]# /etc/init.d/mysqld stop
Shutting down MySQL........... SUCCESS!

#修改配置文件 (备注:在主库上面修改配置文件)

[root@a1 mysql]# vi /roobo/server/mysql/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
#[client]
#port = 3306
#socket = /tmp/mysql.sock
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/lib/mysql/mysqld.pid
default-character-set = utf8 [mysqld]
port = 3306
socket = /tmp/mysql.sock
#innodb_buffer_pool_size=8MB #原文件
innodb_buffer_pool_size=2GB #修改为2G或 3G,根据表大小,进行调优。
basedir = /roobo/server/mysql
datadir = /roobo/mysqldata/database
pid-file = /var/lib/mysql/mysql.pid
character_set_server = utf8
log-bin = /roobo/server/mysql/data/mysql-bin
server_id = 1

#启动数据库 (备注:在主库上面操作)

[root@a1 mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!

#再登录数据库检查是否修改成功 (备注:在主库上面操作)

[root@a1 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.24-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 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.

#修改成2G
mysql> show variables like "%_buffer%";
+-------------------------------------+----------------+
| Variable_name | Value |
+-------------------------------------+----------------+
| bulk_insert_buffer_size | 8388608 |
| innodb_buffer_pool_dump_at_shutdown | OFF |
| innodb_buffer_pool_dump_now | OFF |
| innodb_buffer_pool_filename | ib_buffer_pool |
| innodb_buffer_pool_instances | 8 |
| innodb_buffer_pool_load_abort | OFF |
| innodb_buffer_pool_load_at_startup | OFF |
| innodb_buffer_pool_load_now | OFF |
| innodb_buffer_pool_size | 2147483648 |
| innodb_change_buffer_max_size | 25 |
| innodb_change_buffering | all |
| innodb_log_buffer_size | 8388608 |
| innodb_sort_buffer_size | 1048576 |
| join_buffer_size | 262144 |
| key_buffer_size | 8388608 |
| myisam_sort_buffer_size | 8388608 |
| net_buffer_length | 16384 |
| preload_buffer_size | 32768 |
| read_buffer_size | 131072 |
| read_rnd_buffer_size | 262144 |
| sort_buffer_size | 262144 |
| sql_buffer_result | OFF |
+-------------------------------------+----------------+
22 rows in set (0.00 sec) mysql> exit

 #备注:从库也要调优相同参数,否则会导致数据库主从不同步

#关闭数据库(备注:主从同步状态正常的情况下关闭从库)

[root@a2 mysql]# /etc/init.d/mysqld stop
Shutting down MySQL........... SUCCESS!

#修改配置文件 (备注:在从库上面修改配置文件)

[root@a2 mysql]# vi  my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
#[client]
#port = 3306
#socket = /tmp/mysql.sock
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/lib/mysql/mysqld.pid
default-character-set = utf8

[mysqld]
port = 3306
socket = /tmp/mysql.sock
#innodb_buffer_pool_size=8MB
innodb_buffer_pool_size=2GB  #把8M修改成2G
basedir = /roobo/server/mysql
datadir = /roobo/mysqldata/database
pid-file = /var/lib/mysql/mysql.pid
character_set_server = utf8
server-id = 2
read_only = 1

#启动数据库 (备注:在从主库上面操作)

[root@a2 mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!

#再登录数据库检查是否修改成功 (备注:在从库上面操作)

[root@a2 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.24-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 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.

#修改成2G
mysql> show variables like "%_buffer%";
+-------------------------------------+----------------+
| Variable_name | Value |
+-------------------------------------+----------------+
| bulk_insert_buffer_size | 8388608 |
| innodb_buffer_pool_dump_at_shutdown | OFF |
| innodb_buffer_pool_dump_now | OFF |
| innodb_buffer_pool_filename | ib_buffer_pool |
| innodb_buffer_pool_instances | 8 |
| innodb_buffer_pool_load_abort | OFF |
| innodb_buffer_pool_load_at_startup | OFF |
| innodb_buffer_pool_load_now | OFF |
| innodb_buffer_pool_size | 2147483648 |
| innodb_change_buffer_max_size | 25 |
| innodb_change_buffering | all |
| innodb_log_buffer_size | 8388608 |
| innodb_sort_buffer_size | 1048576 |
| join_buffer_size | 262144 |
| key_buffer_size | 8388608 |
| myisam_sort_buffer_size | 8388608 |
| net_buffer_length | 16384 |
| preload_buffer_size | 32768 |
| read_buffer_size | 131072 |
| read_rnd_buffer_size | 262144 |
| sort_buffer_size | 262144 |
| sql_buffer_result | OFF |
+-------------------------------------+----------------+
22 rows in set (0.00 sec) mysql> exit

#再登录从库,查看主从同步情况 (备注:在从库上面操作)

[root@a2 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 55
Server version: 5.6.24 Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 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 slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.7.19.129
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000015
Read_Master_Log_Pos: 67365
Relay_Log_File: mysql-relay-bin.000036
Relay_Log_Pos: 67528
Relay_Master_Log_File: mysql-bin.000015
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 67365
Relay_Log_Space: 67864
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 4afce67d-d694-11e8-94c2-00163e0a2eec
Master_Info_File: /roobo/mysqldata/database/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec) ERROR:
No query specified mysql> exit
Bye

  

mysql 数据库缓存调优之解决The total number of locks exceeds the lock table size错误的更多相关文章

  1. Mysql_解决The total number of locks exceeds the lock table size错误

    在操作mysql数据库表时出现以下错误. 网上google搜索相关问题,发现一位外国牛人这么解释: If you're running an operation on a large number o ...

  2. 解决The total number of locks exceeds the lock table size错误

    参考:https://blog.csdn.net/weixin_40683253/article/details/80762583 mysql在进行大批量的数据操作时,会报“The total num ...

  3. 【转】Mysql解决The total number of locks exceeds the lock table size错误

    InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_pool_size的值来解决这个问题,并且重启mysql服务. windows ...

  4. MySQL插入大批量数据时报错“The total number of locks exceeds the lock table size”的解决办法

    事情的原因是:我执行了一个load into语句的SQL将一个很大的文件导入到我的MySQL数据库中,执行了一段时间后报错"The total number of locks exceeds ...

  5. MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题

    MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题 查看MySQL版本:mysql>show ...

  6. 【MySQL笔记】mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法

    step1:查看 1.1 Mysql命令行里输入"show engines:"查看innoddb数据引擎状态, 1.2 show variables "%_buffer% ...

  7. mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法

    1. 问题背景         InnoDB是新版MySQL(v5.5及以后)默认的存储引擎,之前版本的默认引擎为MyISAM,因此,低于5.5版本的mysql配置文件.my.cnf中,关于InnoD ...

  8. MYSQL 遭遇 THE TOTAL NUMBER OF LOCKS EXCEEDS THE LOCK TABLE SIZE

    今天进行MySql 一个表数据的清理,经过漫长等待后出现 The total number of locks exceeds the lock table size 提示.以为是table_cache ...

  9. mysql:The total number of locks exceeds the lock table size

    使用mysql InnoDB存储引擎进行大量数据的更新,删除的时候容易引发”The total number of locks exceeds the lock table size”问题,解决方法之 ...

随机推荐

  1. 【python】资料记录

    今天看了一些关于python的知识: 1.装饰器:https://www.zhihu.com/question/25950466/answer/31731502 2.*args的用法:http://b ...

  2. http协议及http协议和tcp协议的区别

    http是应用层的协议,并且无连接,无状态的协议. http协议的特点: 1.支持c/s模式 2.简单快速:客户端向服务器端传送数据的时候,只需要发送请求方法和路径,请求方法有:post,get,he ...

  3. redis之(十五)redis的集群中的哨兵角色

    一:redis集群的哨兵的目的是什么?. (1)监控主redis和从redis数据库是否正常运行 (2)主redis出现故障,自动将其中一台从redis升级为主redis.将原先的主redis转变成从 ...

  4. 【笔试题】Java 易错题精选

    笔试题 Java 易错题精选 1.写出下列程序的运行结果( )String 不变性Java 值传递 public class Test { public static void main(String ...

  5. logging模块介绍

    在我们的实际开发过程中,我们有时候需要记录一些重要操作,或者程序运行情况,我们就需要在程序里面写入日志,来达到更快的排错跟记录重要操作的目的.在Python中logging模块就很好的解决了这个问题, ...

  6. 洛谷——P1920 成功密码

    P1920 成功密码 题目描述 void_rank匪别人的书来看,原本想看杂志颓废的,结果不小心拿错拿成了被导师称作旁门左道的高中数学杂志<成功密码>.数学差得不行的void_rank实在 ...

  7. 洛谷——P1890 gcd区间

    P1890 gcd区间 题目描述 给定一行n个正整数a[1]..a[n]. m次询问,每次询问给定一个区间[L,R],输出a[L]..a[R]的最大公因数. 输入输出格式 输入格式: 第一行两个整数n ...

  8. Xamarin 中Visual Studio创建项目提示错误

    Xamarin 中Visual Studio创建项目提示错误 错误信息:Object reference not set to an instance of an object 出现这种情况,是由于没 ...

  9. Xamarin开发安装Visual Studio 2015 update2报错的解决办法

    Xamarin开发安装Visual Studio 2015 update2报错的解决办法错误信息:update 2 requires a member of the visual studio 201 ...

  10. Extjs MVC模式

    最近在学习Extjs,发现他可以使用MVC模式,不但可以组织代码,而且可以 减少实现的内容,模型(Models)和控制器(Controllers)也被引入其中. Model模型是字段和它们的数据的集合 ...