SQL Server AlwaysOn With LogShipping

Category: sql server migration

Question

VijayKSQL on Thu, 09 Aug 2018 21:25:30


We are planning to migrate all SQL Server 2008 R2 to SQL Server 2016.

Old environment:

SQL Server 2008 R2 with Log shipping 

New environment:

SQL Server 2016 With AlwaysOn (1 Primary+2 Secondary)

Now the new envrironment is ready with AG. the next step is to plan for curover with minimum downtime.

In order to achieve i am planning to configure Logshipping between Old and New environmnet.

In this scenerio how can i configure logshipping between. Once migrated we don't need Logshipping.

Replies

Xi Jin on Fri, 10 Aug 2018 02:12:27


Hi S.Vijay,

In your scenario, you are going to migrate SQL Server 2008 R2 to SQL Server 2016 with minimum downtime. So you choose log shipping to do the migration work. Right?

If so, it is able to do the log shipping between lower version SQL Server 2008 R2 to higher version SQL Server 2016. But the database should be set in "No recovery mode".

However you should know that after doing the log shipping, it is impossible to go back from SQL Server 2016 to SQL Server 2008 R2. Which means there will exist some potential risks.

Thereby, basically it is able to achieve your requirement with log shipping. However this is not a good option. 

Thanks,
Xi Jin.

VijayKSQL on Fri, 10 Aug 2018 16:08:15


Hi Xi,

In this case which is the good option?

Hilary Cotter on Fri, 10 Aug 2018 16:14:05


What Xi describes is the best option. You can simultaneously log ship to another SQL Server 2008 r2 server which will protect that instance in case you have a catastrophic failure and need to recover somewhere else. This way you can failover and failback from the 2 SQL 2008 r2 instances.

Mohsin_A_Khan on Fri, 10 Aug 2018 17:57:59



In order to achieve i am planning to configure Logshipping between Old and New environmnet.

In this scenerio how can i configure logshipping between. Once migrated we don't need Logshipping.

In other words, this is a one-time log shipping that's being used for migration purpose. You can follow the quick steps below for minimal downtime during the cut-over. 

1) Take FULL backups of all user DBs on old 2008 R2 instance and restore with NO RECOVERY on the new AG primary replica (SQL 2016).

2) Keep the new Primary replica updated by continuously restoring DIFF or T-log backups, again, with NO RECOVERY.

3) Migrate all the instance level objects that are outside the DB such as Logins, Jobs, Server Triggers, Proxy, credentials, operators, Linked Servers etc.

4) When it's time to cut over, take the DBs in single_user mode (on 2008 R2) and perform the last Log backup and restore on to the new server WITH RECOVERY. 

The above is log-shipping too, but not the one you would create using GUI etc. 

Once all DBs are restored on the new primary replica (SQL 2016), add them to the Availability Group and synch with the two secondary replicas. 

Hope this helps!

VijayKSQL on Fri, 10 Aug 2018 21:17:20


Hi Mohsin,

This is look good.

A small doubt. Currently we took the backup of Old SQL Server 2008 Db's and restored in SQL 2016 and configured AG. Now application team is test from application end. like HA and DR.

What my plan is once application testing is done, i will delete all DB's from 2016 and configure Logshipping for actual migration.

Does it looks good?

Mohsin_A_Khan on Fri, 10 Aug 2018 21:23:02



What my plan is once application testing is done, i will delete all DB's from 2016 and configure Logshipping for actual migration.

Does it looks good?

Yes, once testing goes well, remove all DBs from AG and drop them from all replicas and start fresh restores. 

Alternatively, you can leave the DBs as is and when you do the first FULL backup restore (for actual migration), you can check the option "Restore with Replace" to overwrite the existing DBs. It's really your choice.

VijayKSQL on Fri, 10 Aug 2018 22:07:12


Excellent!.

Need one more guidance, could you please provide monitoring setup for Alwayson.

We are not going to use any Third Party tools to monitor AG.

If you provide any script/any document, those are more helpful to us.

Mohsin_A_Khan on Fri, 10 Aug 2018 22:12:48



If you provide any script/any document, those are more helpful to us.

The following article has some great scripts that you can schedule from SQL agent job to run every x mins and send an email alert if latency exceeds the acceptable threshold etc.

https://www.sqlshack.com/measuring-availability-group-synchronization-lag/

There are other ways too, such as using Extended Events. As a matter of fact, When you configure AG, an event session is created by default. The above link should help you with what you're looking for.

VijayKSQL on Fri, 17 Aug 2018 20:54:30


We are planning to Migrate SQL Server from 2008 to 2016 using logshipping.

Logshipping is running on current SQL Server 2008 (1 Primary+4 Secondries).

As part of Migration i am planning to adde SQL Server 2016  as secondary to 2008 Logshipping to sync data.

In this case How to add SQL Server 2016 server to Logshipping as secondary?

so that we can minimize the cutover downtime;


Mohsin_A_Khan on Fri, 17 Aug 2018 23:18:59


You don't need to add 2016 as the secondary to your current log shipping setup. You can do the same thing outside the current log shipping setup. Copying my response from earlier thread.

  • In other words, this is a one-time log shipping that's being used for migration purpose. You can follow the quick steps below for minimal downtime during the cut-over. 

    1) Take FULL backups of all user DBs on old 2008 instance and restore with NO RECOVERY on the new SQL 2016.

    2) Keep the new 2012 DB updated by continuously restoring DIFF or T-log backups, again, with NO RECOVERY.

    3) Migrate all the instance level objects that are outside the DB such as Logins, Jobs, Server Triggers, Proxy, credentials, operators, Linked Servers etc.

    4) When it's time to cut over, take the DBs in single_user mode (on 2008) and perform the last Log backup and restore on to the new 2016 server WITH RECOVERY. 

    The above is log-shipping too, but not the one you would create using GUI etc. 

    Hope this helps!

Shanky_621 on Sat, 18 Aug 2018 06:52:19


How is this question different from one you already asked which you marked as answer. PLEASE dont just post for sake of posting, read what responses are posted. We take time to answer your question and when you repeatedly ask same question it defeats the purpose

VijayKSQL on Fri, 24 Aug 2018 15:57:31


Hi Mohsin,

I already started Step2

 2) Keep the new 2012 DB updated by continuously restoring DIFF or T-log backups, again, with NO RECOVERY.

If possible could you please provide any T-SQL script  which can dynamically restore TRN file instead of Manually. So that i will create a SQL JOB which can run every 1 Hr to restore TRN files.

Mohsin_A_Khan on Mon, 27 Aug 2018 22:04:03


Hi Mohsin,

I already started Step2

 2) Keep the new 2012 DB updated by continuously restoring DIFF or T-log backups, again, with NO RECOVERY.

If possible could you please provide any T-SQL script  which can dynamically restore TRN file instead of Manually. So that i will create a SQL JOB which can run every 1 Hr to restore TRN files.

Can you post this as a new thread, preferably in the T-SQL forum if you still need help with this? Not that I don't want to help or something, it's just that your question will have better visibility. Once you have posted it, I'll jump on to that thread.