Professional Documents
Culture Documents
Abstract
The Log Shipping feature that is included in Microsoft® SQL Server 2000 Enterprise Edition
is an automated process that sends transaction logs from one server to another. You can
use Log Shipping to create a warm standby server for your production server. This white
paper is for Database Administrators who have never used Log Shipping before and are
interested in exploring Log Shipping as a strategy for disaster recovery. This white paper
outlines the following:
• The steps to configure Log Shipping between two or more servers that are running
SQL Server 2000 Enterprise Edition.
• The steps to configure Log Shipping between Microsoft SQL Server 7.0 Service Pack
2 (SP2), or later, and Microsoft SQL Server 2000 Enterprise Edition.
• A brief comparison between Log Shipping and the other high availability-solutions
that SQL Server provides.
The information contained in this document represents the current view of Microsoft Corporation on the issues
discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it
should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the
accuracy of any information presented after the date of publication.
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR
IMPLIED, AS TO THE INFORMATION IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for
any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights
covering subject matter in this document. Except as expressly provided in any written license agreement from
Microsoft, the furnishing of this document does not give you any license to these patents, trademarks,
copyrights, or other intellectual property.
The example companies, organizations, products, people and events depicted herein are fictitious. No
association with any real company, organization, product, person or event is intended or should be inferred.
CONTENTS..................................................................................................................3
INTRODUCTION...........................................................................................................1
COMMON TERMS.........................................................................................................2
HOW TO SET UP LOG SHIPPING BETWEEN SQL SERVER 7.0 SERVICE PACK 2, OR LATER,
AND SQL SERVER 2000.............................................................................................31
The Log Shipping feature is only available in the Enterprise Edition of SQL Server
2000.
Monitor Server
Figure 1
• Monitor server: This server is used to monitor Log Shipping. The monitor
server contains all relevant information regarding the status of Log Shipping.
• Transfer Logins Task: You can use this Data Transformation Services (DTS)
task to transfer logins from the source server to the destination server.
Microsoft recommends that you not use the same server as both the monitor
server and the source server because the monitor server maintains critical
information regarding the Log Shipping system. This critical information is lost if
the primary server stops working. Also, because the monitoring activity adds
some server overhead, keep the monitor server separate to yield better
performance. Like all other SQL Server servers, the monitor server must be
backed up regularly. For example, although not recommended, you can configure
the source and destination servers to be the same physical computer with
multiple instances.
• The login that you use to start the MSSQLServer and SQLServerAgent
services must have administrative access to the Log Shipping plan jobs,
the source server, and the destination server.
• Use SQL Server Enterprise Manager on the primary server to register all
the servers that will participate in Log Shipping.
• The database that you set up for Log Shipping must use
either the bulk-logged or full recovery model. A database that uses the
simple recovery model cannot be log shipped because the simple
recovery model does not allow transaction log backups.
\\primary_computername\sharename
If you use a directory that is different from the default backup location, you
must share that directory so that it can be accessed by the Log Shipping jobs.
See the Specify Transaction Log Backup Disk Directory dialog box in
Figure 2.
If you select Use this directory, and then specify the F:\BACKUP folder, the
F:\BACKUP folder must be shared.
You can set up Log Shipping between SQL Server 2000 servers by using the
Database Maintenance Plan Wizard. To access the Database Maintenance Plan
Wizard, open SQL Server Enterprise Manager, and then click Database
Maintenance Planner on the Tools menu. Use these steps to set up Log
Shipping:
2. Select the name of the database that you want to log ship.
Figure 3
NOTE: To set up Log Shipping, you must configure each database separately. If
you select multiple databases, you cannot set up Log Shipping. If you have
selected only one database and cannot select the Ship the transaction logs to
other SQL Servers (log shipping) check box, make sure that the database is
using the Full Recovery model.
The configuration of Log Shipping starts with the Specify the Transaction
Log Share dialog box shown in Figure 4.
3. In the Specify the Transaction Log Share dialog box, enter the share
name on the primary server (for example,
\\primary_computername\sharename) where the transaction log backups will
be stored. (This is the same share that you specified in the Preparing To Set
Up Log Shipping section.)
Figure 4
Figure 5
Option Description
Server Name Select the secondary server from the drop-down list box.
The server must be registered in the SQL Server Enterprise
Manager before you start the Database Maintenance Plan
Wizard.
Transaction
Log
Select the destination directory on the secondary server
Destination
where transaction logs will be copied and subsequently
Directory
restored.
Create and Create a new database on the secondary server with the
initialize new same name as the database on the primary server. You can
database use an existing database backup or create a new one at the
end of the Database Maintenance Plan Wizard.
Use existing
database
The database already exists on the secondary server.
Standby mode The database remains in Standby mode, and the users
have read–only access.
Allow database When this option is enabled, this secondary server becomes
to assume the primary server if there are any problems on the original
primary role primary server. If you select this option, you must provide
a share where the transaction logs are stored when the
server assumes the role of a primary server (for example,
(\\secondary_computername\sharename).
Figure 6
NOTE: If you choose to use an existing backup, the system only lists the
backup on the current primary server. When you use an existing backup, the
file must reside in a directory other than the one you are using to store the
Log Shipping backup.
Although you can specify a UNC path to back up the database, Microsoft does
not recommend this because it adds the overhead of copying the database
backup files to the primary server before they are copied to the secondary
server during the final phase of configuration.
Figure 7
The following table provides more information about the Log Shipping
Schedules dialog box.
Option Description
Backup schedule This option sets the frequency that the transaction logs
are backed up on the primary server.
Copy/load This option sets the frequency that the transaction logs
frequency are copied from the primary server to the secondary
server, and then loaded on the secondary server. If Load
delay is 0, zero (0) is also the frequency with which the
transaction logs are restored.
Load delay This is the length of time that the secondary server waits
before loading logs after the file is copied to the secondary
server. The default for this option is zero (0) minutes,
which indicates that the secondary server should
immediately restore any transaction log backups after they
are copied. In situations where there is a problem on the
primary server, a time delay allows the user to try and
correct the problem before the problem log is restored
onto the secondary server.
File retention period The length of time that the transaction logs are retained
on the secondary server before they are deleted.
Figure 8
Option Description
Out of sync alert This is the maximum elapsed time between the last
transaction log backup on the primary server and the last
transaction log restore on the secondary server.
NOTE: The default numbers that are provided for the preceding dialog box
are based on the frequencies that you selected in step 6.
Figure 9
The next two dialog boxes are a part of the Database Maintenance Plan
Wizard:
• Reports to Generate
-and-
Figure 10
NOTE: If you are configuring Log Shipping for a large database, this process
may take a considerable amount of time. The average time is approximately
12 seconds for an 8-megabyte (MB) database with a single processor [PIII-
500] computer that is using only one secondary server.
Figure 11
A log shipping pair is assigned for each secondary server per database. For
example, if use Log Shipping to send a database from a primary server to a
secondary server, there is one log shipping pair. If you use Log Shipping to send
two databases from a primary server to a secondary server, there are two log
shipping pairs.
You can use the Log Shipping Monitor to check the status of Log Shipping and to
edit specific information that pertains to the primary and secondary server. For
each log shipping pair, the Log Shipping Monitor shows the time of Last Backup,
Backup Threshold, time of Last Copy, time of Last Restore, Sync
Threshold, Alerts Enabled, and Status. When the log shipping pair is not
synchronized, the icon displays an “X.” The log shipping pairs do not auto-
refresh. Therefore, you must manually refresh SQL Server Enterprise Manager to
obtain the current status.
Option Description
Table Description
Additionally, two more jobs are created on the secondary server for copying and
loading the transaction log. The entries for these jobs are made in the
msdb..sysjobs system table. If you have a backup primary server, there is a
transaction log backup job, but it is disabled until you execute a role change.
Figure 12
NOTE: If you do not know which Database Maintenance Plan is being used by
Log Shipping, run the following SQL statement from the SQL Server Query
Analyzer:
FROM msdb..sysdbmaintplans as a,
msdb..log_shipping_databases as b
Option Description
Delete If this is the only log shipping pair, Log Shipping is completely
removed. Otherwise, only that specific log shipping pair is deleted.
Edit Edit the properties of an existing secondary server. You can edit all of
the options that you originally configured during the creation of the
Database Maintenance Plan.
If you click Edit, the Edit Destination Database dialog box appears.
Figure 14
• General
• Initialize
• Threshold
Figure 15
The Edit Destination Database dialog box is the only place where you can
make changes to the History Retention Period, which is used to determine how
much information is retained in the Log_shipping_plan_history table on the
secondary server.
Figure 18
Figure 19
If you click Remove Log Shipping to remove Log Shipping for this database,
the corresponding log shipping pair is also deleted. If this is the only pair, Log
Shipping is completely removed.
Figure 20
For the preceding job, create a job schedule so that it runs once or on a
recurring basis. Microsoft recommends that the job run as close as
possible to the time of the role change, so that the job gets the most
current login information from the primary server.
3. Run the following stored procedure on the instance of SQL Server that
is marked as the current primary server:
Exec msdb..sp_change_primary_role
@db_name sysname,
@backup_log BIT = 1,
@terminate BIT = 0,
@final_state SMALLINT = 1,
@access_level SMALLINT = 1
2 = No Recovery
3 = Stand by (Recommended)
3 = Single user
4. Run the following stored procedure on the instance of SQL Server that
is marked as the current secondary server (the future primary server):
Exec msdb..sp_change_secondary_role
@db_name sysname,
@do_load BIT = 1,
@force_load BIT = 1,
@final_state SMALLINT = 1,
@access_level SMALLINT = 1,
@terminate BIT = 1,
@keep_replication BIT = 0,
2 = No Recovery
3 = Standby
2 = DBO
3 = Single User
1 = Terminate user.
1 = True
exec msdb..sp_change_monitor_role
@primary_server sysname,
@secondary_server sysname,
@database sysname,
6. Run the following stored procedure on the instance of SQL Server that
is marked as the new primary server (the old secondary server):
The former secondary server now functions as the current primary server. The
former primary server is no longer part of a log shipping pair. You can add the
former primary server to the new primary server as a secondary server if you
want to establish a log shipping pair between the two databases.
If you set the pending upgrade option to TRUE while a clustered index is being
created, and there are no existing non-clustered indexes, the index creation
succeeds. However, if non-clustered indexes already exist when the creation of a
clustered index is initiated, and the pending upgrade option is set to TRUE
while the index creation takes place, the index creation may fail, rolling back the
entire operation. The pending upgrade option must always be set to FALSE for
any SQL Server 7.0 system that is not inter-operating with SQL Server 2000.
In addition to the restrictions on SQL Server 7.0, you must consider the following
when you set up Log Shipping:
To set up Log Shipping between SQL Server 7.0 Service Pack 2 (primary) and
SQL Server 2000 (secondary), use these steps:
1. On the primary server, set the pending upgrade option to TRUE for the
database that will be log shipped:
4. Restore the database on the secondary server with the No Recovery mode.
Parameter Description
Parameter Description
@plan_id
This is the ID or name of the plan that
-or-
wascreated in step 5.
@plan_name
NOTE: You should see two jobs created in the msdb..sysjobs system table:
• One for copying the transaction logs from the primary server to the
secondary server.
-and-
• One to restore the transaction logs on the secondary server.
You can only monitor Log Shipping by viewing the job history for copy or restore
jobs. You cannot set up the Log Shipping Monitor to monitor Log Shipping
between SQL Sever 7.0 Service Pack 2 and SQL Server 2000.
You can modify the log shipping information for existing secondary servers. You
can add new secondary servers, or add existing ones that have been deleted. Use
the commands in the following table to perform these operations.
Command Description
For more information about the parameters that are required for each of
these commands, refer to Microsoft SQL Server 2000 Books Online.
If you want to upgrade the secondary server to a primary server, perform these
steps:
It is beneficial to create a recurring job to bcp out syslogins and copy the output
file to the secondary server, which is to be used to synchronize the logins when
the secondary server is upgraded to a primary server. The steps for this are
outlined in the Primary Role Change section of this white paper.
High-Availability Solutions
Failover Clustering
You can use replication as a high-availability solution even though that is not
its intended purpose. The database administrator must take extra care to
transfer the metadata changes that are not otherwise replicated. Moreover,
replication does not synchronize all the objects in the database, unless
explicitly requested. Replication works well for read-only data. For example, it
may be a good idea to replicate a copy of your production database to
another server for reporting purposes, but it involves a lot of work to upgrade
the reporting server to a production server, if and when the need arises.
Log Shipping
How much work can you afford to lose? In some situations, the end
of the current transaction log may not be recoverable, for example,
due to a disk failure. If a disk failure occurs, you are only able to
recover the database up to the last valid transaction log backup,
which means that your users may have to redo some of the work
that was already performed on the primary server. Is this acceptable
in your environment?
For added fault-tolerance, you can combine log shipping with replication and/or
failover clustering to overcome the potential disadvantages that these solutions
bring when they are implemented separately.
• For the latest information about Microsoft SQL Server 2000, refer to the
following resources at:
http://www.microsoft.com/technet/showcase/itops/availsql.asp