Monday, June 16, 2014

SharePoint 2013 Deployment: How to Configure Cache

Introduction
SharePoint 2013 Deployment Series
How to setup a database server alias
How to configure Cache
How to deploy a search service application using PowerShell
This posting walks you through the steps necessary for configuring your SharePoint 2013 farm's caching functions, including: object cache, disk-based (BLOB) cache, and the new (AppFabric) distributed cache.  This posting assumes a traditional SharePoint farm three-tiered topology, where the application server(s) host most services, as well as the farm's CA web application, and the WFEs host primarily the customer-facing web applications and the search query and indexing services.

Preparation
  1. Use only the SharePoint Setup/Administration account when remoting into any SharePoint server to make modifications and configurations.
  2. Verify that the SharePoint Setup/Administration account is a member of the Administrators group on each server.
  3. Verify that the account that you want to use to run the distributed cache service is a member of the Administrators group on each server running SharePoint Server 2013.
  4. Identify domain accounts that you want to use as the Object cache Reader and User accounts (eg, spSuperR, spSuperU).
  5. If you are using HOST files to configure external or internal (or both) static routing amongst your farm servers, check the HOST file on each of the farm servers and verify that the host names in the file are fully qualified.  Otherwise, you may see error event IDs 1000 and 1026 appearing in the application event log of the server hosting the AppFabric service.

Procedure
  1. Configure Object Cache
    1. Add Object Cache Accounts
      1. Reference: Configure object cache user accounts in SharePoint Server 2013
      2. Remote into the application server under the SharePoint setup Administration account.
      3. Go to: Central Administration > Application Management > Manage Web Applications.
      4. Select a web application.
      5. From the ribbon, click User Policy.
      6. Click Add Users.
      7. Leave the zone default as All zones, and then click Next.
      8. In the Choose Users section, add the account that you want to use as the Object Cache Reader.
      9. In the Choose Permissions section, check Enable Read - Has full read-only access.
      10. Click Finish.
      11. Click Add Users again.
      12. Leave the zone default as All zones, and then click Next.
      13. In the Choose Users section, add the account that you want to use as the Object Cache User.
      14. In the Choose Permissions section, check Full Control - Has full control.
      15. Click Finish.
    2. Add Object Cache Account Claims User Names [see note]
      1. Open a SharePoint Management Shell as administrator
      2. Execute the following script:
        $wa = Get-SPWebApplication -Identity "<webapplication>" $wa.Properties["portalsuperuseraccount"] = "i:0#.w|Domain\spSuperU" $wa.Properties["portalsuperreaderaccount"] = "i:0#.w|Domain\spSuperR" $wa.Update()
      3. Execute IISReset on all machines.
    3. Configure Disk-based Cache Settings
      1. Reference: Configure BLOB cache settings
      2. The following steps must be performed on each WFE.
      3. Remote into the WFE under the SharePoint Administrator account.
      4. Go to: C:\inetpub\wwwroot\wss\VirtualDirectories\.
      5. Look for the folder corresponding to your web application and open it.
      6. Look for the file Web.Config.
      7. Open this file in any text editor.
      8. In this file, look for the XML tag, <BlobCache...
      9. Look for these attributes of this tag:
        1. location
        2. enabled
      10. Change the location attribute to whatever is appropriate to your system. 
        Best Practice is to point it to another drive on the WFE so that its write operations do not impact the system drive write operations.
      11. Change the enabled attribute to true.
      12. Save the file.
      13. Repeat for each WFE.
  2. Remove Unnecessary Cache Host
    1. Check AppFabric Status
      1. References: Cache Administration with Windows PowerShell (Windows Server AppFabric Caching) , SharePoint 2013 + Distributed Cache (AppFabric) Troubleshooting
      2. Remote into the application server as the SharePoint setup user administrator account.
      3. Launch the SharePoint Management Shell as administrator.
      4. Run the following script:
        Get-SPServiceInstance | ? {($_.service.tostring()) -eq "SPDistributedCacheService Name=AppFabricCachingService"} | select Server, Status
        This returns a list of your hosts and their network status. You want them all to be online.
      5. In the same shell, run the next script:
        Use-CacheCluster
        Get-CacheHost
        
        This returns the AppFabricCacheService status on each host. They should all be UP.
      6. If these are not UP, the removal will fail.
    2. Remove the host
      1. References: Manage the Distributed Cache service in SharePoint Server 2013, SharePoint 2013: Distributed Cache (AppFabrikCache) part 2/2
      2. Remote into the application server as the SharePoint setup user administrator account.
      3. Launch the SharePoint Management Shell as administrator.
      4. Run the following script:
        $instanceName = “SPDistributedCacheService Name = AppFabricCachingService” $serviceInstance = Get-SPServiceInstance | ? {( $_.service.tostring()) –eq $instanceName –and ($_.server.name) –eq $env:computername $serviceInstance.UnProvision() Remove-SPDistributedCacheServiceInstance
  3. Change Distributed Cache Service Account
    1. Reference: Manage the Distributed Cache service in SharePoint Server 2013: Change the service account, Changing the Distributed Cache Service Account
    2. Remote into the application server as the SharePoint setup user administrator account.
    3. Launch the SharePoint Management Shell as administrator.
    4. Run the following script:
      $Farm = Get-SPFarm $CacheService = $Farm.Services | Where {$_.Name -eq "AppFabricCachingService"} $Account = Get-SPManagedAccount -Identity "Domain\ServiceAccountNamer" $CacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser" $CacheService.ProcessIdentity.ManagedAccount = $Account $CacheService.ProcessIdentity.Update()
Reference
Notes
  • If you implement claims-based authentication, you must add the cache account claims user names to each web application's User Policy.  You do this using PowerShell, and you must use the claims user name format as shown.
  • By default, the distributed cache service is installed on each server to which you installed and configured SharePoint Server 2013.  Thus, if you installed SharePoint Server 2013 first to an application server, this server will be the first to host a cache service instance.  Now, if you are deploying a traditional topology (application server running most services and the CA web application and customer websites running on two or more WFEs), it is unnecessary to run the distributed cache service on the application server as it performs no useful customer function.  Therefore, it can be safely removed from the application server(s) if you want to.  If you are deploying SharePoint Server 2013 to more than three servers, you will definitely need to remove it from at least one of these.
  • To avoid deploying Distributed Cache to a new farm server entirely, use the "-SkipRegisterAsDistributedCacheHost" parameter.
  • It isn't absolutely necessary to remove the distributed cache running an application server.  It will not adversely impact farm operation leaving it there.

No comments: