Implementing High Availability (DR) Using SQL Server 2005 Transactional ReplicationBackground and the SQL 2000 MethodologyUsing transactional replication as a disaster recovery
(DR) option seems to be fairly standard but definitely problematic in SQL 2000 and I wanted to see if it
has become any easier for SQL 2005. Use for DR is mentioned in detail in the SQL
Server 2000 High Availability Series
here. There are well established “competing” alternative technologies
in this series of articles including log shipping, replication with updateable subscribers, and now database
mirroring, which all have their pros and cons and I won't try to do
a long comparison of all these techniques here. Let’s just assume that you have come
to the conclusion that transactional replication is the most appropriate DR
solution for your needs and want to implement it as painlessly as possible. Setting it up in SQL Server 2005What I was interested in was how have things improved for SQL Server 2005 when using transactional replication for a failover solution. Does the above document still hold. If not, are people still using an old methodology when things could now be done more simply? Consider Default Transactional ReplicationIf we replicate a set of tables containing the usual PKs,
FKs, defaults, check constraints, indexes etc what is taken and what is left
behind when using SQL 2005?
[Further discussion of the identity issue If you select the 0x04 value in
sp_addarticle, this will replicate identity columns as
identity columns - this was introduced in SQL Server 2000 SP4.
It isn't exposed in SSMS but can be set in sp_addarticle
or sp_changearticle. Having the identity column on the
subscriber is just what you want for a DR setup. What we also
want is for the identity values to be incremented normally on
the subscriber during synchronization, so if there is a DR
scenario, we don't then have to laboriously use DBCC CHECKIDENT
afterwards to reseed all the identity columns. So, how to set
this up? So, the schemas of the publisher and subscriber are already converging, without any manual changes having yet being made. How can we force the schemas to converge further without resorting to editing scripts? The remaining configuration is set on the article properties dialog box (below).
In the Article properties dialog above we see there is a massive advantage – we can set the properties collectively for a set of tables rather than one by one in SQL 2000. The actual properties themselves are shown below:
The properties in red have defaults values which need changing for our purposes and are the "crucial" ones, while the ones in blue are potentially less critical depending on your requirements. The simplest method is to set them all to true. After setting these properties appropriately by reversing the ones in red and blue I use SQLCompare and find that apart from some inconsequential changes (eg the foreign keys are marked as WITH NOCHECK) my subscriber schema is identical to the publisher. In the Additional Options section below we see that even the problem of timestamps is automatically taken care of.
The default of “Convert timestamp to binary” is set to false. At first I thought that some fundamental change had occurred and timestamps were now allowed to be assigned directly on the subscriber. Looking at the replicated timestamp data and the insert stored procedure I see that the mechanism chosen is to allow the subscriber to select its own timestamp value and not to try to keep it in sync with the publisher ie it isn't really replicated at all. Obviously this leads to non-convergence of data and if later on you are using DataCompare or some equivalent tool you must be aware that this column will need omitting to have a useful comparison of data. SummarySo, by setting the properties of the table articles appropriately we can use transactional replication in SQL Server 2005 as a DR solution without resorting to manual table scripting and stored procedure modifications. This is good news - it can all now be implemented much more simply than with SQL 2000 and is therefore less prone to errors. |
Paul Ibison, Copyright © 2010 |