SharePoint Blog

Adding a local SharePoint 2013 (development server) as a cache host to AppFabric’s cache cluster

UPDATE If you’re landed at this page, you’re probably stuck with a SharePoint 2013 installation that is causing you headaches. If that’s the case you may want to read this post first: http://www.sharepointconsultant.ch/2013/03/12/configuring-my-sharepoint-2013-development-environment-with-only-6-gb/

Having just installed SharePoint 2013 my eye was struck by an anoying error report:

Image

Apparently, SharePoint 2013 had some trouble displaying the microfeed. Digging a little deeper I found many errors in the Event Log e.g.

Application: DistributedCacheService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.UriFormatException
Stack:
at Microsoft.ApplicationServer.Caching.VelocityWindowsService.StartServiceCallback(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

Further reading through the event log made me aware that the Distributed Cache Service was not able to start because it demands by default 10% of available physical memory. Having installed SQL and SharePoint on a single server with 6 GB clearly would not work. Luckily I quickly found the following blog entry http://spvee.wordpress.com/2012/09/25/managing-memory-allocation-for-distributed-cache-in-sharepoint-2013/ and thought my troubles were over. Wrong!

I fired up PowerShell and typed

Use-CacheCluster
Set-CacheHostConfig -Hostname SP2013 -cacheport 22233 -cachesize 300

I tried other commands e.g.

start-cachehost
restart-cachecluster
Get-CacheHostConfig -ComputerName SP2013 -CachePort 22233

But all I would get was

Get-AFCacheHostConfiguration : ErrorCode<ERRCAdmin010>:SubStatus<ES0001>:Specified host is not present in cluster.
At line:1 char:1
+ Get-AFCacheHostConfiguration -ComputerName SP2013 -CachePort "22233"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AFCacheHostConfiguration], DataCacheException
+ FullyQualifiedErrorId : ERRCAdmin010,Microsoft.ApplicationServer.Caching.Commands.GetAFCacheHostConfigurationCommand

For some reason or another, my server wasn’t registered as a cachehost in the first place. I downloaded and studied Microsoft’s Windows Server AppFabric Caching Deployment and Management Guide and it quickly appeared to me that I needed to manually add my server as a cachehost as follows:

Register-CacheHost -Provider %PROVIDER% -ConnectionString %CONNECTION STRING% -Account "NT Authority\Network Service" -CachePort 22233 -ClusterPort 22234 -ArbitrationPort 22235 -ReplicationPort 22236 -HostName SP2013

However, I had no clue what to enter as the provider and the connnection string. It turns out that SharePoint Distributed Cache cluster configuration info can be found in a file named “DistributedCacheService.exe.config” that is stored in the “AppFabric 1.1 for Windows Server” folder. As a provider I had to enter “SPDistributedCacheClusterProvider” and the connnection string value needed to point to SharePoint’s config database e.g. “Data Source=SP2013\SQLExpress;Initial Catalog=SharePoint_Config;Integrated Security=True;Enlist=False”. However, even though these values can be found here, they are in fact stored in the registry here: HKLM\Software\Microsoft\AppFabric\V1.0\Configuration. If for some reason information cannot be found here, your distributed cached will error out stating “Error in reading provider and connection string values”. I also noticed that in this config file the host name was called “localhost”. I changed this to “SP2013″ (However, I don’t believe it’s supported to update out-of-the-box files). Finally my server was added as a cachehost to AppFabric cachecluster but it refused to start …

HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
SP2013.FUTURAMA.LOCAL:22233 AppFabricCachingService DOWN 3 [3,3][1,3]

Of course I still needed to trim its out-of-the-box memory requirements as follows:

Set-CacheHostConfig -Hostname SP2013 -cacheport 22233 -cachesize 300

Now finally things started to work …

HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
SP2013.FUTURAMA.LOCAL:22233 AppFabricCachingService UP 3 [3,3][1,3]

If you’re really unlucky and the Windows AppFabric Caching Service has encountered too many errors, its startup mode may have been set to Disabled. In that case you need to change it back to Automatically. However, don’t start the service using the Windows Service Configuration panel. Instead, once you applied all changes, simply type:

Restart-CacheCluster

It seems the Distributed Cache Service will cause us a few headaches in the years to come, still … It’s a great solution for problem that has been around for too long!

  • http://www.SharePointpapa.com/ Stacy

    Excellent Post! thank you very much for this, the concepts provided here work on SharePoint 2016, and I referenced your post in a post I made on anothersharepointblog.com, thanks Again, really appreciate this!

Copyright ©2012. All Rights Reserved.