mysql 5.6 新特性 主从延迟

前面一篇文章《mysql replication 主从间如何延迟 --- 某大型互联网面试题》已经写到如何延迟主从配置,在5.6里已经实现了这个功能,那么我们看一下官方文档介绍吧 :

http://dev.mysql.com/doc/refman/5.6/en/replication-delayed.html

MySQL 5.6 supports delayed replication such that a slave server deliberately lags behind the master by at least a specified amount of time. The default delay is 0 seconds. Use theMASTER_DELAY option forCHANGE MASTER TO to set the delay to N seconds:

CHANGE MASTER TO MASTER_DELAY = N;

欢迎大家阅读《mysql 5.6 新特性 主从推延》,跪求各位点评,by 搞代码

An event received from the master is not executed until at least N seconds later than its execution on the master. The exceptions are that there is no delay for format description events or log file rotation events, which affect only the internal state of the SQL thread.

mysql 5.6提供了slave服务器指定落后于master服务器一段时间这样的功能.默认没有延迟,通过指定master_delay=n选项来设置延迟n秒:

change master to master_delay=n;

从master接受的event事件等到过了n秒后才在slave上面执行。不会产生异常,仅仅影响sql线程的内部状态。

Delayed replication can be used for several purposes:

To protect against user mistakes on the master. A DBA can roll back a delayed slave to the time just before the disaster.

To test how the system behaves when there is a lag. For example, in an application, a lag might be caused by a heavy load on the slave. However, it can be difficult to generate this load level. Delayed replication can simulate the lag without having to simulate the load. It can also be used to debug conditions related to a lagging slave.

To inspect what the database looked like long ago, without having to reload a backup. For example, if the delay is one week and the DBA needs to see what the database looked like before the last few days' worth of development, the delayed slave can be inspected.

延迟复制用于下面的一些场景:

1  保护master上的用户错误。dba可以通过延迟回滚到灾难发生前。

2  当有延迟的时候,测试系统活动状况。如以下例子:在slave上面因为一个大量加载可能导致延迟,那么我们就可以人为模拟这个延迟,虽然大量加载不一定导致延迟。

3 检查数据库之前的一些状况。

START SLAVE andSTOP SLAVE take effect immediately and ignore any delay.RESET SLAVE resets the delay to 0.

SHOW SLAVE STATUS has three fields that provide information about the delay:

SQL_Delay: A nonnegative integer indicating the number of seconds that the slave must lag the master.

SQL_Remaining_Delay: When Slave_SQL_Running_State isWaiting until MASTER_DELAY seconds after master executed event, this field contains an integer indicating the number of seconds left of the delay. At other times, this field isNULL.

Slave_SQL_Running_State: A string indicating the state of the SQL thread (analogous toSlave_IO_State). The value is identical to theState value of the SQL thread as displayed by SHOW PROCESSLIST

通过 show slave status 查看到三个方面的信息关于延迟

sql_delay :非负整数表明延迟与master

sql_remaining_delay: 当发生等待时,这个地方会有非负整数值。平时,这个地方是null。

slave_sql_running_state:字符串指定sql线程状态(类似于 slave_io_state)。这个状态与通过show processlist 显示的状态值一致。

When the slave SQL thread is waiting for the delay to elapse before executing an event,SHOW PROCESSLIST displays its State value as Waiting until MASTER_DELAY seconds after master executed event.

The relay-log.info file now contains the delay value, so the file format has changed. SeeSection 16.2.2.2, “Slave Status Logs”. In particular, the first line of the file now indicates how many lines are in the file. If you downgrade a slave server to a version older than MySQL 5.6, the older server will not read the file correctly. To address this, modify the file in a text editor to delete the initial line containing the number of lines.

当slave sql thread  线程正在延迟等待时,show  processlist 显示的它的状态值是等待。the relay-log.info 文件也包含延迟值,因此这个文件格式已经改变。具体看官方文档。

第一次翻译,有些可能不太通顺,欢迎指正探讨。

原创文章,转载请注明: 转载自搞代码

微信 赏一包辣条吧~

支付宝 赏一听可乐吧~

