Export (0) Print
Expand All
18 out of 27 rated this helpful - Rate this topic

Manage the Distributed Cache service in SharePoint Server 2013

SharePoint 2013

Updated: February 19, 2013

Summary: Learn how to configure and manage the Distributed Cache service in SharePoint Server 2013.

Applies to:  SharePoint Server 2013 

To perform management and operational tasks on the Distributed Cache service in SharePoint Server 2013, an administrator must perform specific, ordered procedures. This article describes how to conduct several management and operational tasks on the Distributed Cache service.

Important Important:

The Distributed Cache service can end up in a nonfunctioning or unrecoverable state if you do not follow the procedures that are listed in this article. In extreme scenarios, you might have to rebuild the server farm. The Distributed Cache depends on Windows Server AppFabric as a prerequisite. Do not administer the AppFabric Caching Service from the Services window in Administrative Tools in Control Panel. Do not use the applications in the folder named AppFabric for Windows Server on the Start menu.

To learn more about planning, installing, and configuring the Distributed Cache service in a SharePoint Server 2013 farm, see the model Planning and using the Distributed Cache service.

Model: Plan the Distributed Cache service

In this article:

Start and stop the Distributed Cache service

An administrator that performs maintenance and operational tasks might need to start and stop the Distributed Cache service. Some of these tasks include the following:

  • Changing the default configuration of the server farm at installation time. The Distributed Cache service is started on all SharePoint servers at installation time. An administrator might want to stop the Distributed Cache service on some servers in the farm.

  • Updating the server and there is only one Distributed Cache server in the SharePoint Server 2013 farm.

Stopping the cache results in partial data loss. The Feed Cache depends on the Distributed Cache service. Tags and document activities are saved only to the Feed Cache. Tags and document activities are not persisted to content databases. When the Distributed Cache service is stopped, tags and document activities are lost. When the Distributed Cache service is started, repopulation occurs when the feed cache repopulation timer job runs. For more information, see Manage Feed Cache and Last Modified Time Cache repopulation in SharePoint Server 2013. One way to maintain the tags and document activities is to use the method described in Perform a graceful shutdown of the Distributed Cache service later in this article. When the graceful shutdown of the Distributed Cache service method is used, all cache data is moved from one server to another server before the Distributed Cache service is stopped.

note Note:

If your cache hosts are part of a cache cluster, do not start or stop the Distributed Cache service as described here. Instead, see Add or remove a server in a Distributed Cache cluster later in this article.

To start and stop the Distributed Cache service by using Central Administration

  1. In Central Administration, click Application Management.

  2. In Service Applications, click Manage Services on Server.

  3. On the Services on Server page, locate the Distributed Cache service.

  4. If the Distributed Cache service is started and you want to stop the service, under Action, click Stop. If the Distributed Cache service is stopped and you want to start the service, under Action, click Start.

To start the Distributed Cache service by using Windows PowerShell

At the Windows PowerShell command prompt, run the following command:

$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Provision()

To stop the Distributed Cache service by using Windows PowerShell

At the Windows PowerShell command prompt, run the following command:

$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()

Change the memory allocation of the Distributed Cache service

When SharePoint Server 2013 is installed, it assigns the Distributed Cache service 10 percent of the total physical memory on the server. The Distributed Cache service uses half of that memory allocation for data storage (also known as cache size), and the other half of that memory allocation is used for memory management overhead. When the cached data grows, the Distributed Cache service uses the entire 10 percent of the allocated memory.

You should increase the memory allocation of the Distributed Cache service in these scenarios:

  • When you add physical memory to the server. The Distributed Cache service does not automatically recalculate the 10% memory allocation, so when you increase the total physical memory on the server, you have to manually increase the Distributed Cache service's memory allocation.

  • When your server farm has a dedicated Distributed Cache server. Use the following method to calculate how much memory can be assigned to the Distributed Cache service:

    1. Determine the total physical memory on the server. For this example, we will use 16 GB as the total physical memory available on the server.

    2. Reserve 2 GB of memory for other processes and services that are running on the cache host. For example, 16 GB – 2 GB = 14 GB. This remaining memory is allocated to the Distributed Cache service.

    3. Take half of the remaining memory, and convert it to MB. For example, 14 GB/2 = 7 GB or 7000 MB. This is the cache size of the Distributed Cache service.

    4. Use the following procedure to update the memory allocation accordingly.

Change the memory allocation of the Distributed Cache

Use this procedure to reconfigure the memory allocation of the cache size of the Distributed Cache service.

  1. (Optional) To check the existing memory allocation for the Distributed Cache service on a server, run the following command at the Windows PowerShell command prompt:

    Use-CacheCluster
    Get-AFCacheHostConfiguration -ComputerName ComputerName -CachePort "22233"
    
    

    Where:

    • ComputerName is the computer name of the server that you are running the PowerShell cmdlet on.

  2. Stop the Distributed Cache service on all cache hosts. To stop the Distributed Cache service, go to Services on Server in Central Administration, and Stop the Distributed Cache service on all cache hosts in the farm.

  3. To reconfigure the cache size of the Distributed Cache service, run the following command one time only on any cache host at the Windows PowerShell command prompt:

    Update-SPDistributedCacheSize -CacheSizeInMB CacheSize
    

    Where:

    • CacheSize is the cache size's memory allocation assignment in MB. In the previous example, the cache size was calculated at 7000 MB for a server with 16 GB of total memory.

  4. Restart the Distributed Cache service on all cache hosts. To restart the Distributed Cache service, go to Services on Server in Central Administration, and Start the Distributed Cache service on all cache hosts in the farm.

