HOW TO: How to Create a Cache?

Transcription

HOW TO: How to Create a Cache?
HOW TO: How to Create a Cache?
Creating a cache using command line tools:
NCache provides a complete set of command line tools helping administrators to manage, monitor, and automate NCache
tasks from command prompt. In this guide we'll learn simple steps to automate NCache cache creation process through a
batch script. In cache setup process, we'll first create the cache with some defined configurations and then we'll add cache
servers and remote clients to it which will be able to access NCache cluster remotely.
Cache creation process can be scripted with the help of these NCache command line tools (Start->All Programs->NCache>Admin Tools) and we will mainly use three command line tools here to create a cache cluster and client nodes.
1.
CreateCache
2.
AddNode
3.
AddClientNode
Create a Cache using "CreateCache" tool:
The createcache utility allows you to register a new cache on a server. Here are basic details of Createcache tool and its
arguments.
Argument
cache-id
Description
Specifies an id of the cache to be registered on the server.
Option
Description
/s server-name
Specifies a server name where the NCache service is running. The default is the local machine.
/p port
Specifies the port if the server channel is not using the default port. The default TCP port is 8250.
/size cache-size
Specifies the size(MB) of the cache to be created. The default size is 250 MB
/evict-policy
Specifies the eviction policy for cache items. Cached items will be cleaned from the cache according to
/e eviction-policy
the specified policy if the cache reaches its limit. The default eviction policy is Priority.
/ratio
Specifies the eviction ratio (Percentage) for cache items. Cached items will be cleaned from the cache
/r eviction-ratio
according to the specified ratio if the cache reaches its limit. The default eviction ratio is 5%.
/interval
Specifies the time interval (seconds) after which cache eviction is called. The default interval is 15
/i clean-interval
seconds.
/topology
/t topology-name
/cluster-port
/c port of cluster
/def-priority
/d default-priority
/uid user-id
/pwd password
Specifies the topology in case of clustered cache. The default topology is local-cache.
Specifies the port of the server, at which server listens. The default port is 8250.
Specifies the default priority in case of priority based eviction policy. The default priority is Normal.
User-id is required when security is enabled on Cache Server. user-id must be the active directory userid prefixed with the domain name.
Specifies password to authorize the user, when security is enabled on Cache Server, for starting
Option
Description
NCache. This password must be the same as the active directory user password.
/nologo
Suppresses the display of logo banner.
/?
Displays command syntax and options for the utility.
Please note that create cache creates a cache on any server that you specify in its arguments. More nodes can be added to
this cache to form a cache cluster by using Addnode command line tool.
Add a Cache Server using "Addnode" tool:
This addnode utility allows you to add a node to an existing clustered cache. The effect of this utility is that the configuration
of the cache is added to the specified server and is updated on all other nodes indicating that this server has become a part
of the clustered cache.
addnode cache-id /e[existing] server-name1 /n[new] server-name2 [option[...]]
Argument
Description
cache-id
Specify id of the clustered cache to which the node will be added.
/e [existing] server-
Specify a server-name where NCache service is running and a clustered cache with the specified
name1
cache-id is registered.
/n [new] server-name2
Specify the server-name where NCache service is also running which is to be added in the already
existing clustered cache.
Option
/p port
/uid user-id
/pwd password
Description
Specifies port if the server channel is not using the default port. The default TCP port is 8250.
User-id is required when security is enabled on Cache Server. user-id must be the active directory
user-id prefixed with the domain name.
Specifies password to authorize the user, when security is enabled on Cache Server, for starting
NCache. This password must be the same as the active directory user password.
/nologo
Suppresses the display of logo banner.
/?
Displays command syntax and options for the utility.
Batch Script to create a cache:
Please refer to below script that first creates a cache using CreateCache tool by specifying the caching topology, cache size
and all the relevant required cache configurations. It then uses the "Addnode" command line tool to add another node to this
already created cache to form a cache cluster of two nodes.
@echo off
REM General Cache configuration
@SET CACHE_ID="clusteredSessionCache"
@SET SERVER_NAME="20.200.20.109"
@SET CACHE_SIZE=1024
@SET EVICTION_POLICY="LFU"
@SET EVICTION_RATIO=5
@SET CLEAN_INTERVAL=15
@SET CACHING_TOPOLOGY="partitioned-replicas-server"
@SET REPLICATION_STRATEGY="async"
@SET CLUSTER_PORT="7800"
@SET EVICTION_PRIORITY="normal"
REM Cache Servers to add in the cluster
@SET SERVER1="20.200.20.109"
@SET SERVER2="20.200.20.108"
REM Specify Remote clients here
@SET CLIENT_NODE1="20.200.20.109"
@SET CLIENT_NODE2="20.200.20.108"
@SET CLIENT_NODE3="20.200.20.107"
@SET CLIENT_NODE4="20.200.20.106"
REM Creating Clustered Cache
CREATECACHE %CACHE_ID% /s %SERVER_NAME% /size %CACHE_SIZE% /e %EVICTION_POLICY% /r
%EVICTION_RATIO% /i %CLEAN_INTERVAL% /t %CACHING_TOPOLOGY% /rs %REPLICATION_STRATEGY%
/c %CLUSTER_PORT% /d %EVICTION_PRIORITY%
REM Adding Cluster Nodes
AddNode %CACHE_ID% /e %SERVER_NAME% /n %SERVER2%
REM Adding Client Nodes
ADDCLIENTNODE %CACHE_ID% /s %SERVER1% /c %CLIENT_NODE1%
ADDCLIENTNODE %CACHE_ID% /s %SERVER1% /c %CLIENT_NODE2%
ADDCLIENTNODE %CACHE_ID% /s %SERVER1% /c %CLIENT_NODE3%
ADDCLIENTNODE %CACHE_ID% /s %SERVER1% /c %CLIENT_NODE4%
@PAUSE