Tuesday, September 1, 2015

SharePoint 2013 - Remove faulty Cache Host which is in “Unknown” state from a cache cluster

One of my SharePoint environments had some servers removed from that farm. Unfortunately they were not removed properly where, some configuration items still remained.For an example, my distributed cache service prompted me with multiple errors due to invalid configuration.

When I try to remove the unresponsive CacheHost, using PowerShell “Unregister-CacheHost” it gave me following error
Unregister-CacheHost : ErrorCode<UnspecifiedErrorCode>:SubStatus<ES0001>:No such host is known
When I execute the simplest command Get-CacheHost, that too gave me an error
I tried to unregister or remove the Unknown host using PowerShell commands but i was not that lucky.

Finally SharePoint gods decided to let me finish my task :)
I found a solution using “Export-CacheClusterConfig” and “Import-CacheClusterConfig” commands

Following are the steps I follow
Export-CacheClusterConfig -File "F:\Cache\CacheConfig.xml"
My configuration file had the hosts section as below. I removed the faulty host from the config file.

  1. <hosts>
  2.   <host replicationPort="22236"arbitrationPort=22235clusterPort=22233 hostId=99833size=800leadHost=true account=dev\svcuser
  3.       cacheHostName=AppFabricCachingService name=testserver1
  4.       cachePort=22233 />
  5.   <host replicationPort=22236arbitrationPort=22235clusterPort=22233 hostId=34355size=400leadHost=true account=dev\svcuser
  6.       cacheHostName=AppFabricCachingService name=testserver2
  7.       cachePort=22233 />
  8.   <host replicationPort=22236arbitrationPort=22235clusterPort=22233 hostId=67893size=400leadHost=true account=dev\svcuser
  9.          cacheHostName=AppFabricCachingService name=testserver3
  10.          cachePort=22233 />
  11. </hosts>

Then I ran the following command
Import-CacheClusterConfig -File "F:\Cache\CacheConfig.xml"
That solved my problems.