mysql 主从特性_mysql 5.6 新特性 主从推延相关推荐

  1. mysql 5.6特性_MySQL 5.6新特性概览

    MySQL5.6 features This is the MySQL™ Reference Manual. It documents MySQL 5.6 through 5.6.28 添加的新特性( ...

  2. mysql 直方图统计_MySQL 8.0 新特性之统计直方图

    原标题:MySQL 8.0 新特性之统计直方图 | 译者简介 译者 韩杰·沃趣科技MySQL数据库工程师 熟悉mysql体系架构.主从复制,熟悉问题定位与解决 出品 沃趣科技 原文链接: https: ...

  3. mysql 5.9 新特性_MySQL 5.7新特性介绍

    1. 介绍身处MySQL这个圈子,能够切身地感受到大家对MySQL 5.7的期待和热情,似乎每个人都迫不及待的想要了解.学习和使用MySQL 5.7.那么,我们不禁要问,MySQL 5.7到底做了哪些 ...

  4. mysql 并行查询_MySQL 8.0新特性-并行查询innodb_parallel_read_threads

    原文很好翻译,直接读好理解 长久以来MySQL没有并行查询,并且在其他数据库已经有了的情况下,MySQL终于在8.0.14版本开始有了自己的并行查询,但使用面非常的窄,只适用于并行聚集索引的count ...

  5. Jdk8新特性一:jdk8新特性之default关键字、日期类、Base64类、Optional

    Jdk8新特性一:jdk8新特性之default关键字.日期类.Base64类.Optional 文章目录 Jdk8新特性一:jdk8新特性之default关键字.日期类.Base64类.Option ...

  6. mysql计算三角形斜边_MySQL 5.7新特性之Generated Column(函数索引)

    MySQL 5.7引入了Generated Column,这篇文章简单地介绍了Generated Column的使用方法和注意事项,为读者了解MySQL 5.7提供一个快速的.完整的教程.这篇文章围绕 ...

  7. mysql is双竖线_MySQL 5.0 新特性教程 存储过程:第二讲

    MySQL 5.0 新特性教程 存储过程:第二讲推荐查看本文HTML版本 什么样的SQL语句在Mysql存储过程中才是合法的呢?你可以创建一个包含INSERT, UPDATE,DELETE, SELE ...

  8. mysql 5.5 特性_MySQL5.5复制新特性

    MySQL5.5复制新特性 一.MySQL5.5复制改进 MySQL5.5版本对MySQL Replication进行了多项的改良,以提供数据的完整性,性能和应用灵活性更高水平. 1.Semisync ...

  9. 【MySQL 第18章_MySQL8其它新特性】

    第18章_MySQL8其它新特性 1. MySQL8新特性概述 1.1 MySQL8.0 新增特性 1. 更简便的NoSQL支持 2.更好的索引 3. 更完善的JSON支持 4. 安全和账户管理 5. ...

最新文章

  1. 基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?...
  2. 从源码分析DEARGUI之add_listbox
  3. 【版本更新】IM 4.3.0新版本升级上线!
  4. [MySQL光速入门]012 作业解答
  5. js屏蔽浏览器(IE和FireFox)的刷新和右键等功能
  6. 好久不来这里写东西了.
  7. JSON-JSON 百科
  8. C++---堆代码实现
  9. 人工智能目标检测模型(四)——ResNet
  10. 海思烧录工具HiTool的使用方法以及烧录uboot
  11. Centos7下载linux内核源码
  12. iOS-AppStore上线被拒的各种理由...
  13. 服务器虚拟内存设置在什么盘,虚拟内存设置在哪个磁盘呢
  14. cleander日期转换
  15. [Jzoj]3457. 沙耶的玩偶
  16. Halcon union_adjacent_contours_xld详解
  17. library(igraph)
  18. yolo和以往算法的区别/yolo为什么叫yolo
  19. C/C++计算类/结构体和联合体(union)所占内存大小(内存对齐问题)
  20. 4. Flux.filter与Flux.filterWhen的区别与联系

热门文章

  1. jQuery Mobile事件,开发全解+完美注释
  2. cat /etc/redhat-release 查看centos版本
  3. matlab简单分析离散小波变换
  4. AD16自定义板子大小
  5. DNS 正向查找与反向查找
  6. vs下qt的信号与槽实现
  7. 《我在谷歌大脑见习机器学习的一年:Node.js创始人的尝试笔记》阅读笔记
  8. Android控件——TextView,EditText
  9. 懒惰是人类进步的动力,勤奋是实现偷懒的途径
  10. [转载] Python使用list.reverse()返回None