Central Subscriber Model Explained
原文 http://www.sqlrepl.com/sql-server/central-subscriber-model-explained/
The majority of SQL Server Replication topologies are based on the Central Publisher model, which is comprised of a single publisher replicating to one or more subscribers. Another replication model, which is sometimes overlooked, is the Central Subscriber model, which is comprised of multiple publishers replicating to one subscriber using Transactional Replication.

The Central Subscriber model is useful for rolling up or consolidating data from multiple sources. Some examples include:
- Rolling up inventory from several warehouses into a central server at corporate headquarters.
- Sending data from remote offices within a company to a central office for business continuity.
- Consolidating order information to one location for centralized ordering.
Priming the pump
By default, subscriptions are initialized from a snapshot generated by the Snapshot Agent and then applied by the Distribution Agent. When the snapshot is applied, by default the article property Action if name is in use is set to Drop existing object and create a new one, which instructs that the destination table be dropped if it already exists at a subscriber. This behavior can be problematic in the Central Subscriber model when snapshots are applied since snapshots must be applied from multiple publications. The first snapshot is applied as expected, however, subsequent snapshot applications result in the previous snapshot data being wiped out.
The solution to this problem is horizontal partitioning, static row filters, and setting the Action if name is in use article property to Delete data. If article has a row filter, delete only data that matches the filter.
Horizontal partitioning
Ideally, published tables in a Central Subscriber topology will be horizontally partitioned. In order to horizontally partition the tables to be published, a location-specific column should be added and included as a part of a composite primary key. Consider a table that looks like this:
CREATE TABLE TestTable |
To horizontally partition TestTable and prepare it for a Central Subscriber configuration at Publisher 1, drop primary key constraint PK_TestTable_ID, add a location-specific column named LocationID with a default value of 1, and add the new composite primary key including the LocationID column.
ALTER TABLE TestTable |
Next, to horizontally partition TestTable and prepare it for a Central Subscriber configuration at Publisher 2, the same preparation can be done with a default value of 2 for LocationID.
ALTER TABLE TestTable |
Finally, to horizontally partition TestTable and prepare it for a Central Subscriber configuration at Publisher 3, the same preparation can be done with a default value of 3 for LocationID.
ALTER TABLE TestTable |
Once the tables are horizontally partitioned, they can be properly published in a Central Subscriber topology by using static row filters, filtering on the LocationID column and setting the article property Action if name is in use to Delete data. If article has a row filter, delete only data that matches the filter.
Static row filters
For each article to be published in a Central Subscriber topology, a static row filter should be defined to leverage the Action if name is in usearticle property appropriately. A static row filter uses a WHERE clause to select the data to be published. To publish rows from Publisher 1, specify LocationID = 1 for the filter clause. Likewise, to publish rows from Publisher 2 and Publisher 3, specify LocationID = 2 and LocationID = 3 for the filter clause, respectively.

Action if name is in use
When creating the publications and adding articles, the article property Action if name is in use needs to be set to Delete data. If article has a row filter, delete only data that matches the filter. This can be set using the New Publication Wizard Article Properties dialog or by using replication stored procedures sp_addarticle and specifying a value of delete for the @pre_creation_cmd argument. This way, when the central subscriber is initialized or reinitialized from multiple publication snapshots, previously applied snapshot data will be preserved since only data matching the filter clause will be deleted.

