Product Documentation

Create a NetScaler Cluster

Nov 05, 2013

After completing this tutorial you will be able to create a two-node NetScaler cluster. To add more appliances to the cluster you must repeat the procedure that adds and joins the node to the cluster.

Sample Code

For the executable code, see the <NITRO_SDK_HOME>/sample/CreateCluster.cs sample file.

To create a cluster

  1. Copy the libraries from <NITRO_SDK_HOME>/lib folder to the project classpath.
  2. Create a new class and name it CreateCluster.
  3. Log on to one of the appliances that you want to add to the cluster and create a cluster:
    //Connect to the first appliance that you want to add to the cluster 
    nitro_service nonClipSession0 = new nitro_service(nsipAddress0,protocol); 
    //Create a cluster instance 
    clusterinstance newClusterInstance = new clusterinstance(); 
    newClusterInstance.clid = 1; 
    //Add the appliance to the cluster 
    clusternode ClusterNode0 = new clusternode(); 
    ClusterNode0.nodeid = 0; 
    ClusterNode0.ipaddress = nsipAddress0; 
    ClusterNode0.state = "ACTIVE"; 
    ClusterNode0.backplane = "0/1/1"; 
    //Add the cluster IP address 
    nsip newNSIPAddress = new nsip(); 
    newNSIPAddress.ipaddress = clipAddress; 
    newNSIPAddress.netmask = ""; 
    newNSIPAddress.type = "CLIP"; 
    //Enable the cluster instance 
    clusterinstance.enable(nonClipSession0, newClusterInstance); 
    //Save the configurations 
    //Warm reboot the appliance 

    The cluster is created and the first node is added to the cluster. This node becomes the initial configuration coordinator of the cluster.

  4. Log on to the cluster IP address to add other appliances to the cluster:
    //Connect to the cluster IP address 
    nitro_service clipSession = new nitro_service(clipAddress,protocol); 
    //Add the node to the cluster 
    clusternode ClusterNode1 = new clusternode(); 
    ClusterNode1.nodeid = 1; 
    ClusterNode1.ipaddress = nsipAddress1; 
    ClusterNode1.state = "ACTIVE"; 
    ClusterNode1.backplane = "1/1/1"; 
    //Save the configurations 
  5. Log on to the appliance that you added in the previous step and join it to the cluster:
    //Connect to the node that you have just added to the cluster 
    nitro_service nonClipSession1 = new nitro_service(nsipAddress1,protocol); 
    //Join the node to the cluster 
    cluster newCluster = new cluster(); 
    newCluster.clip = clipAddress; 
    newCluster.password = password; 
    //Save the configurations 
    //Warm reboot the appliance 

    The second node is now a part of the cluster.

  6. Verify the details of the cluster by logging on to the cluster IP address
    //Retrieving the cluster node details 
    uint id = 1; 
    clusternode node= clusternode.get(clipSession, id); 
    System.Console.Out.WriteLine("Node ID: " + node.nodeid + " | Admin state: " + node.state + " | Backplane interface: " + node.backplane); 
    //Retrieving the cluster instance details 
    uint id1 = 1; 
    clusterinstance instance= clusterinstance.get(clipSession, id1); 
    System.Console.Out.WriteLine("Cluster instance ID: "+ instance.clid + " | Operational state: " +instance.operationalstate);