SQL Server: Is Replication Recovery Model dependent ?

來源:互聯網
上載者:User

There is a myth that for replication to work properly the databases always have to be in Full recovery mode. Well that is not at all true.

First let me give a short overview on how replication works.

A snapshot agent creates a snapshot of the Publisher which is then taken up by the Distributor agent to apply any schema changes. Log reader agent then replicates transaction to the distributor after reading the log records which
are marked for a replication and the distributor agent replicates them over to the Subscriber.

So now when a checkpoint occurs it will skip those records which are marked for replication. Once the distributor agent traverses the records to the Subscriber the transaction which were before marked as "Marked for replication"
will be marked as "Replicated" by the log reader agent.

Now when the next checkpoint occurs these transactions will also be truncated. So it is not necessary that the recovery model always have to be in Full recovery model for all this to happen. As logging is done even in Simple recovery
mode and maintained until the next checkpoint occurs.

But you have to be careful when you are performing the following actions if your database is in simple recovery model and is part of replication as output of these actions will not be replicated

  • CREATE INDEX

  • TRUNCATE TABLE

  • BULK INSERT

  • BCP

  • SELECT. . .INTO

The reason ...Well the replication engine will not be able to pick up these changes as these changes will only log page allocations and de-allocations. You wont have to worry about the schema changes as these changes will be be
replicated though they are in simple recovery model.

So the ideal strategy of Recovery model for setting up a replication environment from my point of view would be

1) Publisher database be in Simple recovery mode.

2) Subscriber be in a Full recovery mode.

Some people might argue that if Publisher is set to Simple then tlog backup wont be possible.

Well tlog backup on the Publisher wont be of any use anyways in Full recovery model because log backup's wont cover the records until they are marked as "Marked or replication" i.e records which still haven't been replicated to
the Subscribers.

So it is better to have Subscriber in full recovery model and set up tlog backups over there which can save a lot of log space on the Publisher.

 

From:http://www.sqlservergeeks.com/blogs/Sachin.Nandanwar/sql-server-bi/135/sql-server-is-replication-recovery-model-dependent

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.