问题描述

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

SET SESSION lock_wait_timeout=31536000

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

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

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

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

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

--safe-slave-backup
Stop slave SQL thread and wait to start backup until
Slave_open_temp_tables in "SHOW STATUS" is zero. If there
are no open temporary tables, the backup will take place,
otherwise the SQL thread will be started and stopped
until there are no open temporary tables. The backup will
fail if Slave_open_temp_tables does not become zero after
--safe-slave-backup-timeout seconds. The slave SQL thread
will be restarted when the backup finishes. --safe-slave-backup-timeout=#
How many seconds --safe-slave-backup should wait for
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. Electron 入门第一篇

    官网:http://electronjs.org/docs/tutorial/application-architecture 转载:https://blog.csdn.net/qq_33323731 ...

  2. MySQL索引知识点及面试常问题

    索引的功能 索引可以大幅增加数据库的查询的性能,在实际业务场景中,或多或少都会使用到. 但是索引是有如下 2 个代价的: 需要额外的磁盘空间来保存索引 对于插入.更新.删除等操作由于更新索引会增加额外 ...

  3. 报错:sqoop2执行job时:Exception: Job Failed with status:3

    报错背景: 创建完成sqoop2的一个job,主要功能是将数据从hdfs存到mysql数据库中. 执行job的时候发生报错. 报错现象: sqoop:> start job -j -s Subm ...

  4. 【翻译】Flink Table Api & SQL — 内置函数

    本文翻译自官网:Built-In Functions  https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/fu ...

  5. 基于EasyNVR摄像机网页无插件直播服务二次开发实现H5播放页面的简单集成方案

    我们通常在构架一套视频SaaS应用的过程中,将平台设计为3层:视频硬件层(视频源).视频能力平台(vPaaS).视频应用平台(vSaaS),视频硬件包括各种IPC.NVR.编码器等视频生成设备,vPa ...

  6. 存储Flash--NOR flash和 Nand flash

    flash是存储芯片的一种,通过特定的程序可以修改里面的数据.FLASH在电子以及半导体领域内往往表示Flash Memory的意思,即平时所说的“闪存”,全名叫Flash EEPROM Memory ...

  7. ll问题

    不能直接用ll 要用__int64 (64和int 之间无空格) #define ll __int64

  8. Linux定时自动备份oracle数据库

    1.在服务器创建备份目录,并赋予权限mkdir -p /backup/P_DATA #新建shell脚本存放路径mkdir -p /backup/P_DB_BACK  #新建Oracle数据库备份目录 ...

  9. Active Objects模式

    实现的思路是,通过代理将方法的调用转变为向阻塞队列中添加一个请求,由一个线程取出请求后执行实际的方法,然后将结果设置到Future中 这里用到了代理模式,Future模式 /************* ...

  10. [转帖]Xshell改字体,改大小,改快捷键方法

    Xshell改字体,改大小,改快捷键方法 -- :: Jason Ho 阅读数 62更多 分类专栏: Software 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附 ...