In the last time I have seen many SharePoint Farms (2013 and 2016) on which the distributed cache was not in a healthy state or not available at all.
Before you start with any configuration make yourself familiar with distributed cache:
Planning:
- Plan for feeds and the Distributed Cache service in SharePoint 2013 and SharePoint 2016 – Note the “Capacity planning for the Distributed Cache service” section
- Plan the distributed Cache for SharePoint 2013 – I think it’s still valid for SharePoint 2016
- https://blogs.technet.microsoft.com/wbaer/2015/09/18/distributed-cache-in-sharepoint-server-2016-it-preview/
Configuration:
Distributed Cache – Cheat Sheet
The distributed cache is one of the service applications you should not configure via the central administration. So, start your PowerShell as administrator! 😉
I will update this post regular, as there is always something “new”.
Get (all) Distributed Cache Service instances
Get-SPServiceInstance | ? {$_.TypeName -eq "Distributed Cache"}
To get the service instance on a specific server (In this case: the current one). Run this command.
Get-SPServiceInstance | ? {$_.TypeName -eq "Distributed Cache" -and $_.server.name -eq $env:computername}
Get a overview of all Cache Hosts
On a server with a Distributed Cache Service Instance run the following command:
Use-CacheCluster Get-CacheHost
The result should look like this:
HostName : CachePort Service Name Service Status Version Info -------------------- ------------ -------------- ------------ SERVERNAME:22233 AppFabricCachingService UP 3 [3,3][1,3]
If there are any servers with a status other than ‘UP’ you should start there with your investigation.
Get the Cache Cluster Health
On a server with a Distributed Cache Service Instance run the following command:
Use-CacheCluster Get-CacheClusterHealth
This will get you a good overview of your Named Caches. In a healthy environment there should not be any Named Cache with a category value other than 0 for these categories:
- UnderReconfiguration
This is a temporary state of the cache and should resolve to healthy. - NotPrimary
The cache is not currently available. - InadequateSecondaries
I could not find any offical statement to this category. I think this has to do with forced replication of the cache. - Throttled
The cache is read-only, because the host has a low memory condition.
Source: Health Monitoring for Windows Server AppFabric Caching
Unallocated named cache fraction should get resolved by them-self. These cache fractions are not located yet and will get located soon.
Stop the Distributed Cache on a Cluster Server
In a multi server it is highly recommended to stop the Distributed Cache Service on a server before a reboot of this machine. Each Distributed Cache Server holds a copy of cached elements, which will get lost, if your restart this server without stopping the cache. When you stop the cache, the cached elements get moved to the other servers in your cluster.
Stop-SPDistributedCacheServiceInstance -Graceful
Changing the Service Account for the Distributed Cache
Note: Please do not try to change the service account of the distributed cache in the windows services. This will not end good.
It’s recommended to run the distributed cache on a non local admin account on the server. You can choose any managed account to run the distributed cache.
To change the service account run the following script:
$account = Get-SPManagedAccount "domain\youraccount" $cacheServive = Get-SPService | ? {$_.TypeName -eq "Distributed Cache"} $cacheServive.ProcessIdentity.CurrentIdentityType = "SpecificUser" $cacheServive.ProcessIdentity.ManagedAccount = $true $cacheServive.ProcessIdentity.Update() $cacheServive.ProcessIdentity.Deploy()
To complete this change restart the distributed cache on any cache cluster server:
Stop-SPDistributedCacheServiceInstance Remove-SPDistributedCacheServiceInstance