Remove Server Node from Cache
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:
Mirrored Cache
In Mirrored cache, data resides in both nodes. So when the active node leaves the cluster, the passive node becomes active and handles all incoming client requests. If passive nodes leaves, there is no visible change 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 these server nodes i.e. 20.200.20.29 and 20.200.20.30, and the server node 20.200.20.30 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.30 in this case) through 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 these 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.30.
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"/>
</servers>
</cache-deployment>
</cache-config>
Step 3: Restart NCache Service
For the configuration changes made to take effect, restart NCache Service:
- Windows:
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 PowerShell as administrator, otherwise you might get an error message that "Cannot open ncachesvc service on computer".
Execute the following command in PowerShell 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 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 i.e. 20.200.20.29 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 the remaining server.
For example, <server-node ip="20.200.20.30"/>
is removed from the <servers>
list of the remaining server node 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"/>
</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 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.
See Also
Create a Cache
Remove Cache
Add Server Node
Update Cache Config