September 7, 2012

TFS - Moving from one Hardware to another

This article focuses on moving an instance of Visual Studio Team Foundation Server from one hardware configuration to another, which is termed as "Restoration based move" in TFS.
A key point here is that the Restoration-based move can be used only when your database and application tier are in the same machine.
Requirements to perform Restoration-based move.
·         Machine must be Windows Server 2008 R2 with enough space for restoring the databases.
·         Machine should have the exact same configuration what old machine has.
·         You must be the user belongs to administrator group in the server.
·         You must be added in the SQL Server login group and should be given the following permissions.
o    Dbcreator
o    Public
o    Security admin
o    Server admin and
o    Sys admin
Steps to be followed.
Assume that the machine names are TFS01 (Old machine name) and TFS02 (New machine name)
Make sure that the current user has sysadmin as well as Admin privilege in the system as well as TFS
         I.            Taking the backups from TFS01.
a.        First we need to take the full backups of all the databases
                                                               i.      Tfs_Configuration
                                                              ii.      Default Collection
                                                            iii.      Tfs_CollectionOne
                                                              v.      Tfs_CollectionTwo and etc
                We have to take up the DefaultCollection database backup also. Because Tfs_Configuration maintains the settings of Default Collection and unique collection id of Default collection. 

       II.            Prepare the new machine TFS02.Install all the required software with only one user.
a.        Get an ESX Server Image or Physical machine with the following configuration
                                                               i.      OS - Windows 2008 R2
                                                              ii.      IIS should be installed
                                                            iii.      Minimum 150GB HDD and subjected to vary based on the TFS Backup Database. Allocate 60GB for C Drive, which will have all software installations. D drive can be used to store database. So it can be 90GB initially and increased if the restoration Database size is Huge.

b.       Install SQL Server 2008 R2
                                                               i.      You will get a prompt to add .Net Framework to core role, if it is not already installed. Click OK.
                                                              ii.      Support Setup Rules should succeed
                                                            iii.      Setup Role -> Go with default “SQL Server Feature Installation”
                                                            iv.      Feature Selection – Select All
                                                              v.      Installation Configuration -> Default Instance
                                                            vi.      Disc Space Requirement -> Click Next
                                                           vii.      Server Configuration -> Select Account Name as Network Service for the following four service
1.    SQL Server Agent
2.    SQL Server Database Engine
3.    SQL Server Analysis Services
4.    SQL Server Reporting Services
And leave other services account name as default.
                                                         viii.      Databse Engine Configuration -> Select Mixed Mode and enter password, add the current user and required domain users.
                                                            ix.      Analyssis Service Configuration -> add current user and required users
                                                              x.      Reporting Services Configuration -> Install the native mode default configuration
                                                            xi.      Continue with the installation.

c.        Install Microsoft Team foundation server 2010. Install only with the current user who is performing the restoration.
                                                               i.      Copy TFS 2010 DVD content from en_visual_studio_team_explorer_2010_x86_dvd_509698.iso to the TFS Server and extract it using WinRAR
                                                              ii.      Run Setup.exe from .\TFS-x64 folder.
                                                            iii.      Select “Team Foundation Server” in the feature selection dialog and click Next, It installs the following
1.    VC 9.0 Runtime (x86)
2.    VC 9.0 Runtime (x64)
3.    VC 10.0 Runtime (x86)
4.    VC 10.0 Runtime (x64)
5.    Microsoft .Net Framework 4.0
6.    .Net Framework 4 Multi-Targeting Pack
7.    Microsoft Team Foundation Server 2010
                                                            iv.      It asks for reboot after Microsoft .Net Framework 4.0 installation. The installer resumes after restart to install .Net Framework 4 Multi-Targeting Pack and Microsoft Team Foundation Server 2010.
                                                              v.      Continue with Configure after TFS installation.
                                                            vi.      Start Wizard from the configuration center.
                                                           vii.      Enter <domain>\TFSService and use the correct password for Account details and test. Then Click Next
                                                         viii.      Readiness checks validate that your system is ready to Configure.
                                                            ix.      If IIS is not installed then you will get the following message

Warning
[ System Checks ] None : VFIREWALL (System Checks\Root\Firewall)
Information
[ Application Tier ] Service will be installed for you: IIS
Information
[ Application Tier ] Windows Authentication has not been configured in Internet Information Services (IIS). If you continue, it will be configured for you.

d.       Configuration takes few minutes, which will install IIS as well.
e.        Change the Visual Studio Team Foundation Background Job Agent logon account to <domain>\TFSService and use the correct password.
     III.            Stop the TFS Services using the Command (use RunAsAdministrator in Win 2k8 R2). C:\Program Files\Microsoft Team Foundation Server 2010\Tools\TfsServiceContrlo.exe QUIESCE
     IV.            Restoring the databases.To restore the database the user should have the same permissions as in the above requirements.
Restore all the databases Tfs_CollectionOne, Tfs_CollectionTwo, Tfs_DefaultCollection and Tfs_Configuration and etc.
[If the Tfs_DefaultCollection backup is not available, MSSQL Management Studio and run the following query 
BACKUP DATABASE Tfs_DefaultCollection
TO DISK='<some path>\Tfs_DefaultCollection.bak'
   Use master]
For the existing database, right click on the DB Name and select Tasks -> Restore and Select Overwrite under Options.
For the new databases, right click on the Database and select Restore Database.
       V.            Prepare the SQL Server to host the databases for Team Foundation Server.
