Freigeben über


How to rename the App Fabric service after renaming the server.

Issue:

People generally rename the server without removing it from the AppFabric cache cluster. This causes the app fabric instance to no longer work correctly and it goes to a “DOWN” or “UNKNOWN” state.

 PS C:\Users\> get-cachehost
get-cachehost : ErrorCode:SubStatus:Cache host old_name.domain is not reachable. 
At line:1 char:1 + get-cachehost + ~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (:) [Get-AFCacheHostStatus], DataCacheException     + FullyQualifiedErrorId : ERRCAdmin039,Microsoft.ApplicationServer.Caching.Commands.GetAFCacheHostStatusCommand

HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
old_name.domain:22233 AppFabricCachingService UNKNOWN    0 [0,0][0,0]

 

Attempts to remove the old host will not succeed because the machine is no longer reachable as its name has now changed.

If you try to export the cache cluster configuration and edit the host name, you will get the following error while trying to import it back.

 PS C:\Users\> Import-CacheClusterConfig c:/config.xml 
Import-CacheClusterConfig : Object reference not set to an instance of an object. 
At line:1 char:1 + Import-CacheClusterConfig c:/config.xml + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (:) [Import-AFCacheClusterConfiguration], NullReferenceException     + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.ApplicationServer.Caching.Commands.ImportAFCacheClusterConfiguration    Command

 

Solution

Please follow the following steps to rename the App Fabric service correctly.

1. Open your HOSTS file in notepad (C:\Windows\System32\drivers\etc\hosts)
 add: ‘IP_of_the_machine      old_server_name’

2. Add the current computer as a host:
 Add-CacheHost -providertype …* -connectionstring …*

**If you are not aware of the provider type or connection string, you can find them here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppFabric\V1.0\Configuration

3. Register the current computer as a host in the cluster:
 Register-CacheHost -providertype …* -connectionstring …*

4. Stop the App Fabric cache cluster:
 Stop-CacheCluster

5. Export the cluster configuration:
 Export-CacheClusterConfig “c:/config.xml”

6. Edit the exported cluster configuration file:
 remove the ‘host’-tag that contains the old server name and save the file as “config_edited.xml”

7. Update configuration settings:
 Set-CacheHostConfig -HostName server_name.domain.local -Port 22233

8. Change the context:
 use-CacheCluster

9. Import the edited cluster configuration file:
 Import-CacheClusterConfig -file “c:/config_edited.xml”

10. Remove entry from HOSTS file which was made earlier.

11. Start the App Fabric cache cluster:
  Start-CacheCluster

 

This should now bring the App Fabric service to an UP and running state. Do a get-CacheHost to confirm.

 

Hope this helps!
Saurav Dey (MSFT)