Escolar Documentos
Profissional Documentos
Cultura Documentos
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR
STATUTORY, 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.
Microsoft, SharePoint, SQL Server, and Windows are either registered trademarks or trademarks of Microsoft
Corporation in the United States and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
Table of Contents
Using SQL Server Database Mirroring with Office SharePoint® Server and
Windows® SharePoint Services..................................................................................1
Table of Contents....................................................................................................... 3
Overview.................................................................................................................... 1
Prerequisites ...........................................................................................................9
Setup Steps........................................................................................................... 10
Types of Failover...................................................................................................16
Monitor mirroring...............................................................................................19
Additional References...............................................................................................22
Overview
This paper describes how you can use synchronous database mirroring to increase
the availability of SharePoint Products and Technologies farms, including farms
running Microsoft Office SharePoint® Server 2007, Microsoft Windows® SharePoint
Services, Microsoft Office Forms Server 2007, and Microsoft Search Server 2008.
Note: Database mirroring is not supported for Microsoft Office Project Server 2007.
To see a case study of how mirroring has been implemented, see Case Study:
Creating a Highly Available Microsoft Office SharePoint Server Environment by using
Microsoft SQL Server 2005 Database Mirroring (http://go.microsoft.com/fwlink/?
LinkID=117905&clcid=0x409).
1
• High-safety or high-protection This operating mode allows you to
synchronize writing transaction logs to both servers. Transactions are marked
complete after the mirror server confirms that the log has been written. Failover
is manual.
Note: Mirroring within a farm provides database availability only—that is, when
databases fail over, we assume that your front-end Web servers remain
available.
2
Figure 1 Mirroring within a farm
High
availabilty
mirroring
Principal instance Mirror instance
Index and application server
Content Content
SSP SSP
Configuration Configuration
In these farms, you can provide redundancy for the databases by using synchronous
mirroring. Within a stretched farm, you can mirror both the configuration and
content databases. For a case study of how one company used a stretched
datacenter, see White paper: Case Study of High Availability for SharePoint using
Database Mirroring (http://go.microsoft.com/fwlink/?LinkId=122045&clcid=0x409).
3
Mirroring across farms in separate data centers
In an environment in which you have farms in separate datacenters, you can use
asynchronous mirroring to provide redundancy for content databases. You can also
use asynchronous mirroring to provide redundancy for SSP databases if you are not
running search in your SSP.
• SSP databases when the SSP is running search. Search requires complete
synchronization between the search database, SSP database, and index. The
index file cannot be mirrored.
In the cross-farm scenario, we recommend that you perform one of the following
to recover search:
• Back up search by using the backup and recovery tools built in to SharePoint
Products and Technologies, and restore it to the secondary environment on
failover. A full crawl will be started.
• Rebuild search.
We recommend that you use the tools in SharePoint Products and Technologies
to back up and restore search databases. The following figure shows how
mirroring can be configured to provide high availability between farms.
4
Primary Server Farm Secondary Server Farm
W eb, query and application server W eb, query and application server
W eb, query and application server W eb, query and application server
High safety
or
High performance
mirroring
Index and application server Principal instance Mirror instance Index and application server
Content C ontent
SSP SSP
W SS search W SS search
mirroring within a farm. For more information about overall availability for
SharePoint Products and Technologies, see Plan for redundancy (Office
SharePoint Server) (http://go.microsoft.com/fwlink/?LinkId=98720) on the
Microsoft TechNet Web site.
5
• Certificates
This document describes how to use database mirroring with certificates. For
information about using Windows authentication with database mirroring, see
Example: Setting Up Database Mirroring Using Windows Authentication (Transact-
SQL) (http://go.microsoft.com/fwlink/?LinkId=83567&clcid=0x409).
Unless the network is secure, the data transmitted during the session should be
encrypted. This document outlines how to set up encryption on the data transmitted
over the wire by using RC4, but database mirroring supports both AES and RC4
encryption algorithms. For more information about the security associated with
database mirroring, see Database Mirroring Transport Security
(http://go.microsoft.com/fwlink/?LinkId=83569&clcid=0x409).
• All application pool accounts and the search services and default content access
account should have SQL Server logins, although they are not assigned to SQL
Server fixed server or fixed database roles.
• Members of the Farm Administrators SharePoint group should also have SQL
Server logins and should be members of the same roles as the Central
Administration application pool account.
We recommend that you transfer your logins and permissions from the principal
server to the mirror server by running a script. An example script is available in
Knowledge Base article 918992 How to transfer the logins and the passwords
between instances of SQL Server 2005 (http://go.microsoft.com/fwlink/?
LinkId=122053&clcid=0x409). For more general information about transferring SQL
Server metadata between instances, see the SQL Server Books Online article
Managing Metadata When Making a Database Available on Another Server Instance
(http://go.microsoft.com/fwlink/?LinkId=122055&clcid=0x409).
Recommended Topologies
It is recommended that you maintain a one-to-one mapping of principal server to
mirror server to ensure compatibility with SharePoint Products and Technologies.
The following illustrations demonstrate some supported topologies.
6
The supported topologies include mirroring all content databases, the configuration
database, and the Central Administration content database; additionally for Office
SharePoint Server you can mirror the SSP database, SSP search database and SSP
content databases.
Any topologies that do not have matching principal and mirror servers should be
avoided. Also, you should keep the configuration database and the administration
content database on the same server. The following diagram illustrates an
unsupported topology.
7
Figure 4: Unsupported SQL Server topology in a SharePoint Products and
Technologies server farm
• The latency of the network is the largest factor for performance. We recommend
that your system have latency no greater than 1 millisecond.
• Logs are copied in real time between the principal and the mirror servers, and
copying can impact performance.
• Every database mirroring session creates at least two threads for each database.
Ensure that your database server has enough threads to allocate for mirroring all
the supported databases. If you have insufficient threads, as more databases are
added to a session, performance can get progressively worse. For more
information about the number of possible threads, see Database Mirroring
Sessions (SQL Server Books Online) (http://go.microsoft.com/fwlink/?
LinkId=156594).
8
resource intensiveness of mirroring (each principal instance and mirror instance
requires dedicated threads), and testing. Your results may vary, based on the
following factors:
• The network bandwidth between the principal and the mirror instances
For more information about performance and scale, see Database Mirroring in SQL
Server 2005 (http://go.microsoft.com/fwlink/?LinkId=83566&clcid=0x409).
Ensure that the principal server and mirror server are running the same edition of
SQL Server 2005 SP 1. Database mirroring is available only in the Standard,
Developer and Enterprise editions. The witness server can run any version of SQL
Server 2005, including SQL Server Express.
If you plan to mirror SSP databases, consider that the transaction log size of these
databases may become quite large. To remedy this, consider having a recovery
plan that truncates transaction logs as necessary. For more information, see the
following article in the Microsoft Knowledge Base: How to stop the transaction log of
a SQL Server database from growing unexpectedly (http://go.microsoft.com/fwlink/?
LinkId=111458&clcid=0x409).
9
Setup Steps
The steps in this section give the instructions for using Transact-SQL to set up high-
availability mode database mirroring for a SQL Server database.
To set up database mirroring with SharePoint Products and Technologies, you must
work individually with each database that you want to mirror.
The steps in the following section pertain to the following server farm topology:
• Three servers running Microsoft SQL Server 2005: principal server, mirror server,
and witness server
10
STATE = STARTED
AS TCP (
LISTENER_PORT=5024
, LISTENER_IP = ALL
)
FOR DATABASE_MIRRORING (
AUTHENTICATION = CERTIFICATE <MASTER_HostA_cert>
, ENCRYPTION = REQUIRED ALGORITHM RC4
, ROLE = ALL
);
GO
2. On the principal server, back up the certificate.
3. On the principal server, back up the database. This example uses the
configuration database. Repeat for all databases.
USE master;
4. Copy the backup file to the mirror server. Repeat for all databases.
5. By using any secure copy method, copy the backup certificate file
(C:\HOST_HostA_cert.cer, for example) to the mirror and witness servers.
11
GO
--Create a mirroring endpoint for the server instance on HOST_B.
CREATE ENDPOINT Endpoint_Mirroring
STATE = STARTED
AS TCP (
LISTENER_PORT=5024
, LISTENER_IP = ALL
)
FOR DATABASE_MIRRORING (
AUTHENTICATION = CERTIFICATE <HOST_HostB>
, ENCRYPTION = REQUIRED ALGORITHM RC4
, ROLE = ALL
);
GO
2. On the mirror server, back up the certificate.
3. By using any secure copy method, copy the backup certificate file
(C:\HOST_HostB_cert.cer, for example) to the principal and witness servers.
4. On the mirror server, restore the database from the backup files. This
example uses the configuration database. Repeat for all databases.
12
--Grant CONNECT permission on the login for the remote mirroring endpoint.
GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO [<MASTER_HostA_login>];
GO
2. On the principal server, set up the mirroring partnership. This example uses
the configuration database. Repeat for all databases.
Note: You must use the format TCP :// < system-address> : < port> to specify
the address of the partner server that you are configuring. For more information,
see Specifying a Server Network Address (Database Mirroring)
(http://go.microsoft.com/fwlink/?LinkID=116405&clcid=0x409).
13
SET PARTNER = '<TCP://databasemirror.adatum.com:5024>';
GO
1. On the witness server, set up the certificate and open the port.
3. By using any secure copy method, copy the backup certificate file
(C:\WITNESS_HOSTC_cert.cer, for example) to the principal server and the mirror
server.
4. On the witness server, create logins and users for the principal and mirror
servers, associate the certificates with the users, and grant the logins connect
permissions for the partnership.
14
--Create a user for that login.
CREATE USER <MASTER_HostA_user> FOR LOGIN <MASTER_HostA_login>;
GO
--Associate the certificate with the user
CREATE CERTIFICATE <MASTER_HostA_cert>
AUTHORIZATION <MASTER_HostA_user>
FROM FILE = '<c:\MASTER_HostA_cert.cer>' --do not try to use a network
path, SQL Server will give an error about the key not being valid
GO
--Grant CONNECT permission on the login for the remote mirroring endpoint.
GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO [<MASTER_HostA_login>];
GO
--Create Login for Mirror Host B
CREATE LOGIN <HOST_HostB_login> WITH PASSWORD = '<1234-test>';
GO
--Create a user for that login.
CREATE USER <HOST_HostB_user> FOR LOGIN <HOST_HostB_login>;
GO
--Associate the certificate with the user
CREATE CERTIFICATE <HOST_HostB_cert>
AUTHORIZATION <HOST_HostB_user>
FROM FILE = '<c:\HOST_HostB_cert.cer>' --do not try to use a network
path, SQL Server will give an error about the key not being valid
GO
--Grant CONNECT permission on the login for the remote mirroring endpoint.
GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO [<HOST_HostB_login>];
GO
5. On the principal server, create a login and user for the witness server,
associate the certificate with the user, and grant the login connect permissions
for the partnership. Repeat for the mirror server.
6. On the principal server, attach the witness server. This example uses the
configuration database. Repeat for all databases.
15
ALTER DATABASE SharePoint_Config
SET WITNESS =
'<TCP://databasewitness.adatum.com:5024>'
GO
We recommend that you transfer your logins and permissions from the principal
server to the mirror server by running a script. The script that we recommend that
you use is available in Knowledge Base article 918992: How to transfer the logins
and the passwords between instances of SQL Server 2005
(http://go.microsoft.com/fwlink/?LinkId=122053&clcid=0x409).
• Manual failover
• Forced failover
The following table lists the types of failover available in each mirroring mode.
Note: This paper describes only how to recover from an automatic failover or a
manual failover.
Automatic Yes No No
failover
Automatic Failover
Automatic failover occurs when the principal server has lost communication with
the rest of the database mirroring configuration, while the mirror and witness retain
communication.
Note: If all server instances lose communication automatic failover does not occur,
even if the witness and mirror server later regain communication.
The following process occurs when automatic failover is triggered:
16
1. If the principal server is still running, it changes the state of the principal
database to DISCONNECTED and disconnects all clients from the principal
database.
2. The witness and mirror servers register that the principal server is
unavailable.
3. If any logs are waiting in the redo queue, the mirror server finishes rolling
forward the mirror database. The amount of time required to apply the log
depends on the speed of the system, the recent work load, and the size of the
logs in the redo queue.
4. The former mirror database moves online as the new principal database, and
recovery cleans up all uncommitted transactions by rolling them back as quickly
as possible. Locks isolate those transactions.
5. When the former principal server rejoins the session, it recognizes that its
failover partner now owns the principal role. The former principal server takes on
the role of mirror server, making its database the mirror database. The new
mirror server synchronizes the new mirror database with the principal database
as quickly as possible. As soon as the new mirror server has resynchronized the
databases, failover is again possible, but in the reverse direction.
Manual Failover
Manual failover typically occurs when both the principal and mirror servers are still
running. The administrator makes a conscious decision to switch the active
database from the principal to the mirror. This might be done for a variety of
reasons, such as upgrading software on the principal server.
The following process occurs during a manual failover:
1. The administrator connects to the principal server and issues the following
Transact-SQL commands for each database:
USE master;
This initiates an immediate transition of the mirror server to the principal role.
The following example provides a Transact-SQL script that you can use to
failover all mirrored databases:
USE master;
DECLARE i CURSOR
17
READ_ONLY
FOR
SELECT name FROM sys.databases WHERE database_id IN
(SELECT database_id FROM sys.database_mirroring WHERE mirroring_state=4)
CLOSE i
DEALLOCATE i
GO
2. On the former principal server, clients are disconnected from the database
and uncommitted transactions are rolled back.
If you run manual failover with an automatic failover setup that includes a witness
server, the principal and mirror automatically change roles.
We have tested using SQL Server aliasing to connect SharePoint Products and
Technologies to the mirrored database after failover.
The following methods can be used for disaster recovery failover, but are not
covered in this document:
• Stsadm operation: renameserver
18
• Host file edits
• WINS/DNS edits
Monitor mirroring
On the server, you can use the following Transact-SQL statement to monitor the
current mirroring state:
You may want to create a series of SQL Server jobs and alerts to determine which
server is principal, or create a Windows service that runs this command to
determine which server is principal.
If you plan to use aliasing, we recommend that you set it up before you install
SharePoint Products and Technologies, although you can set up aliasing after
installation. We recommend that you set up aliasing before you implement
mirroring.
Create an alias
Complete the following steps on every front-end Web server, and every server
that connects to SQL Server.
19
2. Click the Alias tab, and then click Add.
3. Select TCP/IP, type an alias, type the server name to associate with the alias,
and then click OK.
Note: If you are setting up aliasing for an existing farm, use an alias that is the
same name as the principal server so that no changes will need to be made to
the front-end Web servers to start using the alias.
20
4. Repeat for all servers that connect to SQL Server.
Complete the following steps on every front-end Web server and server that
connects to SQL Server.
1. On a server, start the SQL Server Native Client Network Utility (%SYSTEM
%\cliconfg.exe).
3. In the Edit Network Library Configuration dialog box, in the Server field,
type the name of the mirror server, and then click OK.
4. On the Manage Content Databases page, click the name of the content
database that has failed over.
7. Enter the information for the database you just removed, but replace the
information in Database Server with the name of the new principal server.
Repeat Steps 4-7 for each database that has failed over
You can also use the command line to accomplish the same thing.
1. To delete the failed database, use the following command:
21
stsadm -o deletecontentdb -url <http:// WebSiteName:port>
-databasename <ContentDatabaseName> -databaseserver
<OldPrincipalServer>
Additional References
SQL Server Database Mirroring Documentation (http://go.microsoft.com/fwlink/?
LinkId=93763&clcid=0x409)
22