Add or remove a server in a Distributed Cache cluster

An administrator can add or remove a server to a cache cluster, or might want to remove a server from the cache cluster, perform some operational or maintenance tasks on the server, and then rejoin or add the server to the cache cluster. When removing the server, the Distributed Cache service is stopped, then unregistered from the server. Unregistering the Distributed Cache service means that an administrator will not see the Distributed Cache service listed on the Services on Server page in Central Administration. Similarly, when a server is added, the Distributed Cache service is registered and then is started on the server. Registering the Distributed Cache service means that an administrator will see the Distributed Cache service listed on the Services on Server page in Central Administration.

Use the following procedures to add and remove a server from a cache cluster. These Windows PowerShell cmdlets are run on the server being added or removed.

note Note:

Before performing the following procedures, ensure the firewall allows Inbound ICMP (ICMPv4) traffic through it. For more information, see Firewall configuration considerations.

Add a server to the cache cluster and starting the Distributed Cache service by using a Windows PowerShell

At the Windows PowerShell command prompt, run the following command:

Add-SPDistributedCacheServiceInstance

Remove a server from the cache cluster by using a Windows PowerShell

At the Windows PowerShell command prompt, run the following command:

Remove-SPDistributedCacheServiceInstance

ImportantImportant:

This procedure will stop the cache service and nonpersisted cached data will be lost. If you want to keep the cached data, use the graceful shutdown procedure that is described in the next section, and then run the Remove-SPDistributedCacheServiceInstance cmdlet. The Remove-SPDistributedCacheServiceInstance cmdlet involves stopping and disabling the underlying AppFabric Caching service. Do not restart the AppFabric Caching service other than by running the Add-SPDistributedCacheServiceInstance cmdlet.

Perform a graceful shutdown of the Distributed Cache service

In a SharePoint Server 2013 farm, a cache cluster exists when one or more cache hosts run the Distributed Cache service. In a SharePoint Server 2013 farm, one cache exists, and the cache spans the cache cluster. An administrator can take a cache host out of the cluster to perform operational or maintenance tasks on the server, such as applying updates to the server. To prevent data loss associated with the removal of the cache host from the cache cluster, an administrator must first run the graceful shutdown procedure before removing the cache host from the cache cluster. The graceful shutdown procedure is run on the cache host being removed from the cache cluster. This cache host stores a portion of the cached data. The graceful shutdown procedure transfers all cached data from the cache host on which the graceful shutdown procedure is being run on to another cache host in the farm. The transfer process takes 15 minutes or more to run depending on how many items exist in the cache. When the transfer process is complete, removing the cache host by using the Remove-SPDistributedCacheServiceInstance cmdlet does not result in any data loss.

To perform a graceful shutdown of the Distributed Cache by using Windows PowerShell

At the Windows PowerShell command prompt, run the following command:

Stop-SPDistributedCacheServiceInstance -Graceful
Remove-SPDistributedCacheServiceInstance

noteNote:

To rejoin or add the server to the cache cluster, run the Add-SPDistributedCacheServiceInstance cmdlet.

Change the service account

When the server farm is first configured, the server farm account is set as the service account of the AppFabric Caching service. The Distributed Cache service depends on the AppFabric Caching service. To change the service account of the AppFabric Caching service to a managed account:

  1. Create a managed account. For more information, see Configure automatic password change (SharePoint Server 2010).

  2. Set the Managed account as the service account on the AppFabric Caching service. At the Windows PowerShell command prompt, run the following command:

    $farm = Get-SPFarm
    $cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"}
    $accnt = Get-SPManagedAccount -Identity domain_name\user_name
    $cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser"
    $cacheService.ProcessIdentity.ManagedAccount = $accnt
    $cacheService.ProcessIdentity.Update() 
    $cacheService.ProcessIdentity.Deploy()
    
    

    Where Domain_name\user_name is the domain name and user name of the managed account.

Repair a cache host

During installation, configuration, or maintenance activities, the Distributed Cache service might enter a non-functioning state. Evidence of a malfunctioning Distributed Cache service will appear in Health Rules in Central Administration, or when users use features in SharePoint Server 2013 that rely on the Distributed Cache. For example, the Newsfeed on a user's My Site will start reporting errors. Also, administrators might receive the error message "cacheHostInfo is null " when they run Windows PowerShell cmdlets to manage the Distributed Cache service.

Use the following procedure to restore a non-functioning Distributed Cache host.

  1. At the Windows PowerShell command prompt, run the Get-SPServiceInstance cmdlet to list all services on all servers in the server farm. Make note of the GUID in the ID property of the Distributed Cache service on the server that you are repairing. The Get-SPServiceInstance cmdlet lists all services on all servers in the server farm. Ensure that you note the correct GUID from the server that you are repairing.

  2. At the Windows PowerShell command prompt, run the following command:

    $s = Get-SPServiceInstance GUID
    $s.delete()
    
    

    Where GUID is the GUID of the Distributed Cache service noted in step 1.

  3. At the Windows PowerShell command prompt, run Add-SPDistributedCacheServiceInstance to reinstall and start the Distributed Cache service on the cache host that you are repairing.

Change History

Date Description

February 19, 2013

Added an optional step to reconfigure the memory allocation of the Distributed Cache service, added a note about Inbound ICMP (ICMPv4) traffic, and added a new section: "Repair a cache host."

July 16, 2012

Initial publication

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.