Log on to the server, open a Command Prompt window, and then change directories to Drive:\%programfiles%\ Microsoft Team Foundation Server 2010\Tools.
Type the following command, where ServerName is the name of the instance of SQL Server that hosts the databases for Team Foundation Server, in either ServerName or ServerName\InstanceName format:
TFSConfig PrepSQL /SQLInstance:ServerName
[Note: You will get the following message :
Logging sent to file C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\CFG_CFG_AT_0927_085559.log
Command: prepSql
TfsConfig - Team Foundation Server Configuration Tool
Copyright (c) Microsoft Corporation. All rights reserved.
SQL Instance ‘
ServerName’ successfully prepared.]
     VI.            Redirect Team Foundation Server to its Databases. We must have to redirect our Team Foundation Service to our Databases if any of the conditions are true.
a.        The TFS_Analysis or the TFS_Warehouse database is hosted on a different server from TFS_Configuration.
b.       You are using a named instance to host your databases.
c.        You have one or more collection databases hosted on a different server from the configuration database.

Run the following command.
TFSConfig RemapDBs DatabaseName:ServerName;TFS_Configuration /SQLInstances:ServerName,ServerName2/AnalysisInstance:ServerName2/AnalysisDatabaseName:DatabaseName
Replace the ServerName with the new TFS server name.(ie TFS2).
For us we can run the command as follows.
TFSConfig RemapDBs DatabaseName:TFS2;TFS_Configuration /SQLInstances:TFS2
This will do all remapping to the Team Foundation Server.
(Note: This command also we have run the from the elevated command prompt.)

   VII.            Change the Ownership of the Moved Databases.We must have to change the ownership of the Moved Databases. For that we need to run TFSConfig Accounts ResetOwner Command. Before running we need to make sure that ,
a.        must be appropriate user in the system
b.       use the same account which the TFS is installed and configured
c.        Must be the member of the TFS administrator group.
d.       And must be the member of sysadmin in SQL Server.
Following is the command we have run with elevated command prompt and change the directory to c:\Program Files\Microsoft Team Foundation Server 2010\Tools.
TFSConfig Accounts /ResetOwner /SQLInstance:ServerName /DatabaseName:DatabaseName
Replace ServerName with TFS2 (New TFS machine) and DatabaseName is TFS_Configuration. After replacing the command will be as follows.
TFSConfig Accounts /ResetOwner /SQLInstance:TFS2 /DatabaseName:Ttf_Configuration
If you specify the configuration database, this command will change the ownership for all of the databases for Team Foundation Server.
[Note: If specified database name is incorrect then, it would show the following error
“Logging sent to file C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\CFG_ACCT_AT_0927_090003.log
Command: accounts
TfsConfig - Team Foundation Server Configuration Tool
Copyright (c) Microsoft Corporation. All rights reserved.
Validating Inputs
TF246017: Team Foundation Server could not connect to the database. Verify that the server that is hosting the database is operational, and that network problems are not blocking communication with the server.”]
 VIII.            Update all the service Accounts.We must have to update the service account for Team Foundation Server (TFSService) and the data sources account (TFSReports). Even if these accounts have not changed, you must update the information to help ensure that the identity and the format of the accounts are appropriate for the new server.

To update the service Account
1.    Open a Command Prompt window, and change directories to c:\Program Files\Microsoft Team Foundation Server 2010\Tools
2.       At the command prompt, type the following command to add the service account for Team Foundation, where DatabaseName is the name of the configuration database (by default, TFS_Configuration):
TfsConfig Accounts /add /AccountType: ApplicationTier /account:AccountName /SQLInstance:ServerName/DatabaseName:DatabaseName
In the above command replace ServerName with TFS2, DataseName as Tfs_Configuration and AccountName as <domain>\TFSService. After replacing the command will be as follows.
TfsConfig Accounts /add /AccountType:ApplicationTier /account:SWG\TFSService /SQLInstance:TFS2 /DatabaseName:Tfs_Configuration
[Note: If the account exists, then you will get “Already a member” message]
3.       At the command prompt, type the following command to add the data sources account:
TfsConfig Accounts /add /AccountType:ReportingDataSource /account:AccountName/SQLInstance:ServerName /DatabaseName:DatabaseName
In the above command replace ServerName with TFS2 And DataseName as Tfs_Configuration. After replacing the command will be as follows.
TfsConfig Accounts /add /AccountType:ReportingDataSource /account:SWG\TFSServer /SQLInstance:TFS2  /DatabaseName:Tfs_Configuration
     IX.            Register the Tfs_Configuration Database to the TFS Server.We must have to register the Tfs_Configuration Database to the new Team Foundation Server. This step is missing from the above given link.TFSConfig registerDB /sqlInstance:TFS2 /databaseName:Tfs_Configuration
[Note: This command will also start the Team Foundation Server Job Agent.]
       X.             Update the URL for the Application Tier Server.
To update the URL in the application Tier Server
·         Open the Team Foundation Server Administrative Console
·         Change to Application Ties in the navigation bar and click on Change URLs
·         Change the URLs accordingly and test
[This might throw an error ]

     XI.            Verify the Users and Permissions using the administrative Console.

   XII.            Connect to the new machine TFS2

Some Challenges you may face :

1)       Installing and configuring TFS. We have to make sure that the current user should have sysadmin permissions and admin privileges in the system as well as TFS also.
2)       We must have to take the backup of Default collection from the old machine.
3)       Uninstallation of the TFS will leave some residues in the database as well as default collection. We must have to remove them manually. For that we have to access the URL from the Internet Explorer and manually delete the Default collection.

This document is prepared on the based of the Link.

No comments:

Post a Comment