Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2448290
  • 博文数量: 540
  • 博客积分: 11289
  • 博客等级: 上将
  • 技术积分: 6160
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-11 20:27
个人简介

潜龙勿用,见龙在田

文章分类

全部博文(540)

文章存档

2018年(2)

2013年(5)

2012年(24)

2011年(104)

2010年(60)

2009年(217)

2008年(128)

分类: Mysql/postgreSQL

2009-08-10 17:37:12

OnlineDataDrift  
Online datadrift checks for MySQL

This describes a tool for generating checksums on tables in a MySQL database. It can be used to check for data drift between copies of tables on a master and slave. The tool is intended to be easy to use and efficient. The tool is easy to use because it can run concurrent with the normal workload on a master or slave, it does not require an idle server, and servers do not have to be drained or restored when it runs. The tool is efficient because it computes the checksum incrementally over a period of time. The rate at which the check is made is configurable.

这里描述一个工具,在mysql数据库的表格上生成一个校验和。它能够用于在主从数据库表的两个拷贝之间进行校验。这个工具易用且有效。说它易用是因为它能够同时运行在具有正常负载的主从服务器上,不需要一台空闲的服务器,且运行时无需重建服务器,也不会将服务器拖垮。该工具很有效,因为在一段时间里它递增地计算校验和。校验的频率是可配的。

为了达到易于使用和高效的目的,这个工具不会在同一个时间点里对所有的表计算校验和,或者计算一个表里所有的行。该工具为每个表的一大段记录计算校验和。这样会忽略某些表的小部分行。这是一种权衡的做法。后面红色的字体无法翻译,Google的原文不全。

but uses features added to the Google MySQL patch. The big difference is that this uses the aggregate function to avoid estimating row ranges.

这工具有点类似于mk-table-checksum,使用特性已被添加到Googlemysql补丁里。其最大不同之处在于这个工具使用最后值()聚合功能来避免估计行的范围。

The checksum statements are run directly on masters. They are written to the binlog and replayed on all slaves by MySQL replication. They are executed on the primary and replicas at the same point in time as measured by transactions committed.

设计:

该工具做如下工作:

    估算数据库的行数来决定其运行有多快

  •对于每一个表,运行一系列语句来计算一大段行的校验和,然后将结果插入一张表

工具完成上面的工作后,将会比较masterslave里的保存结果的表。如果发现不同之处,表示数据有偏移。

计算校验和的语句直接运行在masters上。他们被写入二进制日志里并且通过复制在所有的slaves上重新执行。这些语句在同一时间点里被执行于主和拷贝上,以事务提交作为衡量标准

Run SHOW TABLE STATUS for each database to get an estimate on the number of rows in each table. Determine the rate at which the checksum SQL statements should be run from the estimated row count, the number of rows per chunk (--rows_per_chunk) and the time in which the job should finish (--hours_to_run). Statements are run sequentially. If --hours_to_run is too small, the checksum job will not finish in the expected time. Statements will not be run concurrently to catch up.

行估算

在每个数据库上运行show table status,以获得每个表的行数的预估值。决定计算校验和的SQL语句的比例,将会是估计的行数,每一段的行数(参数:--rows_per_chunk)和任务完成时间(参数:--hours_to_run)。语句顺序地运行。如果--hours_to_run参数设置太小,那么在预期时间内计算校验和的工作将无法完成。语句也没有办法在这么短的时间内同时运行。

The values of float and double columns might be different between the primary and replica for acceptable reasons. For example, the order of evaluation for aggregation may be different when a statement is executed on a replica. If rounding is required during the computation, then the result may be different. We don't know the extent of this problem. If it generates a lot of false warnings, then we should either ignore some floating point columns or provide a new SQL function that formats such columns as with a reduced amount of precision. This can be done by formatting as a decimal string with fewer digits of precision (3 for float, 6 for double).


经本人多方查阅和亲自试验,打好补丁后仍旧没有看到与这个功能相关的工具或功能,现本人已经放弃继续研究这个功能的使用,故翻译将不再进行。现已成功使用另一个工具:mk-table-checksum
如果有哪位成功使用此功能,请不吝赐教啊。

最后ps:经过跟此项目负责人 沟通得知,此项目的源代码并没有发布到mysql patch里面,所以也就见不到该工具的影子了,呵呵。并且推荐了类似工具,Maatkit 项目里的mk-table-checksum。
我已经成功测试mk-table-checksum的功能,不错。

 

阅读(1498) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~