User Requirements Drive the Replication Design

As mentioned before, the business requirements will really drive your replication configuration and method. The phase zero (0) high availability assessment results will provide you with the answers to most of the detail questions that are needed to pick the right type of replication to use. The answers you gave and the path that was followed through the HA decision tree got you to this point to begin with. However, adding more thoroughness in requirements gathering is highly recommended to get a prototype up and running as quickly as possible. This will allow you to measure the effectiveness of one replication approach over the other.

Figure 7.23 depicts the factors that contribute to replication designs and the possible data replication configuration that would best be used. It is only a partial table because of the numerous factors and the many replication configuration options that are available.

Figure 7.23. Replication design factors.


The last option in Figure 7.23 depicts a “hot spare” requirement that will be used for fail-over and will likely be done using the central publisher/remote distributor model.

Design Note

If you have triggers on your tables and you want them to be replicated along with your table, you might want to revisit them and add a line of code reading NOT FOR REPLICATION so that the trigger code isn't executed redundantly on the subscriber side! So, for a trigger (insert, update, or delete trigger) on the subscriber, you would use the NOT FOR REPLICATION statement for the whole trigger (placed before the AS statement of the trigger). If you want to be selective on a part of the trigger code (FOR INSERT, FOR UPDATE, FOR DELETE) you will put the NOT FOR REPLICATION immediately following the ones you don't want to execute and put nothing on the ones you do want to execute.

If you are using IDENTITY columns to automatically generate column values or to help partition your data you should use the NOT FOR REPLICATION option to keep these values intact during replication. SQL Server will replicate these identity values as they were created on the publisher if you have defined the column on the subscriber to use the NOT FOR REPLICATION statement. If new rows are inserted to subscriber tables with IDENTITY columns, SQL Server increments the identity value in the normal way (because the insert to the subscriber isn't via replication agent, it is via a normal user connection).

You can also use the NOT FOR REPLICATION option if you are using IDENTITY columns in tables and you are implementing ranges of identity values in a partitioned environment (one range of values on one publisher, another range of values on another publisher—and both subscribe and publish to each other). The following create table statements establish the identity value seed and increment for each publisher that owns a set of customerID values (like West Coast publisher and East Coast publisher):

-- Publisher Westcoast (range of custid between 1 and 1,000,000)
CREATE TABLE Customers ( CustID INT IDENTITY (1, 1)
NOT FOR REPLICATION PRIMARY KEY,
....)

-- Publisher Eastcoast (range of custid between 1,000,001 and above)
CREATE TABLE Customers ( CustID INT IDENTITY (1000001, 1)
NOT FOR REPLICATION PRIMARY KEY,
....)

It is best to use the NOT FOR REPLICATION option along with the CHECK constraint to ensure that the identity values being assigned are within the allowed range. For example

CREATE TABLE Customers
(CustID INT IDENTITY(1000001, 1)
    NOT FOR REPLICATION
    CHECK NOT FOR REPLICATION (CustID <= 2000000),
     ...,
    CONSTRAINT valid_range_pk PRIMARY KEY (CustID)
 )

One caveat is the case when you are using transactional replication with immediate-updating subscribers and only one publisher. You should not use the IDENTITY and NOT FOR REPLICATION approach described here. Instead, use the IDENTITY column at the publisher only, and have the Subscriber use INT(data type) for that column. In this way the next identity value is always generated at the publisher and only the publisher.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.96.94