We all know Distributed Cache plays a key role in SharePoint. It handles authentication, page load performance, social features, and so on. A healthy distributed cache guarantees the stability of the farm. In this article, I will explain a common issue we all face every now and then.
Issue
We have a multiple-server farm and the distributed cache should run only on one server. But, when we run the "Use-CacheCluster" command on one of the SharePoint servers ( which is not meant for Distributed Cache), we get the following error.
"Use-CacheCluster : ErrorCode<ERRPS001>:SubStatus<ES0001>:Error in reading provider and connection string values. Please provide the values manually.
At line:1 char:1
+ Use-CacheCluster
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-AFCacheClusterConfiguration], DataCacheException
+ FullyQualifiedErrorId : ERRPS001,Microsoft.ApplicationServer.Caching.Commands.ConnectAFCacheClusterConfigurationCommand "
Or, if you run the Get,
"Get-CacheHost : ErrorCode<ERRPS013>:SubStatus<ES0001>:Error: No valid cluster settings were provided with Use-CacheCluster.
At line:1 char:1
+ Get-CacheHost
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AFCacheHostStatus], DataCacheException
+ FullyQualifiedErrorId : Microsoft.ApplicationServer.Caching.DataCacheException,Microsoft.ApplicationServer.Caching.Commands.GetAFCacheHostStatusCommand "
Cause
This error is telling us that the server is unable to read and get the values of the Connection String. Basically, this information comes from the AppFabric and If Distributed Cache service is not running on the server (where you ran the commands), then it will throw the error. Because the Server is unable to communicate with the AppFabric, in order to check on which server the Distributed Cache is running, you can do a couple of things.
PowerShell
Open the SharePoint PowerShell and run the below command -
Get-SPServiceInstance | Where {$_.Typename -like “Distributed Cache”}
The above command returns only one server information on which DC is running, that is the problem.
Resolution
What we are seeing is an expected thing. But, if you want to access the Distributed Cache from all Servers in the farm, then you have to enable the provision of the DC instance on all servers in the farm.
Now, we have a couple of options to fix it.
Option # 1
No need to do anything. Leave it as is. In order to get this command working, just log on to the Server where Distributed Cache is running, and run it.
Now, let’s log on the Server where we enabled the DC.
Open the PowerShell and run the following command.
Use-CacheCluster
Get-CacheHost
Option # 2
Install the Distributed Cache instance on all Servers in the farm, then stop it. It will look a little ugly but will work fine. Run the following command on the Server where you want to run the DC.
add-SPDistributedCacheServiceInstance The above command successfully provisions the Distributed Cache Service Instance on the Server and starts the Service. Now, run the below command.
stop-SPDistributedCacheServiceInstance -Graceful This will stop the DC on the server without removing it. Now, run the following command.
Use-CacheCluster
Get-CacheHost As you see, DC is up on the Server where we want it. Run it on the server where we want it. But this looks ugly because it is a big distraction.
Conclusion
I highly recommend removing the DC instance from the Server where we don’t want to run it, to avoid such confusion. Just keep it running on the Server where it should be.