Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Index     Next Next

Responding to Cluster Notifications by Modifying the Cluster

You can use the CMM API to respond to notifications received from the nhcmmd daemon that indicate a change in the cluster. In response to these notifications, it might be necessary to remove or disqualify a node or to trigger a switchover or a failover.

This section contains these topics:

Removing or Excluding a Node

A node can be removed from the cluster by using the cmm_membership_remove() function. The cmm_membership_remove() function temporarily takes the current node out of the cluster by giving it the CMM_OUT_OF_CLUSTER role and all other peer nodes learn that it is not an active peer node.

A node with this role is not actually excluded from the cluster. It is still configured to be in the cluster. For an explanation of this role, see Membership Roles.

If you want to exclude a node completely from the cluster, first use the cmm_membership_remove() function to remove the role from the cluster. Then remove the entry for this node from the cluster node table. It is better to remove the node completely from the cluster node table instead of attributing the node with an excluded value (X) in the cluster_nodes_table file. For more information, see the cluster_nodes_table(4) man page.

The nhcmmd issues notifications of the node's exclusion. For more information, see Triggering a Failover by Using the cmm_membership_remove() Function.

Removing the Master Node

Removing the master node must be done in two stages so as to avoid triggering a failover. First, the node that is master should be released from the role of master by using the cmm_mastership_release() function. This triggers a switchover. Only then should the node be removed from the cluster. The node is removed from the cluster by calling the cmm_membership_remove() function from the node. This gives the node the CMM_OUT_OF_CLUSTER role, effectively taking the node out of the cluster. For more information about how to trigger a switchover, see Triggering A Switchover. For an explanation of the notifications sent when you trigger a switchover, see Switchover Notifications.

If the cmm_membership_remove() function is called directly from the master node, without first triggering a switchover to a qualified vice-master node, then a failover is triggered.


Caution Caution - Triggering a failover should be done for test purposes only.


For more information about how to trigger a failover, see Triggering A Failover.

For an explanation of the notifications sent when you remove the master role with the cmm_membership_remove() function, see Table 6-15. For an explanation of the notifications sent when you trigger a failover, see Failover Notifications.

Removing the Vice-Master Node

When the cmm_membership_remove() function is called by a system service on the vice-master node, the function removes the vice-master node from the cluster. If the vice-master is removed from the cluster, the cluster no longer has 2N redundancy.

You can remove the vice-master node for maintenance purposes. If you want to perform maintenance on both master-eligible nodes, remove the vice-master and carry out the maintenance. Then trigger a switchover, remove the new vice-master and perform the maintenance tasks on this node. For more information, see the Netra High Availability Suite Foundation Services 2.1 6/03 Cluster Administration Guide.

For an explanation of the notifications sent when you remove the vice-master node with the cmm_membership_remove() function, see Table 6-9.

Removing a Diskless Node

If the cmm_membership_remove() function is called by a system service on a diskless node, the function removes the diskless node from the cluster. This action has no effect on the role of other nodes in the cluster.

Setting the Qualification of a Node

The cmm_member_setqualif() function sets the qualification of a node. Qualification level is only relevant for master-eligible nodes. This function can only be called from the master node. The nodeid and the qualification level must be provided as input parameters to this function. The nodeid of the current node can be retrieved by using the cmm_node_getid() function.

The following example demonstrates how to use the cmm_member_setqualif() function to disqualify a node with the nodeid 12.

Example 7-3 Disqualifying a Node

if (cmm_member_setqualif (12, CMM_DISQUALIFIED_MEMBER) != CMM_OK) 
			  	  /* handle the error  */;

The following example demonstrates how to use the cmm_node_getid() and cmm_member_setqualif() functions.

Example 7-4 Requalifying a Node

#include <cmm.h>
#include <stdio.h>
#include <sys/types.h>       /* for boolean_t */
#include <stdlib.h>          /* for exit(), atoi() */
#include "common.h"

/******************************************************************/
int get_id(cmm_nodeid_t *P_NodeId)
{
    int          success;
    char         str_node[10];
    boolean_t    go_on = B_TRUE;

    while (go_on == B_TRUE) {
        printf("Your node [0 for abort]: ");
        success = (scanf("%9s", str_node) != 0);
        if (success) {
            *P_NodeId = atoi(str_node);
            if (*P_NodeId >= 0)
                go_on = FALSE;
        }
    }
    return (*P_NodeId==0)?FALSE:TRUE;
}
/*******************************************************************/
/*******************************************************************/
int ask_for_qualif(cmm_qualif_t *P_NewQualif)
{
    char         L_Choice[20] ;

    puts("Your qualif:  o Q  qualif") ;
    puts("              o D  disqualif")
    printf("your choice: ") ;
    scanf("%6s", L_Choice) ;
    if (strcasecmp(L_Choice,"Q") == 0)
        *P_NewQualif = CMM_QUALIFIED_MEMBER ;
    else if (strcasecmp(L_Choice,"D") == 0)
        *P_NewQualif = CMM_DISQUALIFIED_MEMBER ;
    else
    {
        printf("bad qualif: [%s]",L_Choice ) ;
        return FALSE ;
    }
    return TRUE ;
}

/*******************************************************************/
void main(void)
{
    cmm_error_t  res;
    cmm_nodeid_t onenode;
    cmm_qualif_t newqualif;

    if (!get_id(&onenode))    {
        printf("abort\n");
        exit(0);
    }

    if (!ask_for_qualif(&newqualif)) {
        printf("abort\n");
        exit(0);
    }

    if ((res = cmm_member_setqualif(onenode, newqualif)) != CMM_OK) {
        fprintf(stderr, 
            "ERROR: Failed to set qualif (Error: %s)\n", 
            cmm_strerror(res));
    }
}

Previous Previous     Contents     Index     Next Next