问题描述

innobackupex备份过程需要保证备份数据一致性,通过刷新表缓存和加全局读锁(FLUSH TABLES WITH READ LOCK)获取备份位点,而为防止锁等待超时,会先设置:

  1. SET SESSION lock_wait_timeout=31536000

在MySQL中,导致FLUSH TABLES WITH READ LOCK操作获取锁超时的场景有:

  1. 1、超长事务或超大DML操作
  2. 2、超大表DDL操作

如果要解决锁超时问题,可以从加锁和KILL超长查询两方面入手,innobackupex命令有如下参数:

  1. --no-lock
  2. Use this option to disable table lock with "FLUSH TABLES
  3. WITH READ LOCK". Use it only if ALL your tables are
  4. InnoDB and you DO NOT CARE about the binary log position
  5. of the backup. This option shouldn't be used if there are
  6. any DDL statements being executed or if any updates are
  7. happening on non-InnoDB tables (this includes the system
  8. MyISAM tables in the mysql database), otherwise it could
  9. lead to an inconsistent backup. If you are considering to
  10. use --no-lock because your backups are failing to acquire
  11. the lock, this could be because of incoming replication
  12. events preventing the lock from succeeding. Please try
  13. using --safe-slave-backup to momentarily stop the
  14. replication slave thread, this may help the backup to
  15. succeed and you then don't need to resort to using this
  16. option.
  17.  
  18. --no-backup-locks
  19. This option controls if backup locks should be used
  20. instead of FLUSH TABLES WITH READ LOCK on the backup
  21. stage. The option has no effect when backup locks are not
  22. supported by the server. This option is enabled by
  23. default, disable with --no-backup-locks.
  24.  
  25. --kill-long-query-type=name
  26. This option specifies which types of queries should be
  27. killed to unblock the global lock. Default is "all".
  28.  
  29. --kill-long-queries-timeout=#
  30. This option specifies the number of seconds innobackupex
  31. waits between starting FLUSH TABLES WITH READ LOCK and
  32. killing those queries that block it. Default is 0
  33. seconds, which means innobackupex will not attempt to
  34. kill any queries.

如果在从库上执行备份,可以考虑暂停复制进程来防止阻塞:

  1. --safe-slave-backup
  2. Stop slave SQL thread and wait to start backup until
  3. Slave_open_temp_tables in "SHOW STATUS" is zero. If there
  4. are no open temporary tables, the backup will take place,
  5. otherwise the SQL thread will be started and stopped
  6. until there are no open temporary tables. The backup will
  7. fail if Slave_open_temp_tables does not become zero after
  8. --safe-slave-backup-timeout seconds. The slave SQL thread
  9. will be restarted when the backup finishes.
  10.  
  11. --safe-slave-backup-timeout=#
  12. How many seconds --safe-slave-backup should wait for
  13. Slave_open_temp_tables to become zero. (default 300)

MySQL Backup--Xtrabackup备份设置锁等待问题的更多相关文章

  1. MySQL Backup mysqldump备份流程学习

    我们都知道MySQL逻辑备份工具mysqldump可以保证备份数据的一致性,但是它是怎么保持一致性的? 本文不讨论mysqldump具体的选项和用法,一直对mysqldump的工作机制梳理的不太清楚, ...

  2. MySQL 事务没有提交导致 锁等待 Lock wait timeout exceeded

    java.lang.Exception: ### Error updating database.  Cause: java.sql.SQLException: Lock wait timeout e ...

  3. 排查MySQL事务没有提交导致 锁等待 Lock wait timeout exceeded

    解决思路: select * from information_schema.innodb_trx 之后找到了一个一直没有提交的只读事务, kill 到了对应的线程后ok 了. 转载自:http:// ...

  4. MySQL 基于xtrabackup备份—热备工具

    xtrabackup(仅对InnoDB存储引擎支持热备) percona公司开发 改进的MySQL分支:percona-server 存储引擎改进:InnoDB —> XtraDB 使用本地的R ...

  5. ubuntu上的mysql数据库双机备份设置

    配置环境: myslq 5.5.3 + ubuntu server 12.04 一.配置MySQL主服务器(192.168.0.1) 1.增加一个账号专门用于同步 1 mysql>grant r ...

  6. Mysql使用xtrabackup备份失败处理

    在生产环境中使用的是xtrabackup,对mysql进行备份,每天0点开始备份,周日是全量备份,其他时间是基于周日做的增量备份,通过脚本实现,每天备份完成后会发送短信,突然有一天,备份全部失败,手动 ...

  7. mysql 开发进阶篇系列 13 锁问题(关于表锁,死锁示例,锁等待设置)

    一. 什么时候使用表锁 对于INNODB表,在绝大部分情况下都应该使用行锁.在个别特殊事务中,可以考虑使用表锁(建议). 1. 事务需要更新大部份或全部数据,表又比较大,默认的行锁不仅使这个事务执行效 ...

  8. MySQL事务锁等待超时 Lock wait timeout exceeded; try restarting transaction

    工作中处理定时任务分发消息时出现的问题,在查找并解决问题的时候,将相关的问题博客收集整理,在此记录下,以便之后再遇到相同的问题,方便查阅. 问题场景 问题出现的场景: 在消息队列处理消息时,同一事务内 ...

  9. MySQL详解--锁

    http://blog.csdn.net/xifeijian/article/details/20313977 2014-03-06 23:45 66484人阅读 评论(17) 收藏 举报  分类: ...

随机推荐

  1. CFCA证书工具类

    jar:com.cfca.pkibase-1.0.jar import java.io.UnsupportedEncodingException; import java.security.Secur ...

  2. centos7下python2环境安装pip2、kazoo、bottle、beaker

    摘自:https://mp.weixin.qq.com/s?src=11&timestamp=1576355125&ver=2034&signature=mNp2na6VjFz ...

  3. matlab学习笔记7-定时器

    一起来学matlab-matlab学习笔记7-定时器 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考书籍 <matlab 程序设计与综合应用>张德丰等著 感谢张老师的书籍,让 ...

  4. Swift编码总结5

    1.UIWindow属性: 1>.- (void)becomeKeyWindow;                               // override point for sub ...

  5. preHandle、postHandle与afterCompletion

    preHandle 调用时间:Controller方法处理之前 执行顺序:链式Intercepter情况下,Intercepter按照声明的顺序一个接一个执行 若返回false,则中断执行,注意:不会 ...

  6. js 二叉树算法

    //生成二叉树 function binarySearchTree() { let Node = function(key) { this.key = key; this.left = null; t ...

  7. [LeetCode] 67. Add Binary 二进制数相加

    Given two binary strings, return their sum (also a binary string). The input strings are both non-em ...

  8. QT笔记--组合框

    1 数据项 (1)位置 index 第一项位0 (2)文本text 这一项的显示值 (3) 关联数据,每一项可以关联一个数据比如整数或者文本类型数据 2 手工添加项 (1)additem:新数据项附加 ...

  9. 【RSR】RSR如何配置BGP与BFD联动(动态路由)

    应用场景 企业租用运营商MSTP线路,配置BGP路由协议上网,由于企业本端出口路由器无法检测到运营商中间链路通信中断,导致路由收敛缓慢,无法快速的切换到其它备份线路,此时可以在路由器上启用BGP与BF ...

  10. Redis专栏

    后端开发都应该掌握的Redis基础 Redis实用监控工具一览