码迷,mamicode.com
首页 > 其他好文 > 详细

Replication Monitor Operation

时间:2015-12-22 21:16:49      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:

Replication Monitor Operation 有三种操作:Reinitialize Subscriptions,Validate Replicated Data 和 Subscription Expiration and Deactivation

 

1,Reinitialize Subscriptions

Reinitialize a subscription 是指在Subscription创建完成之后,make a subscription for reinitialization,或者change property that requires a reinitialization,对Subscription重新初始化,保证Publication和subscription的data 和 schema是相同的。

MSDN 对 Initialize a Subscription 的描述:

Subscribers in a replication topology must be initialized, so that they have a copy of the schema from each article in the publication they have subscribed to and any replication objects that are required, such as stored procedures, triggers, and metadata tables. In addition, the Subscriber typically receives an initial dataset. The default initialization method uses a full snapshot that includes schema, replication objects, and data, but publications can also be initialized without a full snapshot.

 

Initialize 复选框是指是否需要Initialize a subscription。如果没有选中 Initialize 复选框,那么Publication被mark为non-immeidate_sync_publication,不能对Subscription reinitialize。

技术分享

 

Reinitializing a subscription involves applying a new snapshot of one or more articles to one or more Subscribers

Reinitialization occurs for one of two reasons:

  • You explicitly mark a subscription for reinitialization.
  • You perform an action, such as a property change, that requires a reinitialization.

In both cases, the most recent snapshot is applied to the Subscriber the next time the Distribution Agent or the Merge Agent runs. For snapshot and transactional replication, when reinitialization occurs, any changes made at the Subscriber, but not yet synchronized with the Publisher, are overwritten by the application of the new snapshot.

If, you specified that no initial snapshot was to be applied to the Subscriber when you created the subscription, and you then mark the subscription for reinitialization, a snapshot is not applied.

 

After a publication has been created, an initial snapshot is typically created and copied to the snapshot folder. It is then applied to the Subscriber by the Distribution Agent (for transactional and snapshot publications).

 

在Publication端,mark reinitialization

技术分享

在Subscription端,mark reinitialization

技术分享

对于non-immeidate_sync_publication,不能reinitialize。

技术分享

 

2,Subscription Expiration and Deactivation

Subscription 和Publication的数据同步可能会expire。数据同步必须在一个规定的时间内完成,即retention period。

在Distributor端设置的maximum distribution retention period,是指distribution db存储transaction的时间,以hour为单位。

技术分享

在publisher端,查看Publication的Property。Subscription Expiration 的行为有两种,如图

技术分享


Subscriptions can be deactivated or can expire if they are not synchronized within a specified retention period. The action that occurs depends on the type of replication and the retention period that is exceeded.

If a subscription is not synchronized within the maximum distribution retention period (default of 72 hours) and there are changes in the distribution database that have not been delivered to the Subscriber, the subscription will be marked deactivated by the Distribution clean up job that runs on the Distributor. The subscription must be reinitialized.

If a subscription is not synchronized within the publication retention period (default of 336 hours), the subscription will expire and be dropped by the Expired subscription clean up job that runs on the Publisher. The subscription must be recreated and synchronized.

If a push subscription expires, it is completely removed, but pull subscriptions are not. You must clean up pull subscriptions at the Subscriber.

 

3,Validate Replicated Data

在Transactional 和 merge replication 中,能够 validate subscriber和publisher的数据是否匹配。

在Publication上,右键点击弹出快捷菜单“Validate Subscriptions...”

技术分享

 

 

Transactional and merge replication allow you to validate that data at the Subscriber matches data at the Publisher. Validation can be performed for specific subscriptions or for all subscriptions to a publication. Specify one of the following validation types and the Distribution Agent or Merge Agent will validate data the next time it runs:

  • Row count only. This validates whether the table at the Subscriber has the same number of rows as the table at the Publisher, but does not validate that the content of the rows matches. Row count validation provides a lightweight approach to validation that can make you aware of issues with your data.
  • Row count and binary checksum. In addition to taking a count of rows at the Publisher and Subscriber, a checksum of all the data is calculated using the checksum algorithm. If the row count fails, the checksum is not performed.

How Data Validation Works

SQL Server validates data by calculating a row count or a checksum at the Publisher and then comparing those values to the row count or checksum calculated at the Subscriber. One value is calculated for the entire publication table and one value is calculated for the entire subscription table, but data in text, ntext, or image columns is not included in the calculations.

While the calculations are performed, shared locks are placed temporarily on tables for which row counts or checksums are being run, but the calculations are completed quickly and the shared locks removed, usually in a matter of seconds.

When binary checksums are used, 32-bit redundancy check (CRC) occurs on a column-by-column basis rather than a CRC on the physical row on the data page. This allows the columns with the table to be in any order physically on the data page, but still compute to the same CRC for the row. Binary checksum validation can be used when there are row or column filters on the publication.

 

If the validation failure is an issue, manually update the data so that it is synchronized, or reinitialize the subscription.

参考文档:

https://msdn.microsoft.com/en-us/library/ms152771(v=sql.110).aspx

https://msdn.microsoft.com/en-us/library/ms151188(v=sql.110).aspx

https://msdn.microsoft.com/en-us/library/ms152578(v=sql.110).aspx

https://msdn.microsoft.com/en-us/library/ms152758(v=sql.110).aspx

https://msdn.microsoft.com/en-us/library/ms151705(v=sql.110).aspx

https://msdn.microsoft.com/en-us/library/ms151795(v=sql.110).aspx

 

Replication Monitor Operation

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/5068072.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!