The caveat
As we can see, horizontal partitioning requires that tables have a location-specific column added, however, the location-specific column does not necessarily need to be included as a part of the primary key at the publication databases. In addition, it is not a hard requirement that published tables in a Central Subscriber topology be horizontally partitioned. In some shops, changing a primary key or adding additional columns is strictly prohibited, in which case I would urge you to take an alternative approach. If you would like some ideas on implementing a Central Subscriber topology without modifying primary keys or horizontally partitioning publication databases, feel free to get in touch or leave a comment below.
Central Subscriber Model Explained的更多相关文章
- AMQP 0-9-1 Model Explained Why does the queue memory grow and shrink when publishing/consuming? AMQP和AMQP Protocol的是整体和部分的关系 RabbitMQ speaks multiple protocols.
AMQP 0-9-1 Model Explained — RabbitMQ http://next.rabbitmq.com/tutorials/amqp-concepts.html AMQP 0-9 ...
- [Windows Azure] Building the web role for the Windows Azure Email Service application - 3 of 5
Building the web role for the Windows Azure Email Service application - 3 of 5. This is the third tu ...
- [转]Design Pattern Interview Questions - Part 2
Interpeter , Iterator , Mediator , Memento and Observer design patterns. (I) what is Interpreter pat ...
- OpenStack 企业私有云的若干需求(10):OpenStack 的前景和钱景
本系列会介绍OpenStack 企业私有云的几个需求: 自动扩展(Auto-scaling)支持 多租户和租户隔离 (multi-tenancy and tenancy isolation) 混合云( ...
- Lock-Free 编程
文章索引 Lock-Free 编程是什么? Lock-Free 编程技术 读改写原子操作(Atomic Read-Modify-Write Operations) Compare-And-Swap 循 ...
- 关于 ActiveMQ 的消息模式
1.JMS Queue 执行 load balancer语义:一条消息仅能被一个 consumer(消费者) 收到.如果在 message 发送的时候没有可用的consumer,那么它将被保存一直到能 ...
- Mingyang.net:用注解校验数据
注解校验依赖的是javax.validation和hibernate-validaton. <dependency> <groupId>javax.validation< ...
- ActiveMQ使用总结
一.下载使用: 官网下载apache-activemq-5.8.0-bin.tar.gz.apache-activemq-5.8.0-bin.zip 解压,然后启动ActiveMQ服务器 方法1: 直 ...
- JMS理解2
使用JMS 的应用程序被称为JMS 客户端,处理消息路由与传递的消息系统被称为JMS Provider,而JMS 应用则是由多个JMS 客户端和一个JMS Provider 构成的业务系统.发送消息的 ...
随机推荐
- [React] Recompose: Override Styles & Elements Types in React
When we move from CSS to defining styles inside components we lose the ability to override styles wi ...
- .net core 下的分布式事务锁
原文:.net core 下的分布式事务锁 目录 系统分布式锁的用法 锁的实现 锁的使用 API内的范例: 引用链接 系统分布式锁的用法 公司框架新增功能分布式锁: 锁的性能之王: 缓存 > Z ...
- 创建数据库以及其属性的sql语句
创建数据库的SQL语句: create database stuDB on primary -- 默认就属于primary文件组,可省略 ( /*--数据文件的详细描写叙述--*/ name='stu ...
- 【BZOJ 1022】 [SHOI2008]小约翰的游戏John
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1022 [题意] [题解] 和这题类似http://blog.csdn.net/harl ...
- Springboot系列:@SpringBootApplication注解
在使用 Springboot 框架进行开发的时候,通常我们会在 main 函数上添加 @SpringBootApplication 注解,今天为大家解析一下 @SpringBootApplicatio ...
- Linux 增值服务中删除,自己主动和国家执行
CAMS 在自己主动参加相关的服务安装过程.在最后的安装过程中会提示用户是否启动该服务,这样的服务才能生效,需要注意的是一个服务并不意味着系统启动过程中被添加到该服务后,会自己主动执行,只可用于ser ...
- MyReport报表引擎2.2.0.0新功能
分组功能添加分组头,分组尾设计支持,支持按字段分组,排序 分组效果 排序效果 新增分组行号函数,用于分组内部独立行号显示 分组行号效果 新增平均函数,用于求平均值统计 支持四则优先运算(用中括号表示, ...
- ubuntu 下 caffe 的安装
官方下载说明:Caffe | Installation: Ubuntu 在 ubuntu 的一些较新版本中(14.04 以上),caffe 的所有依赖包都可以使用 apt-get 大法搞定. 1. 依 ...
- sql操作xml小总结
一.前言 SQL Server 2005 引入了一种称为 XML 的本机数据类型.用户可以创建这样的表,它在关系列之外还有一个或多个 XML 类型的列:此外,还允许带有变量和参数.为了更好地支持 XM ...
- jquer表单序列化加强版
相同name值会转化为一个数组 $.fn.serializeObject = function(){ var o = {}; var a = this.serializeArray(); $.each ...