Implementing NoSync Initializations (and variations) on SQL Server 2005I'd like to do a brief article on doing nosync initializations for SQL Server 2005. I had previously done an article on SQL Server 2000 (see here), but the methodology is now slightly different and offers other alternatives. How to Add the Subscription - the WizardWhen adding a subscription, the option in the wizard to declare that 'No, the Subscriber already has the schema and data' has been replaced by the screen below which is fairly self-explanatory. We still need to get the data to the subscriber as before, and there are several modifications we might need to make to the schema on the subscriber as explained in the section below, but this sets us up for a nosync initialization. For merge replication this is much the same as the previous methodology for a nosync initialization and running the merge agent will generate all the extra system tables, triggers etc on the subscriber. However for transactional replication this is not the same as the SQL Server 2000 nosync initialization - this is the new 'replication support only' option which is explained further below.
How to Add the Subscription - ScriptsUsing scripts we can more easily see what all the options are and what they mean. To add a subscription in transactional replication we use the following procedures: sp_addsubscription and sp_addpushsubscription_agent / sp_addpullsubscription_agent. In sp_addsubscription there are now 4 options for @sync_type. Previously there were just 2 options: 'automatic' (the default) and 'none' which was used to make a nosync initialization. This is still the case for merge replication in SQL Server 2005 so I'll not mention that any more, but for transactional we now have several new options which aren't explicitly available in the wizard. To paraphrase my SQL Server 2000 article, the latter option ('none') had to be used in conjunction with a manual generation of replication stored procedures which are then applied to each subscriber. In SQL Server 2005 we now have alternative options which I'll explain below: (1) none -
assumes that the subscriber already has the schema and initial data for
published tables - NOW DEPRECATED. (however sp_scriptpublicationcustomprocs is
not marked as deprecated for manual use in BOL!!!) (a) remove redundant objects and tables. There's
no point cluttering up the database on the subscriber with nothing that wouldn't
be there is you had done an automatic initialization. This will speed up the
backup and clarify to other administrators what the subscriber is being used
for. How "initialize with backup" Works, and How to avoid PitfallsWhen using "initialize with backup", a
transactional replication topology does not need to be quiesced during
configuration. With "initialize with backup", sp_addsubscription
internally calls RESTORE HEADERONLY to extract the last LSN of backup to be used
as the starting point of the new subscription. A subsequent comparison is made
to the xact_seqno value in distribution..MSrepl_commands, and the necessary
commands transferred. To ensure that all the required commands actually exist in
the MSrepl_commands table we must restore the backup before the retention period
is reached and the distribution cleanup agent removes the rows. BOL recommends
that we disable the distribution cleanup agent is stopped during this period to
ensure it all goes smoothly. If you get this wrong, you'll receive the following
message: ConclusionsHopefully this article will help you to take advantage of the useful new options in setting up a nosync initialization. This option has always involved some necessary scripting requirements, and it could never be done entirely using the GUI. Now with SQL Server 2005 this is even more so, but the additional options present a necessary alternative to automatic initializations. Thanks to Nigel Maneffa for pointing out some improvements on this article. |
Paul Ibison, Copyright © 2010 |