Remove Server Node
Note
A cache can be removed at runtime without stopping the cache.
NCache cluster is dynamic and supports removing server nodes from a running cache cluster at runtime. When a cache server is removed, the existing cache cluster automatically updates its cluster membership and notifies all the clients about it.
Topology specific behavior on removing a cache server is mentioned below:
Partitioned Cache
In Partitioned Cache, data is partitioned among all the running cache servers. So when a cache server leaves the cluster, data residing on the cache server that is leaving is lost. Data distribution map also changes and cache clients are notified about the removal of this cache server.
Replicated Cache
In Replicated Cache, each cache server holds the same set of data. So no data loss occurs when a cache sever is removed from the cluster. However, all the clients that were connected to this leaving cache server detect this and move on to connect to other servers in the cluster.
A server node can be removed from the clustered cache at any time. The cache needs to be stopped before removing a node from a cluster.
For NCache Open Source Edition, you can manually edit config.ncconf and client.ncconf located at %NCHOME%/config. %NCHOME% is NCache install directory. These files can be edited through any text editor of your choice.
Consider a cache named demoClusteredCache registered on three server nodes i.e. 20.200.20.29, 20.200.20.30 and 20.200.20.31, and the server node 20.200.20.31 needs to be removed from the cluster.
Configuration for Node to Be Removed
Step 1: Stop Cache
Stop the cache on the server node which is to be removed (20.200.20.31 in this case) through Windows PowerShell using the Stop-Cache cmdlet.
Stop-Cache -Name demoClusteredCache
Step 2: Remove Cache Configuration from config.ncconf
The configuration files of all server nodes contain the information of all three server nodes. In order to remove a node from the cache, remove the entire configuration of the cache from config.ncconf of the node to be removed.
For example, in this scenario, the entire configuration of the cache demoClusteredCache in the <cache-config>
section will be removed from 20.200.20.31.
Important
Note that the server IPs and cache name will be according to your own environment.
<cache-config cache-name="demoClusteredCache">
...
<cache-deployment>
<servers>
<server-node ip="20.200.20.29"/>
<server-node ip="20.200.20.30"/>
<server-node ip="20.200.20.31"/>
</servers>
</cache-deployment>
</cache-config>
Step 3: Restart NCache Service
For the configuration changes made to take effect, restart NCache Service using Windows PowerShell. Make sure you have enough privileges to restart the service. If the user is not the part of the Administrator's group, make sure to run Windows PowerShell as administrator, otherwise you might get an error message that "Cannot open ncachesvc service on computer".
Execute the following command to restart NCache Service:
Restart-Service -Name NCacheSvc
Step 4: Verify Successful Removal of Cache
In order to verify that the node is removed from the clustered cache, open Windows PowerShell and use Get-Caches cmdlet on the server node.
Get-caches
If the server node is successfully removed, the list will not contain the name of the cache demoClusteredCache.
Configuration for Remaining Nodes
Step 5: Update Configuration
Once the node has been removed from the cache, you need to update the <cache-deployment>
configuration on the remaining nodes of the cluster (20.200.20.29 and 20.200.20.30 in this case).
To remove a server node from a cache cluster, remove the <server-node>
tag containing the removed node IP within the <cache-deployment>
section in config.ncconf of both the remaining servers.
For example, <server-node ip="20.200.20.31"/>
is removed from the <servers>
list of the remaining two server nodes in the following sample configuration.
Important
Note that the server IPs and cache name will be according to your own environment.
<cache-config cache-name="demoClusteredCache">
...
<cache-deployment>
<servers>
<server-node ip="20.200.20.29"/>
<server-node ip="20.200.20.30"/>
<server-node ip="20.200.20.31"/>
</servers>
</cache-deployment>
...
</cache-config>
Important
Repeat this step for all server nodes.
Step 6: Remove server node from client.ncconf
Once the node is removed from config.ncconf, you need to update client.ncconf. In client.ncconf of EACH server node, remove the configuration of the server node.
Please refer to the Remove Client from Cache section for more detail.
Step 7: Verify Successful Node Removal
In order to verify successful removal of the server node from the cache, open Windows PowerShell and use Get-Caches cmdlet with -Detail
parameter which displays all caches registered on the server and their respective servers along with additional information.
Get-Caches -Detail
If the node has been successfully removed from the cache, the list will display the Cluster Size
for the cache along with all registered nodes. The node which has been removed will not exist in the list now. If it does, there might have been some mistake while changing configuration or NCache Service may not have been restarted.
Important
Repeat this step for all server nodes.