报错信息:

InnoDB: An optimized (without redo logging) DDLoperation has been performed. All modified pages may not have been flushed to the disk yet.

为了解决这个错误,percona新加了三个参数xtrabackup --lock-ddl, xtrabackup --lock-ddl-timeout, xtrabackup --lock-ddl-per-table。

MySQL5.7在记录redo log时会跳过某些DDL。在MySQL5.7当中,创建索引分为三个阶段
1:扫描clustered index,生成索引项到sort buffer当中,当sort buffer满了的时候,会写入到临时文件当中。
2:多个线程对临时文件或者sort buffer中的索引项进行排序
3:排序完成后插入到 B-tree当中。
在此之前,MySQL创建索引的时候会调用insert APIs逐条进行 B-tree的插入,这种插入方式会打开 B-tree游标,找到位置,乐观插入。如果要插入的 B-tree节点page页满了,就会拆分或者合并 B-tree的page页,我们称之为悲观插入。这样创建索引就会引起不断分裂和合并,并且还有查找插入位置,代价会比较昂贵。
Sorted Index Builds and Redo Logging:
在使用Sorted Index方式创建索引的时候会关闭掉Redo Logging,他是通过检查点的方式来保证创建索引的高可用性。检查点强制将所有脏页写入磁盘,在索引创建期间, page cleaner会定期的刷新脏页以保证检查点的快速前推。通常情况下,只有当干净页面的数量低于设置的阈值时,page cleaner才回去刷新脏页,但是在创建索引的过程中, page cleaner会快速刷新,来减少检查点的开销。

由于不记录redo,然后再备份时候就会出现以下错误

[FATAL] InnoDB: An optimized(without redo logging) DDLoperation has been performed. All modified pages may not have been flushed to the disk yet.
Percona XtraBackup will not be able to take a consistent backup. Retry the backup operation

  xtrabackup为了解决这个问题加入了--lock-ddl选项,但是会在备份的时候会对所有表加一个备份锁(Executing LOCK TABLES FOR BACKUP)

另外一个选项是--lock-ddl-per-table,会有以下输出

170726 11:32:33 [01] Copying ./ibdata1 to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/ibdata1
170726 11:32:33 Locking MDL for db1.sb1
170726 11:32:33 [02] Copying ./db1/sb1.ibd to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/db1/sb1.ibd
170726 11:32:33 Locking MDL for db1.sbtest1
170726 11:32:33 Locking MDL for db2.sb1
170726 11:32:33 [03] Copying ./db1/sbtest1.ibd to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/db1/sbtest1.ibd
170726 11:32:33 [04] Copying ./db2/sb1.ibd to /home/shahriyar.rzaev/backup_dir/ps_5.7_master/full/2017-07-26_11-31-56/db2/sb1.ibd
170726 11:32:33 [04] ...done
170726 11:32:33 >> log scanned up to (2892754398)
170726 11:32:34 Locking MDL for db2.sbtest1

  

有一点需要注意是在非percona server使用--lock-ddl参数肯能不被支持,例如MariaDB。但是--lock-ddl-per-table是所有的server都支持的。

但是如果一个进程持有MDL锁,另外一个进程执行alter table操作(创建索引属于alter table操作),这时候更新操作就会被阻塞。

如果不想在备份时候又任何阻塞就只能打开old_alter_table参数,这样就不能使用alter table新特性。

参数项解释

  --lock-ddl          Issue LOCK TABLES FOR BACKUP if it is supported by server
at the beginning of the backup to block all DDL
operations.
--lock-ddl-timeout=#
If LOCK TABLES FOR BACKUP does not return within given
timeout, abort the backup.
--lock-ddl-per-table
Lock DDL for each table before xtrabackup starts to copy
it and until the backup is completed.
--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.

