Friday, February 22, 2008

Hey Standby Server ! Your (Transaction Log) Ship(ment) has arrived…!-(LOGSHIPPING)

Having SQL Server as a Database Solution to your enterprise applications, you may have a little chance of losing your valuable data, due to some failures, as SQL Server 2005 is having a lot of features for High-Availability and Disaster Recoverability.

One of such feature is LOG Shipping. Even though LOG Shipping is available from predecessors of SQL Server 2005, it is more robust with SQL Server 2005. In SQL Server 2000, logshipping is only available in Enterprise edition. In SQL 2005, it is available from Standard edition.

All you require a stand by server with a same SQL Server Configuration, and a tamper proof network connection between the production server and the standby server.

How LOGSHIPPING works….?

Before delving into LOGShipping, let us think over, how we were maintaining a stand by server for our failures?

Normally, we backup our Database in to a Device (either tape or a disk file) and move the backup to another server, and restore the backup there. In these situations, the down time of the Database will be more, depending upon the standby or warm server’s setup and how frequently we are doing this manualy. If the standby server is located near by the primary production server then the job will be done frequently. Suppose if the Standby Server is located in another part of the world, then what will happen!?

LOGShipping does all the steps described above in an automatic way. SQL Agent Service plays a vital role here.

A SQL Server Agent Job first takes the Backup of the Transaction log of the Database from the Primary Server (for which Logshipping is enabled) in a file and store it in a (specified) network shared path in a specified time interval. Then secondary server’s SQL Server Agent’s Job gets the files from the network shared path in the order that they were taken backup from primary Server Database and copy it in its file system and restore the transaction log to the standby server’s database. For this purpose, the network service account which is maintaining the SQL Server Agent Service in the Secondary server must have the Read Permission for the Network Shared Path.

Setting up a Logshipping in a Domain scenario , where the Primary Server and Standby Server are the members of the same Domain, it is advisable to use the same domain user account for the both Servers’ SQL Server Agent Service, so that no conflict will happen and give read /write permission for the network shared folder to that account. But in a no-domain scenario, to set up a log shipping, you have to adopt a tricky way. Create an user account with a same name and same password in both the Prinmary and the Secondary Server and make it member of SQL Server Agent Group and give full control over the Network Shared Path where Primary Server’s Database's Transaction Log Backup were stored.

Steps Involved in Logshipping.
1. Backup the primary database in to a device.
2. Restore the backup in the secondary Server with NORECOVERY option.
(Note: First time transport log manually. If your LOG file is too big in size, then, change the RECOVERY model of the DATABASE to Simple and take the Backup. It will reduce the size of your log. After taking the backup change the recovery model to FULL, because, you can set up logshipping for the Database with FULL recovery model. Following steps are handled by the scheduled jobs.)
3. Backup the Transaction Log of the Primary Database.
4. Copy the Transaction Log to Secondary Database.
5. Apply the Transaction Log To Secondary Database.
Steps to be followed in Failover
1. Backup the last transactions after the last schedule of LOGShipping from the Primary (fault) sever, if possible.
2. Apply to the secondary database.
3. Synchronize the user related to the database in the secondary server.
4. Reconfigure the server as Production Server.
PROS & CONS of LOGShipping
Pros are :
o Easy to implement.
o Easy to maintain.
o It is more reliable.
o Multiple standby servers can be configured.
o Stand by Server Database can be used for reporting purposed to minimizing the workloads of the primary server.

Here are some cons too…
o No automatic failover (The Database Mirroring, an another feature of SQL Server 2005, supports automatic failovers.)
o Manual failover requires a technocrat during failover.
o At least a minimum data loss depending upon how frequently your logs are being shipped.

Some last considerations….

All the steps in LOGShipping involves SQL Server Jobs, all that jobs are executed in a frequency of time, and the failover is manual (main drawback of LOGShipping) so keep the frequency of logshipping in a low time interval to minimize the amount of data loss during failover.

Give some special consideration for synchronizing the user logins in both servers (primary and secondary) for failover situations, so that you can switch the standby server as a production server to all of your client applications by simply changing the name or IP or both, and keep trouble-shooting the faulty server. If you succeeded in troubleshooting, you can make this server as standby server and started log shipping from the production server. Synchronizing users in secondary server may cause SID conflicts. So do it carefully.

