While starting Distributed Cache service, I got this ugly message "cacheHostInfo is null"
After googling, I found different solutions but the better one was posted by rakasatria as follows:
Here $cacheClusterInfo giving me value. and the above code will only run when this variable will be empty.
So I removed if condition and left rest as it is.
After googling, I found different solutions but the better one was posted by rakasatria as follows:
$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}
But it's not working for me.
Then I traverse the script to found the issue. For this I have done following:
$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}
Write-Host $cacheClusterInfo -ForegroundColor DarkCyan
if([System.String]::IsNullOrEmpty($cacheClusterInfo.CacheHostsInfoCollection))if{ #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}Here $cacheClusterInfo giving me value. and the above code will only run when this variable will be empty.
So I removed if condition and left rest as it is.
$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}
Write-Host $cacheClusterInfo -ForegroundColor DarkCyan
$serviceInstance.Delete() Add-SPDistributedCacheServiceInstance $cacheClusterInfo.CacheHostsInfoCollection
And now it worked!!!!
Your solution saved my life!
ReplyDeleteThis comment has been removed by the author.
DeleteThanks, saved my time :)
ReplyDeleteYour solution worked perfectly...You saved my life too
ReplyDeleteYou are a Jedi, dude! Thank's a lot!
ReplyDeleteThanks for your appreciation
Deleteworking this issue for more than 4 days and finally solved using your tip. Thanks a zillion !!!! :)
ReplyDeleteThank you, Thank you, Thank you...you saved my bacon!
ReplyDeleteThanks
ReplyDelete