獨立與共用的代理程式

SQL Server 線上說明:

ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.zh-CHT/s10rp_4deptrbl/html/f27186b8-b1b2-4da0-8b2b-91f632c2ab7e.htm

獨立代理程式即服務一個訂閱的代理程式。共用的代理程式會服務多個訂閱;如果使用相同共用代理程式的多個訂閱需要同步,依預設,它們會在佇列中等候,該共用代理程式會一次服務其中之一。使用獨立代理程式會降低延遲,因為代理程式會在訂閱需要同步時就緒。合併式複寫通常使用獨立代理程式,依預設,交易式複寫會使用在「新增發行集精靈」中建立的發行集之獨立代理程式 (在舊版 SQL Server 中,依預設,交易式複寫則使用共用代理程式)。

sp_replicationdboption

independent_agentnvarchar(5),預設值是 FALSE。如果是 true,就表示這個發行集有獨立的散發代理程式。如果是 false,發行集會使用共用散發代理程式,每一組發行者資料庫/訂閱者資料庫都有單一共用代理程式

所以,所以不同 Subscriber DB 就會不同的 Agent 了😦

測試:

use [Northwind]
exec sp_replicationdboption @dbname = N’Northwind’, @optname = N’publish’, @value = N’true’
GO
–決定是否要採用獨立的散發代理程式
declare @independent nvarchar(5)=N’false’

— 正在加入交易式發行集
–如果將發行集的 ‘immediate_sync’ 屬性設定為 True,也必須將 ‘independent_agent’ 屬性設定為 True。發行集的 ‘allow_anonymous’ 屬性和 ‘immediate_sync’ 屬性相依。
use [Northwind]
exec sp_addpublication @publication = N’NwindCustomers’,
@description = N’來自發行者 “NBI7″ 的資料庫 “Northwind" 交易式發行集。’,
@sync_method = N’concurrent’, @retention = 0, @allow_push = N’true’, @allow_pull = N’true’,
@enabled_for_internet = N’false’, @snapshot_in_defaultfolder = N’true’,
@compress_snapshot = N’false’, @ftp_port = 21, @allow_subscription_copy = N’false’, @add_to_active_directory = N’false’,
@repl_freq = N’continuous’, @status = N’active’,
@independent_agent = @independent, @immediate_sync = @independent, @allow_anonymous = @independent,
@allow_sync_tran = N’false’, @allow_queued_tran = N’false’, @allow_dts = N’false’, @replicate_ddl = 1,
@allow_initialize_from_backup = N’false’, @enabled_for_p2p = N’false’, @enabled_for_het_sub = N’false’

exec sp_addpublication_snapshot @publication = N’NwindCustomers’, @frequency_type = 1, @frequency_interval = 1,
@frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8, @frequency_subday_interval = 1,
@active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0,
@job_login = null, @job_password = null, @publisher_security_mode = 1

exec sp_addarticle @publication = N’NwindCustomers’, @article = N’Customers’, @source_owner = N’dbo’,
@source_object = N’Customers’, @type = N’logbased’, @description = null, @creation_script = null,
@pre_creation_cmd = N’drop’, @schema_option = 0x000000000803509F, @identityrangemanagementoption = N’manual’,
@destination_table = N’Customers’, @destination_owner = N’dbo’, @vertical_partition = N’false’,
@ins_cmd = N’CALL sp_MSins_dboCustomers’, @del_cmd = N’CALL sp_MSdel_dboCustomers’, @upd_cmd = N’SCALL sp_MSupd_dboCustomers’

— 正在加入交易式發行集
exec sp_addpublication @publication = N’NwindCategory’, @description = N’來自發行者 “NBI7″ 的資料庫 “Northwind" 交易式發行集。’,
@sync_method = N’concurrent’, @retention = 0, @allow_push = N’true’, @allow_pull = N’true’,
@enabled_for_internet = N’false’, @snapshot_in_defaultfolder = N’true’, @compress_snapshot = N’false’, @ftp_port = 21,
@allow_subscription_copy = N’false’, @add_to_active_directory = N’false’, @repl_freq = N’continuous’, @status = N’active’,
@independent_agent = @independent, @immediate_sync = @independent,  @allow_anonymous = @independent,
@allow_sync_tran = N’false’, @allow_queued_tran = N’false’,
@allow_dts = N’false’, @replicate_ddl = 1, @allow_initialize_from_backup = N’false’, @enabled_for_p2p = N’false’, @enabled_for_het_sub = N’false’
GO

exec sp_addpublication_snapshot @publication = N’NwindCategory’, @frequency_type = 1, @frequency_interval = 1,
@frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 8, @frequency_subday_interval = 1,
@active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = null,
@job_password = null, @publisher_security_mode = 1

use [Northwind]
exec sp_addarticle @publication = N’NwindCategory’, @article = N’Categories’, @source_owner = N’dbo’, @source_object = N’Categories’,
@type = N’logbased’, @description = null, @creation_script = null, @pre_creation_cmd = N’drop’, @schema_option = 0x000000000803509F,
@identityrangemanagementoption = N’manual’, @destination_table = N’Categories’, @destination_owner = N’dbo’, @vertical_partition = N’false’,
@ins_cmd = N’CALL sp_MSins_dboCategories’, @del_cmd = N’CALL sp_MSdel_dboCategories’, @upd_cmd = N’SCALL sp_MSupd_dboCategories’
GO

–加入訂閱
use [Northwind]
exec sp_addsubscription @publication = N’NwindCustomers’, @subscriber = N’NBI7′, @destination_db = N’test’,
@subscription_type = N’Push’, @sync_type = N’automatic’, @article = N’all’, @update_mode = N’read only’, @subscriber_type = 0
exec sp_addpushsubscription_agent @publication = N’NwindCustomers’, @subscriber = N’NBI7′, @subscriber_db = N’test’,
@job_login = null, @job_password = null, @subscriber_security_mode = 1, @frequency_type = 64, @frequency_interval = 0,
@frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 0, @frequency_subday_interval = 0,
@active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 20110531, @active_end_date = 99991231,
@enabled_for_syncmgr = N’False’, @dts_package_location = N’Distributor’

exec sp_addsubscription @publication = N’NwindCategory’, @subscriber = N’NBI7′, @destination_db = N’test’,
@subscription_type = N’Push’, @sync_type = N’automatic’, @article = N’all’, @update_mode = N’read only’, @subscriber_type = 0
exec sp_addpushsubscription_agent @publication = N’NwindCategory’, @subscriber = N’NBI7′, @subscriber_db = N’test’,
@job_login = null, @job_password = null, @subscriber_security_mode = 1, @frequency_type = 64, @frequency_interval = 0,
@frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 0, @frequency_subday_interval = 0,
@active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 20110531, @active_end_date = 99991231,
@enabled_for_syncmgr = N’False’, @dts_package_location = N’Distributor’

image

/* 清除物件
use [Northwind]
exec sp_dropsubscription @publication = N’NwindCustomers’, @subscriber = N’NBI7′, @destination_db = N’test’, @article = N’all’
exec sp_dropsubscription @publication = N’NwindCategory’, @subscriber = N’NBI7′, @destination_db = N’test’, @article = N’all’

exec sp_droppublication @publication = N’NwindCustomers’
exec sp_droppublication @publication = N’NwindCategory’
exec sp_replicationdboption @dbname = N’Northwind’, @optname = N’publish’, @value = N’false’
*/

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: