SharePoint 2013 SPDistributedCacheServiceInstance “cacheHostInfo is null”

Again, I get an error after I run “Remove-SPDistributedCacheServiceInstance”

“cacheHostInfo is null”

I can’t start Distributed Cache Service on SharePoint Central Administration, even I’ve run “Add-SPDistributedCacheServiceInstance”.
So, I realize that it happened because there is no cacheHost in SPDistributedCacheHostInfoCollaction but we can fix it with this script
here’s the script

$SPFarm = Get-SPFarm
$cacheClusterName = "SPDistributedCacheCluster_" + $SPFarm.Id.ToString()
$cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local
$cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName);
$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq $env:computername}

if([System.String]::IsNullOrEmpty($cacheClusterInfo.CacheHostsInfoCollection))
{
	#here's the key. we can't provision, unprovision, start, or stop a Cache Service because we still have a Cache Service that have no server attached  
	$serviceInstance.Delete()
	Add-SPDistributedCacheServiceInstance
	$cacheClusterInfo.CacheHostsInfoCollection
}

and problem is solved… :D

Hope this is helpful

Raka Satria

About these ads

37 thoughts on “SharePoint 2013 SPDistributedCacheServiceInstance “cacheHostInfo is null”

      • It did! I got the Cache back to functional levels after I had managed to royally mess it up. In the end it was the simple service account permissions like 90% of all posts mention. I was just barking up the wrong tree the whole time as I had mixed up my accounts.

      • There are lots of cache info null posts out there. Why not post some messages on some forums? Your ps script works a charm.

      • Sure, I will post some message on some forums even though I did it at Technet Forum and they marked it as an answer.
        Thanks, I’m just happy if i can solve my clients’ problems

  1. How can I execute this script? I tried to save text file with ps1 extension and run with powershell but got bunch of error with red text

  2. I get this error when I use the script. I have tried to change the user for the service but it still gives an error.

    Add-SPDistributedCacheServiceInstance :
    ErrorCode:SubStatus:Service running under Network
    Service account in workgroup environment is not supported.

    • From the error you got, I know that somehow your DistributedCacheService are using NetworkService Account, Please use this script to change your service account

      $CacheService = (Get-SPFarm).Services | ? {$_.Name -eq AppFabricCachingService”}
      $ServiceAccount = Get-SPManagedAccount -Identity "DOMAIN\FarmAccount"
      $CacheService.ProcessIdentity.CurrentIdentityType = “SpecificUser”
      $CacheService.ProcessIdentity.ManagedAccount = $ServiceAccount
      $CacheService.ProcessIdentity.Update()
      $CacheService.ProcessIdentity.Deploy()
      

      after that you can run my blog’s script

      • Thanks Raka for your great post, I think I am nearly there with getting my Distributed Cache Service sorted but one issue that I am having is with the line in your script above;

        $ServiceAccount = Get-SPManagedAccount -Identity

        This returns an error to me;

        Get-SPManagedAccount : Missing an argument for parameter ‘Identity’. Specify a
        parameter of type ‘Microsoft.SharePoint.PowerShell.SPManagedAccountPipeBind’
        and try again.

        Any suggestions?

        Also in the following line of the script I presume “specific user” should be replaced with the account that the cache service process should run under. Can you confirm this.

        Thanks again for the great posts.

      • I have got this working down as far as $CacheService.ProcessIdentity.Deploy()

        But now I am getting the original error returned from the command, ie cacheHostInfo is null

        Any thoughts?

      • Please Run this

        $CacheService = (Get-SPFarm).Services | ? {$_.Name -eq AppFabricCachingService”}
        $ServiceAccount = Get-SPManagedAccount -Identity "DOMAIN\FarmAccount"
        $CacheService.ProcessIdentity.CurrentIdentityType = “SpecificUser”
        $CacheService.ProcessIdentity.ManagedAccount = $ServiceAccount
        $CacheService.ProcessIdentity.Update()
        $CacheService.ProcessIdentity.Deploy()
        

        then this

        $SPFarm = Get-SPFarm
        $cacheClusterName = "SPDistributedCacheCluster_" + $SPFarm.Id.ToString()
        $cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local
        $cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName);
        $instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
        $serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq $env:computername}
        
        if([System.String]::IsNullOrEmpty($cacheClusterInfo.CacheHostsInfoCollection))
        {
        	#here's the key. we can't provision, unprovision, start, or stop a Cache Service because we still have a Cache Service that have no server attached  
        	$serviceInstance.Delete()
        	Add-SPDistributedCacheServiceInstance
        	$cacheClusterInfo.CacheHostsInfoCollection
        }
        
      • Have worked through the Technet article and the script in the blog post but am being stumped by the cacheHostInfo is null message when I run the Deploy command in the above for changing the Service Account to a Farm Admin Acct.

        I notice when I run Get-SPServiceInstance that the Distributed Cache Service Instance Status is Disabled and the Properties are empty (). When I try to delete the instance with

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

        I get OverloadDefinitions / void Delete

        Really at a roadblock with this one.

      • Hmmm, I just curious what exactly happen there. If I’m there. I will do some scripts to make sure the root cause. Sorry I can’t help because I can’t imagine your problem therefore I can’t find the root cause.

  3. Pingback: Piano Portal

  4. Pingback: SharePoint2013.DistributedCacheService.Neuinstallation | Tobias Wolter IT- Solutions & Consulting

  5. Awesome work Raka!
    This did the trick….
    In the future I would like to reference this in my blog and give you proper credit, given you’re OK with that.
    Cheers!

  6. I am not having any issues getting the script to run, however I am still not able to start the service or remove it from my two other servers. Even when I click on app fabric setup, the two servers say “This is not a memeber for the cluster app fabric” At this point I do not need the distributed cache if I can just get it removed. But having it would be nice :-)

  7. Raka,

    I think I may have found the problem or issue, but not sure how to resolve it just yet. I noticed that in order to run distributed cache, you must use enterprise or higher. Wellllllllll I am using Server 2012 standard and of course there is not Enterprise….so not sure how to fix this yet or at least get it from showing the errors. Anyone else have any recommendations?

  8. Pingback: Cannot Remove Server Reference from Farm: CacheHostInfo is null | Summit 7 Systems

  9. Hi Raka when i execute your script the command Add-SPDistributedCacheServiceInstance send me this error (the first time only) “Add-SPDistributedCacheServiceInstance :
    ErrorCode:SubStatus:Service running under Network
    Service account in workgroup environment is not supported.
    At line:1 char:1
    + Add-SPDistributedCacheServiceInstance
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (Microsoft.Share…ServiceInstance:
    SPCmdletAddDist…ServiceInstance) [Add-SPDistributedCacheServiceInstance]
    , CmdletInvocationException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletAddDistr
    ibutedCacheServiceInstance”

    then the variable “$cacheClusterInfo.CacheHostsInfoCollection” is always empty. Do you know why ?
    Best regards

      • Hi Raka, thank you so much for your help, i think that i don’t really need Distribution cache service in my development approach. I juste want to deploy apps from VS2012 to SP2013 install on a Virtual Machine running windows server 2012. I juste wanna develop and test in a “local way”. So when i ttry to deploy a simply hello world apps i obtain this mess: “The load balancer is not provisioned. Verify the load balancer was provisioned successfully before retrieving endpoint addresses. ” and the same thing when i try to deploy my apps with sharepoint interface.
        Regards

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s