How to: Fail Over to a Mirrored Data-Tier Server if the Principal Server is Unavailable

If you have configured SQL Server mirroring for the databases on which Team Foundation relies, you can fail over to the mirrored data-tier server even if the principal server is unavailable. This approach can help minimize disruption in your deployment of Team Foundation Server. For more information, see Mirroring the Team Foundation Data-Tier Server"Implementing Restore Scenarios for SQL Server Databases" for either SQL Server 2005 or SQL Server 2008 on the Microsoft Web site.

Important noteImportant Note:

You should perform the procedures in this topic only if the principal data-tier server is unavailable. If the principal server is available, you should follow the procedures in How to: Fail Over to a Mirrored Data-Tier Server. For more information, see "Forced Service (with Possible Data Loss)" for SQL Server 2005 or SQL Server 2008 on the Microsoft Web site.

To fail over to a mirrored data-tier server when the principal server is unavailable, you must perform the following procedures:

  1. Stop Services that Team Foundation Server Uses

  2. Manually Swap the Roles of the Principal and Mirroring Databases

  3. Redirect SQL Server Reporting Services to Connect to the Mirrored Data-tier Server

  4. Map the Application-Tier Server to the New Principal Data-Tier Server

  5. Rebuild the Team System Cube

  6. Delete the Version Control Cache

  7. Redirect Web Sites for Team Projects

  8. Restart Services

  9. (Optional) Refresh the Data Cache on Client Computers

Required Permissions

To perform these procedures, you must be a member of the Administrators group and a member of the SQL Server Administrator group on the principal and mirrored servers. For more information, see Team Foundation Server Permissions.

In addition to these permissions, you might need to address the following requirements on a computer that is running Windows Server 2008 or Windows Vista:

  • To follow a command-line procedure, you might need to open an elevated Command Prompt by clicking Start, right-clicking Command Prompt, and clicking Run as Administrator.

  • To follow a procedure that requires Internet Explorer, you might need to start it as an administrator by clicking Start, clicking All Programs, right-clicking Internet Explorer, and then clicking Run as administrator.

  • To edit web.config files, you might need to start the text editor as an administrator by clicking Start, clicking All Programs, right-clicking the editor, and then clicking Run as administrator.

  • To access Report Manager, reports, or Web sites for SQL Server Reporting Services, you might need to add these sites to the list of trusted sites in Internet Explorer or start Internet Explorer as an administrator.

For more information, see the Microsoft Web site.

Stop Services that Team Foundation Server Uses

Before you fail over to the mirrored server, you must prepare the application-tier server to use the mirrored data-tier server.

Note

In a single-server deployment, you log on to the server that is running Team Foundation Server to stop and start all services, application pools, and Web sites. In a dual-server deployment, you must log on to the appropriate server that hosts the specific service, application pool, or Web site for Team Foundation Server. For more information, see How to: Stop and Start Services, Application Pools, and Web Sites.

To stop services that Team Foundation Server uses

  • Log on to the appropriate server, open Computer Manager, and stop the services and Web sites in the following table:

    Log on to the server that hosts this program

    Stop this component

    SharePoint Products and Technologies

    • Default Web Site or Team Web site

    • SharePoint Timer Service or Windows SharePoint Services Timer

    Reporting Services

    • SQL Server Reporting Services (TFSINSTANCE)

    • ReportServer or ReportServer$InstanceName (application pool)

    • Default Web Site or Report Manager Web site

      NoteNote:
      You have to stop the Report Server Web site and application pool with SQL Server 2005 but not with SQL Server 2008.

    Application tier

    • Visual Studio Team Foundation Server Task Scheduler Service

    • Microsoft Team Foundation Server Application Pool

Manually Swap the Roles of the Principal and Mirroring Databases

After you stop services, you can manually fail over the databases. For more information, see "How to: Manually Fail Over a Database Mirroring Session (SQL Server Management Studio)" for SQL Server 2005 or SQL Server 2008 on the Microsoft Web site.

To open SQL Server Management Studio on the mirroring server

  1. On the mirroring server, click Start, point to All Programs, point to Microsoft SQL Server, and then click SQL Server Management Studio.

    Note

    For more information, see "Implementing Restore Scenarios for SQL Server Databases" for either SQL Server 2005 or SQL Server 2008 on the Microsoft Web site.

    The Connect to Server dialog box opens.

  2. In Server type, click Database Engine.

  3. In Server name, click or type the name of the data-tier server and database instance, and then click Connect.

    SQL Server Management Studio opens.

  4. In Object Explorer, expand the Databases node to show the list of databases that make up the data tier.

