Adding Oracle Agent As A Resource To The Clusterware

Normally when we have an agent we usually include it in the starting and stopping of the machine. This is usually correct in systems standalone, but if we have a CRS it is not perhaps the most appropriate. It is more serious include the agent as a resource in the CRS itself, this We provides a number of advantages, such as controlling agent to be available at all times and the startup automatic of the agent If it falls. In this example it is assumed that each node in the cluster has its own agent, the agent will never travel (from a node to other one), it will be a resource that resides only on a machine.

Another option is to have a single agent and clusterware used as an active/passive, and the agent is associated with the resource database and is promoted between all the machines that are part of the cluster.

The following script, perl, which performs three basic actions that need the clusterware to run. These are

  • start; to start the resource
  • stop; to stop the resource
  • check; to check if resource available
#!/usr/bin/perl

# Home for binaries
$ORACLE_HOME = "/agent11/";

if ($#ARGV != 0 ) {
        print "usage: start stop check required \n";
exit;
}
$command = $ARGV[0];

# Start Agent
if ($command eq "start" ) {
        system ("
        ORACLE_HOME=$ORACLE_HOME
        export ORACLE_HOME

        $ORACLE_HOME/bin/emctl start agent" );
        exit 0;
}
# Stop Agent
if ($command eq "stop" ) {
        system ("
        ORACLE_HOME=$ORACLE_HOME
        export ORACLE_HOME

        $ORACLE_HOME/bin/emctl stop agent" );
        exit 0;
}
# Check Agent
if ($command eq "check" ) {
        system ("
        ORACLE_HOME=$ORACLE_HOME
        export ORACLE_HOME

        $ORACLE_HOME/bin/emctl status agent" );
        
        if ( $? == -1 )  ### system command fails
        {
          exit 1;
        }
        else  ### system command ok
        {
          $ExitCode = $? >> 8;
          printf "the exicode es ; %d", $ExitCode;
          if ($ExitCode == 0)      ### emctl status return agent is up     
          {
             exit 0;
          }
          else   ### emctl status return agent is ko
          {
             exit 1;
          }
        }
}

HTH – Antonio NAVARRO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s