MySQL 5.7使用xtabackup报错解决的更多相关文章

  1. linux mysql source 导入大文件报错解决办法

    找到mysql的配置文件目录 my.cnf interactive_timeout = 120wait_timeout = 120max_allowed_packet = 500M 在导入过程中可能会 ...

  2. MySql数据库存储emoji表情报错解决办法

    异常:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1 解决: ...

  3. mysql导入数据方法和报错解决

    mysql -u root -p databasename < db.sql 数据库导入数据时,MySQL收到下面异常:ERROR 1153 (08S01): Got a packet bigg ...

  4. MySQL5.7.26安装及启动报错解决

    一.安装依赖包 [root@db01 ~]# yum install -y lrzsz [文件上传/下载] [root@db01 ~]# yum -y install xfsprogs [安装磁盘格式 ...

  5. 【MYSQL】MYSQL报错解决方法: Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8M B4 in a future release."

    用python3.6.5创建mysql库时出现如下报错,虽然报错,但是数据库可以插入成功. D:\python3\lib\site-packages\pymysql\cursors.py:170: W ...

  6. MySQL 表与字段编码格式报错

    MySQL 表与字段编码格式报错 一.数据库,表,字段编码格式都为latin1(iso-8859-1) .当数据保存到数据库后,中文显示乱码. 解决办法: 1.在访问数据库连接串中添加编码格式: &l ...

  7. 在给mysql数据库备份时,报错: mysqldump: Got error: 145: Table '.\shengdaxcom\pre_forum_thread' is marked as c rashed and should be repaired when using LOCK TABLES

    在给mysql数据库备份时,报错: mysqldump: Got error: 145: Table '.\shengdaxcom\pre_forum_thread' is marked as cra ...

  8. egg 连接 mysql 的 docker 容器,报错:Client does not support authentication protocol requested by server; consider upgrading MySQL client

    egg 连接 mysql 的 docker 容器,报错:Client does not support authentication protocol requested by server; con ...

  9. 部署php程序报错解决---TP框架

    1.TP框架中 出现如下错误: 访问网站 http://192.168.0.204/ STORAGE_WRITE_ERROR_:./Runtime/Cache/Home/51620d75af91aa7 ...

随机推荐

  1. Spring AOP设计

    Spring IOC设计到的设计模式: 工厂模式,模板方法模式,单例模式 Spring AOP涉及到的设计模式: 工厂模式,代理模式 1.Spring AOP目标 将分散在程序各处的横切关注点剥离出来 ...

  2. nrm -- 一键切换npm源

    0. 背景 先描述一下没有nrm时我们是怎样使用npm源的 查看npm源地址,终端中输入 npm config list 可以看到npm源 metrics-registry = "https ...

  3. 基于 Binlog + Flink 实现多表数据同构/异构方案

    https://mp.weixin.qq.com/s/1h942YAcS6fhO5C43hGX-w 什么是数据异构?简单讲,就是将数据进行异地数据异构存储. 数据异构 服务市场使用 BinLake(京 ...

  4. JS实现下载的常用方案

    如何使用JS实现异步下载吗?即:既能实现下载又不刷新页面.这时我们常常会想到使用ajax,但是由于ajax接受的response始终是字符串,因此并不能使用ajax来实现下载功能. 常见是新建下载的方 ...

  5. JS数组常见方法的深浅拷贝分类

    一.涉及浅拷贝类方法,会改变原数组 1,pop():   删除 arrayObject 的最后一个元素,把数组长度减 1,并且返回它删除的元素的值.如果数组已经为空,则 pop() 不 改变数组,并返 ...

  6. 小D课堂 - 零基础入门SpringBoot2.X到实战_第10节 SpringBoot整合定时任务和异步任务处理_41、SpringBoot定时任务schedule讲解

    笔记 1.SpringBoot定时任务schedule讲解     简介:讲解什么是定时任务和常见定时任务区别 1.常见定时任务 Java自带的java.util.Timer类            ...

  7. Flutter TextField详解

    原文地址:https://www.jianshu.com/p/54419a143d70 实现TextField说简单也简单,说有坑,坑也不小,下面从易到难介绍一下使用 1.最简单的就是无参数调用构造方 ...

  8. k8s记录-使用kube-proxy让外部网络访问K8S service的ClusterIP (转载)

    配置方式 kubernetes版本大于或者等于1.2时,外部网络(即非K8S集群内的网络)访问cluster IP的办法是:修改master的/etc/kubernetes/proxy,把KUBE_P ...

  9. wave数据集的回归曲线

    wave数据集的回归曲线 import matplotlib.pyplot as pltimport mglearnfrom scipy import sparseimport numpy as np ...

  10. Spring MVC 验证表单

      在实际工作中,得到数据后的第一步就是检验数据的正确性,如果存在录入上的问题,一般会通过注解校验,发现错误后返回给用户,但是对于一些逻辑上的错误,比如购买金额=购买数量×单价,这样的规则就很难使用注 ...