Complete the "To force a service failover to a mirrored data-tier server" procedure later in this topic for each database in the following list:

  • ReportServer

    Note

    If you used a named instance, this database will be named ReportServer$InstanceName.

  • ReportServerTempDB

    Note

    If you used a named instance, this database will be named ReportServerTempDB$InstanceName.

  • The following databases for SharePoint Products and Technologies, if the deployment uses the same data-tier server for SharePoint Products and Technologies as for Team Foundation Server:

    • The administration content database for SharePoint Products and Technologies (WSS_AdminContent)

    • The configuration database for SharePoint Products and Technologies (STS_Config_TFS or WSS_Config)

    • The content database for SharePoint Products and Technologies (STS_Content_TFS or WSS_Content)

      Note

      The names of the databases that contain data for SharePoint Products and Technologies will vary depending on the version of SharePoint Products and Technologies that is installed and whether the person who installed it customized the name. Additionally, if SharePoint Products and Technologies is installed on a separate server from Team Foundation Server, these databases might not reside on the data-tier server. If they reside on a different server, you must manage their backup, restoration, and configuration separately from Team Foundation Server. However, you should synchronize the maintenance of the databases to avoid synchronization errors.

  • TfsActivityLogging

  • TfsBuild

  • TfsIntegration

  • TfsVersionControl

  • TfsWarehouse

  • TfsWorkItemTracking

  • TfsWorkItemTrackingAttachments

To force a service failover to a mirrored data-tier server

  1. In SQL Server Management Studio, open the File menu, point to New, and then click Query with Current Connection.

    A new query window opens.

  2. In the window, type the following command, where Database is the name of a database for Team Foundation:

    ALTER DATABASEDatabaseSET PARTNERFORCE_SERVICE_ALLOW_DATA_LOSS

  3. On the toolbar, click Execute.

Redirect SQL Server Reporting Services to Connect to the Mirrored Data-tier Server

To redirect Reporting Services to connect to the mirrored data-tier server

Map the Application-Tier Server to the New Principal Data-Tier Server

After you have failed over all the databases and deleted the version control cache, the mirroring data-tier server becomes the principal data-tier server for the deployment. To complete the failover, you must redirect the application-tier server to the current principal data-tier server.

To redirect the application-tier server

  1. Log on to the appropriate server, open Computer Manager, and start the components in the following table in the order specified:

    Log on to the server that hosts this program

    Start this component

    Application tier

    • Microsoft Team Foundation Server Application Pool

    Reporting Services

    • ReportServer or ReportServer$InstanceName (application pool)

      NoteNote:
      You have to start the Report Server application pool in Internet Information Services (IIS) if you are running SQL Server 2005 but not if you are running SQL Server 2008.
    • SQL Server Reporting Services (TFSINSTANCE)

  2. Open the Command Prompt window, change directories to %ProgramFiles%\Microsoft Visual Studio 2008 Team Foundation Server\Tools, and type the following command:

    TfsAdminUtil RenameDT newTeamFoundationDataTierServerName

    Important noteImportant Note:

    For the RenameDT command to succeed, the application pools and programs in the previous step must be running. This requirement is new in Visual Studio Team System 2008 Team Foundation Server.

  3. Type iisreset, and then press ENTER to restart Internet Information Services (IIS).

Rebuild the Team System Cube

To rebuild the Team System cube

Delete the Version Control Cache

After you rebuild the Team System cube, you must delete the version control cache on the application-tier server and any proxy servers to force synchronization with the new data-tier server.

To delete the version control cache

  1. Log on to the application-tier server, and open the following directory:

    Drive:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services\VersionControl

  2. Delete the contents of the Data subdirectory, but do not delete the subdirectory itself.

    For more information, see How to: Delete the Version Control Cache on the Application-tier Server.

  3. Repeat this procedure on any server in your deployment that is running Team Foundation Server Proxy.

Redirect Web Sites for Team Projects

To redirect project sites to use the content database on the mirrored data-tier server

Restart Services

To restart services that Team Foundation Server uses

  1. Log on to the appropriate server, open Computer Manager, and start the services in the following table in the order specified:

    Log on to the server that hosts this program

    Start this service

    SharePoint Products and Technologies

    • SharePoint Timer Service or Windows SharePoint Services Timer

    • Default Web Site or Team Web site

    Application tier

    • Visual Studio Team Foundation Server Task Scheduler Service

    • Microsoft Team Foundation Server Application Pool

    Reporting Services

    • SQL Server Reporting Services (TFSINSTANCE)

    • ReportServer or ReportServer$InstanceName (application pool)

      NoteNote:
      You have to start the Report Server application pool in IIS if you are running SQL Server 2005 but not if you are running SQL Server 2008.
    • Default Web Site or Report Manager Web site

  2. Open Internet Explorer, type the following string in the Address bar, and verify that the team project portal is available:

    http://SharePointServicesServerName/default.aspx

Refresh the Data Cache on Client Computers

You must refresh the data cache on client computers only if the restored data does not match the data on the data-tier server before failover.

To refresh the data cache on client computers

  1. Log on to the application-tier server.

  2. Use the ClientService Web service to force clients to update the cache for tracking work items the next time that they connect to the application-tier server.

    For more information, see How to: Refresh the Data Caches on Client Computers.

See Also

Tasks

How to: Stop and Start Services, Application Pools, and Web Sites

How to: Configure SQL Server Mirroring for the Team Foundation Data-Tier Server

How to: Fail Over to a Mirrored Data-Tier Server

Concepts

Team Foundation Server Permissions

Other Resources

Mirroring the Team Foundation Data-Tier Server