Saturday, March 31, 2012

Cloning Your SharePoint 2010 Farm

More than once, I've had a client who's attempted to clone their virtual production SharePoint 2010 farm for development testing and run into errors. The most common steps they take once they clone the system is to assign the network interfaces new IPs and rename the host names. This is not enough as both SQL Server and SharePoint will have references to their old names in their configurations.

I don't recommend this method for a couple reasons and suggest that you should build a dedicated development farm that matches the configuration of your production environment. One issue is the cloned machines will retain their system SIDs and it's recommended that a cloned VM be generalized with Sysprep to address this. Also, if your Farm has jobs or processes that effect other systems, for example your Profile Service writing changes to Active Directory, those jobs will attempt to run.

With that said, here are the steps to take if you'd like to still go this route:

On All Servers

  1. Clone your farm member servers using your hypervisor's built in methods.
  2. Make sure the virtual adapters on the cloned machines are not connected. This will prevent network IP and NETBIOS name conflicts when they power on.
  3. Assign the machines new IP addresses but still don't connect the virtual interfaces.
  4. Rename the host name on each farm member and reboot. This can be done in the System Properties:
Once the systems come back up and are renamed, you may connect the virtual interfaces.

On the SQL Server

  1. On your SQL Server instance, you'll have to change the server name setting. This can be done in Magement studio (SSMS) with the following query:

    DECLARE @AddNew NVARCHAR(150)
    DECLARE @DropOld NVARCHAR(150)
    
    SET @DropOld = N'sp_dropserver ''' + @@SERVERNAME + N''''
    SET @AddNew = N'sp_addserver ''' + HOST_NAME() + N''', ''local'''
    
    exec (@DropOld)
    exec (@AddNew)
     
  2. Restart the SQL Server service to allow the changes to apply.

On the SharePoint Servers

  1. Run the following PowerShell command:

    Rename-SPServer [-Identity] <OriginalServerName> -Name <NewServerName>
    Example:

    Rename-SPServer -Identity "SPWFE01" -Name "DEV-SPWFE01"
  2. List all of the URLs in your farm with the following PowerShell Command:

    Get-SPWebApplication -IncludeCentralAdministration
  3. Rename all URLs to new server name with PowerShell, if they contain server name. This must be done for each zone that needs to be changed as well:

    New-SPAlternateURL -Url http://newserver -WebApplication http://oldserver -Zone "Default"

  4. Add any domain accounts, if needed, to the web apps and Central Admin.

Recreate the User Profile Service Application

You probably will have to recreate your UPS application as it will have references to your old server names. 

  1. Go to Central Admin > Manage Service Applications and highlight User Profile Service Application. Then click Delete in the Ribbon.
  2. Do NOT click the checkbox in the dialog box that pops up. Leaving this unchecked keeps the UPS data.
  3. Open SQL Server Management Studio (SSMS) and find the three UPS databases. They are (your full name will vary):
    SyncDB
    SocialDB
    ProfileDB
  4. Delete the SyncDB, as it is only used by SharePoint as a staging area and does not contain useful data.
  5. Create a new User Profile Service Application and provide the exact names of the Sync and Social databases as they exist in SSMS.
  6. Once the UPS application is created, add your content search account as an administrator with the permission “Retrieve People Data for Search Crawlers”.
  7. Restart the UPS Synchronization service.
  8. In Central Admin go to Manage Services On Server.
  9. Start the User Profile Synchronization Service.
  10. Supply all needed information in the prompts.
Sources:
http://technet.microsoft.com/en-us/library/cc261986.aspx
http://technet.microsoft.com/en-us/library/ff607632.aspx
http://technet.microsoft.com/en-us/library/ff607562.aspx
http://support.microsoft.com/kb/303774
http://technet.microsoft.com/en-us/library/ee721052.aspx