The conflict tables ■ ■ match the schema of the published tables: each published table is scripted, and then the script is used to create the conflict table in the publication database
Trang 1Conflict tables are created to store conflict information The conflict tables
■
■
match the schema of the published tables: each published table is scripted,
and then the script is used to create the conflict table in the publication
database Conflict tables are named in the form dbo.MSmerge_conflict_
<Publication>_<Article>.
Components
Merge replication uses two components, Snapshot Agent and Merge Agent If the
publication is unfiltered or uses static filters, the Snapshot Agent creates a single
snapshot If the publication uses parameterized filters, the Snapshot Agent creates a
snapshot for each partition of data The Merge Agent applies the initial snapshots to
the Subscribers It also merges incremental data changes that occurred at the
Publisher or Subscribers after the initial snapshot was created, and detects and
resolves any conflicts according to rules you configure.
Replication Configuration
Though there are several replication types, which we discussed earlier, configuration
of those types are almost similar Therefore, in this chapter we will look at how to
configure Merge Replication Later we will discuss how to configure Peer-to-Peer
Replication.
Configuration of Distributor
Before configuring any replications on your server, you need to configure your
distribution If no distribution is available when configuring publication, the
publication wizard will ask for relevant information to configure the distribution.
ExERCISE 9.1
C onfiguring D istributor
1 Launch Open SQL Server Management Studio from Program Files|
SQL Server 2008.
2 Supply the correct authentication for you to login to the
SQL Server in which you are going to configure the distribution
3 In the SQL Server Management Studio, navigate to Replication
node in the Object Explorer Right-click the Replication node
and select Configure Distribution in the context menu.
Trang 24 After the start page you will be taken to the screen shown in Figure 9.2 From this screen, you can decide where your distribution server is It can be either on the same database server instance where your publication is or on some other server that must already be configured as a distributor
Figure 9.2 Configuring Distributor Server
5 Configure the snapshot folder To support both push and pull subscriptions, use a network path to refer to this folder
6 Configure the distribution database Supply the database name, database data file path and name, and database log file path and name By default the database name is distribution
7 Next you can add who can use this distributor when they become publishers
Configuration of Publisher
After configuring distribution, the next step is to configure publisher, which is the major configuration in Replication Exercise 9.2 will help you create a publisher.
Trang 3ExERCISE 9.2
C onfiguring P ublisher
1 Launch Open SQL Server Management Studio from Program Files|
SQL Server 2008.
2 Supply the correct authentication for you to login to the SQL
Server in which you are going to configure the publisher
3 Navigate to Local Publication leaf under the Publication leaf and
right-click the Local Publication leaf Select New Publication….
4 After the starting screen, the next screen asks you to select the
database you want to publish All the user databases will be
listed, which means that you cannot replicate system databases
5 After selecting the database, select the Replication type you want
to implement, as seen in Figure 9.3
Figure 9.3 Selecting Publication Type
Trang 4Four replication types are shown and Peer-to-Peer Replication is missing here We will see how we can configure Peer-to-Peer Replication later When configuring replication, the most difficult part is to select which replication you want Figure 9.3 gives you a short description about each replication so that you can be sure before selecting a
replication type
In this example, we are going to configure Merge Replication, so we will select the last option
6 Next, you will be asked what the database versions are for subscribers This is Merge Replication specific configuration, and will not be seen for other replication configurations In Figure 9.4, you can see that Merge Replication supports SQL Server versions after 2000
Figure 9.4 Subscriber Types
Also, in SQL Server 2000, DDL replication is not supported
7 Another important configuration is to configure Articles As you can see in Figure 9.5, you have the luxury of replicating not only tables and views, but also stored procedures and user-defined functions as well
Trang 5SQL Server requires that all tables referenced by published views
and indexed views be available at the Subscriber If the referenced tables
are not published as articles in this publication, they must be created
at the Subscriber manually
In case of transactional replication you are not allowed to select
tables without primary keys to select as articles
8 The next screen is an issue screen of the previous selected articles
For example, in the case of Merge Replication, tables without
rowguid will be listed Also, if you have selected views and have
not selected referenced tables,which are referred by views again,
a warning will be raised here
9 The next screen lets you set filters (Figure 9.6) By clicking Add,
you can set filters You can create either static filters or dynamic
filters Static filters are straightforward; a simple where clause
filters data Dynamic filters filter which different subscribers
receive different portions of data For example, you may have
Figure 9.5 Publisher Articles