Thursday, October 24, 2013

SharePoint 2013: Distributed Cache

Wow! I found my new enemy within the SharePoint world: Distributed Cache. Please step down from your throne, User Profile Service.
But how was that even possible?
Well, it started with a small, new SharePoint 2013 Farm, just enough power to run as a testing system. I wanted to use the Distributed Cache on the App as well as on the WFE. But everytime I tried to start the Service under /_admin/Server.aspx ( CA -> System Settings -> Manage services on server) I got this message:

So, what did I do? A lot. The next steps are the ones, that "fixed" my problem, which means, that I will not use Distributed Cache on my WFE but only on the App Server.

TechNet suggests that I should repair the Cache and be done with. So I used their example:
$s = Get-SPServiceInstance GUID
But that did nothing, except throwing a couple of errors. Maybe I got the GUID wrong, so I tried it without one:
$instanceName = "SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {( $_.service.tostring()) –eq $instanceName –and ($ –eq $env:computername}
 At least I didn't get an error. I checked id the ServerInstance was really removed:
Get-SPServiceInstance >> C:\Service.txt

Well. It's just the App Server there. And I'm honestly not sure if that is the way it's supposed to look like. But it would make sense, because I still have a ServerInstance running on my App Server. To be sure, that I don't have anything running, I'm trying to stop the service with this command:
Stop-SPDistributedCacheServiceInstance -Graceful

I'd say: I can't stop the ServiceInstance, because it does not exist. Which is great! It is gone, finally.
And now, we can remove the Service Instance:
I got no error message while writing this blogpost. When I was trying this before, I got a lot of errors, most of them were about "cachehostinfo is null".
If you check your CA now, you will notice, that the Distributed Cache Service was removed from the services on service page of the server, the WFE in my case.
Next step would be to add a ServiceInstance again, which you have to do with this code:
Finally I got another error message, it's been a while. Also I'm starting to hate Distributed Cache.

I guess it's in use because of AppFabric. But why should that be a problem? Distributed Cache is based on AppFabric and as far as I know, you are not supposed to configure anything in AppFabric. So: what now?
In my case it meant to retrace my step, right to where I tried to add the ServiceInstance again.

After that, I tried all those links at the bottom. But none helped me with this problem. I tried for two days to get the Distributed Cache to work on my WFE, after that I gave up. I stop the ServiceInstance, removed the ServiceInstance and unregistered the WFE from the Cache:
Unregister-CacheHost -HostName 'HName' -Provider 'PName' -ConnectionString 'CString'
You can find the information for provider and connectionstring in the registry of the working server:
 Don't forget to do an IIS reset or you might get shocked from the IIS screen.

If anyone has a different solution, that is not one of the many posted below, please feel free to contact me!

And here are the references used, which are a lot. But sadly none of them fixed my problem.

No comments:

Post a Comment