Module 07 Log Shipping
Agenda Log Shipping Overview SQL Server Log Shipping Log Shipping Failover 2
Agenda Log Shipping Overview SQL Server Log Shipping Log Shipping Failover 3
Log Shipping Overview Definition Purpose Log Shipping Operations Log Shipping Mechanisms Considerations Transaction Log Chain
Definition Log shipping is an automated method of maintaining a warm standby server Based on SQL Server's log backup and restore architecture It is relatively low-tech and inexpensive: Available in all SQL Server Editions except Express and SQL Everywhere (Mobile) Log Shipping can be custom coded in T-SQL
Purpose Log shipping aims to automate the maintenance of a warm standby server It 'ships' (copies and restores) a production server's transaction logs to a standby server The standby is usually a second database server that is ready to take the place of the production server if it fails. The shipped-to server is often called a 'warm' standby If the standby server's copy of the production database is kept current within minutes
Log Shipping Basics Primary DB (recovered) Full Backup Secondary DB Secondary DB (unrecovered) TL Backup TL Backup End
Log Shipping Operations Initialize a secondary server database from a backup With STANDBY or NORECOVERY Start a series of transaction log backups to disk Copy the disk files to the secondary server Restore the log files to the secondary database in sequence With STANDBY or NORECOVERY
Considerations You can ship from one primary to many secondary databases By default failover is manual only You can add custom code for a controlled failover You can set up alerts for detecting backup, copy or load failures
Transaction Log Chain Log shipping depends on maintaining a continuous log sequence a transaction log chain Transactions are numbered with LSNs (Log Sequence Numbers) A freshly restored database has a maximum LSN in its log The very next backup must begin its LSN at that or an earlier value Each log backup file contains a discrete set of ascending LSNs The next log backup begins right after the maximum value of the previous log backup When restoring a series of transaction log backup files: The transaction log sequence of LSNs must remain unbroken Don t break the chain of log backup files
Agenda Log Shipping Overview SQL Server Log Shipping Log Shipping Failover 11
Basic Features of SQL Server Log Shipping Uses tables and stored procedures in the msdb database Each server s msdb contains a complete set Invokes the executable sqllogship.exe for some operations Provides GUI support for setup and monitoring Supports an optional monitor server
Requirements Must have any edition of SQL Server except Express and Everywhere Ensure that the primary database to be log shipped is in the FULL or BULK-LOGGED recovery model The SIMPLE recovery model does not permit transaction log backups, so it is not compatible with log shipping Ensure that all servers have the same serverlevel collations Especially if they are meant as standby servers
Planning Identify the participants Primary database and server Secondary databases and servers Optional monitor server Create a file share to hold the transaction log backup files Preferably on the primary server locally Optionally on a shared location Decide on a transaction log backup schedule The secondary will be average twice the backup interval out of date Create a folder on each secondary server for copies of log backup files
Initializing the Secondary Manual Initialization Take a full database backup of the primary database to disk Restore that backup to the secondary server(s) without recovery Automatic Initialization Use the Management Studio interface. For larger systems, you should use a manual method of initialization. May require transport to a remote site May require that backups occur within a certain time interval
Enabling Log Shipping From Management Studio Use the Properties dialog of the primary database to initialize log shipping Optionally use the dialogs to initialize the secondary database from a database backup
Testing Log Shipping Use Windows Explorer to observe flow of transaction log files Make changes to the primary database and ensure they propagate to the secondary databases Requires restoring using STANDBY to query
Monitoring Log Shipping The log shipping monitor server is a third location that can monitor multiple log shipping pairs Use the Log Shipping Status Report in Management Studio for graphical viewing
Agenda Log Shipping Overview SQL Server Log Shipping Log Shipping Failover 19
Log Shipping Failover Types of Failover Bringing the Secondary Database Online Swapping Roles
Types of Failover Uncontrolled A sudden loss of the primary database or server requires that the secondary database come into service Controlled Both servers are intact but you wish to change the direction of log shipping.
Bringing the Secondary Database Online If the primary server becomes unavailable Disable or remove the log shipping jobs on the secondary server Recover the secondary database After recovery, you must manually ensure that Logins and permissions are synchronized Required jobs and support objects in other databases are in place The application can connect to the new server
Swapping Roles Stop all transactions on the primary database or wait for them to complete Disable the transaction log backup job on the primary Wait for all files to be copied and loaded on the secondary Take one last transaction log backup of the primary database Without recovery, leaving it unrecovered Not the same as the 'tail of the log' Apply that last log backup to the secondary database With recovery, so that it is now ready for activity Establish log shipping in the opposite direction
Review Log Shipping Overview SQL Server Log Shipping Log Shipping Failover 24
Question rdyess@solidq.com
Module 7 Demo Configuring and Failing Over Log Shipping