Replication--Alwayson+订阅
场景:
主服务器:SubServer1
从服务器:SubServer2
监听者:RepListener
分发库:DisServer
发布数据库:RepDB1
发布服务器:RepServer1
当failover发生后,订阅服务器应转变成SubServer2
实现步骤:
1>修改发布属性以允许从备份初始化订阅
2>查看订阅最后同步事务LSN
SELECT transaction_timestamp, * FROM MSreplication_subscriptions;
3>删除订阅EXEC sp_subscription_cleanup @publisher = 'RepServer1', @publisher_db = 'RepDB1'
4>使用LSN新建订阅
EXEC sp_addsubscription -- past the LSN before executing
@publication = 'tranPublicationTest',
@subscriber = 'Denali5',
@destination_db = 'subDB',
@subscription_Type = 'Push',
@sync_Type = 'initialize from LSN',
@subscriptionlsn = 0x00000023000000E60003000000000000, ----这个值就是我们在步骤2得到的transaction_timestamp
@article = 'all',
@update_mode = 'read only',
@subscriber_type = 0;