If you have enough infrastructure, then it is recommended to have another server as Monitoring Server which involves the LOGShipping operation, and track status and statistics of LOGShipping.

After setting up LOGShipping, you can monitor the operations, through three tools available in SQL Server 2005.
1. TRANSACTION LOG SHIPPING STATUS REPORT - an built-in Report available in SSMS Standard reports.
2. SQL Server LOG files
3. SQL Server Agent’s Job History.

For further studies:

1. Read Chapter 27:LOGShipping and Database Mirroring , from the book ‘MICROSOFT SQL SERVER 2005 – Administrator’s Companion’ by Edward Whalen, Marcilina Gracia and others - MS PRESS.
2. Refer Books Online.

17 comments:

Anonymous said...

Hi Buddy,

Thanks so much for this post. I had been scratching my head for the longest time trying to figure out how to resolve the permissions issues that come up when you attempt to implement Log shipping in a workgroup environment. The conventional wisdom is that it is sufficient to have two accounts with the same password on the primary server and the secondary server and have the sql server agent service run under that account. This of course never freakin works and the reason is because the aforementioned user has to be in the sql server agent local user group Brilliant my man! Brilliant! :-)

Esakkiappan Barathan said...

Credit goes to some SQL Groups in srilanka They gave this idea

koteswar Rao said...

Hi,

The article is nice and very much help to me for logshipping admin..

I need one clarification,the primary server damaged i.e is unavailable to take the active transaction log backup(tail-log backup),i think there is change of data loss,

Is iam right?if wrong plz let me know.

Regards
Koteswar Rao

koteswar Rao said...

Hi,

The article is nice and very much help to me for logshipping admin..

I need one clarification,the primary server damaged i.e is unavailable to take the active transaction log backup(tail-log backup),i think there is chance of data loss,

Is iam right?if wrong plz let me know.

Buy Cialis said...

I think that it is so important,SQL is a great help to many companies and many people around the world!!

www.vbarcelone.com said...

In my view one and all may read this.

Anonymous said...

Wow, fantastic blog layout! How long have you been running a
blog for? you made blogging look easy. The full look
of your site is fantastic, let alone the content!

Visit my web site ... microsoft email templates

Anonymous said...

I am curious to find out what blog platform you happen
to be using? I'm experiencing some small security problems with my latest site and I would like to find something more safeguarded. Do you have any solutions?

Also visit my web page - mailchimp email templates

Anonymous said...

At this time it sounds like Wordpress is the best blogging platform out there right
now. (from what I've read) Is that what you're using on your blog?


Visit my site: business email templates

Anonymous said...

Wonderful, what a blog it is! This webpage provides helpful data to us, keep it up.


Also visit my homepage conceiving a boy ()

Anonymous said...

Very good information. Lucky me I ran across your site by
chance (stumbleupon). I've saved as a favorite for later!

Feel free to surf to my blog ... http://www.ezinearticles.gr/Perfectly-Practical-Free-Email-Templates-Tricks-And-Tips.htm

Anonymous said...

I am really impressed together with your writing skills
and also with the format on your blog. Is that this a
paid topic or did you customize it yourself?
Anyway keep up the nice quality writing, it's uncommon to see a nice blog like this one nowadays..

my blog cheap hdmi cables

Anonymous said...

Have you ever considered writing an e-book
or guest authoring on other sites? I have a blog based upon on the same
subjects you discuss and would love to have you share some stories/information.
I know my subscribers would value your work. If you are even
remotely interested, feel free to send me an e-mail.


Feel free to visit my web page ... keyword

Anonymous said...

You can certainly see your skills in the article you write.

The world hopes for more passionate writers like you who aren't afraid to mention how they believe. Always go after your heart.

my website - email marketing script

Anonymous said...

Hi there, this weekend is fastidious in support of me,
for the reason that this time i am reading this great educational paragraph here at my residence.


My blog post :: beautifulemails.com

Anonymous said...

Wow, that's what I was looking for, what a stuff! existing here at this weblog, thanks admin of this web site.

my webpage ... Email Wedding Invitation Templates

Anonymous said...

Hi, always i used to check web site posts here early in the morning, as i like to find out more and
more.

Also visit my webpage; Similar Site