Oracle® Database Oracle Clusterware and Oracle Real Application Clusters Administration and Deployment Guide 10g Release 2 (10.2) Part Number B14197-02 |
|
|
View PDF |
This appendix describes the Oracle Clusterware application program interface (API) command reference and includes the following topics:
C Application Programming Interface to the Oracle Clusterware
Functions for Managing Resource Structures
See Also: Chapter 14, "Making Applications Highly Available Using the Oracle Clusterware" for conceptual and introductory information about using Oracle Clusterware commands |
This section explains how to use the Oracle Clusterware commands to manage applications and application resources under the Oracle Clusterware framework.
The examples in this appendix show the command syntaxes that you use in application profiles. Lines starting with a pound sign (#
) are comment lines and are not processed as part of a profile. A backslash (\
) at the end of a line indicates that the next line is a continuation of the previous line. Refer to the section titled "Using crs_profile to Create An Application Resource Profile" to see a profile example.
The Oracle Clusterware uses UNIX-like security where permissions may be specified for the owner, nodes of a group, or holders of specific privileges. There may also be default permissions for other users. These permissions are read
, write
, and run
on Windows-based systems, and rwx
on UNIX-based systems. Default ownership and permissions are set when you create an application profile. Table B-1 shows the Oracle Clusterware commands and their owners as well as which commands require write permission and which commands require run permission.
Table B-1 Oracle Clusterware Command Owner and Permissions Matrix
Owner | Read | Write Permission Required | Run/Execute Permission Required |
---|---|---|---|
User |
|
|
|
Group |
|
|
|
Other |
|
|
|
Note: On platforms that do not have a group concept, the group permissions areNULL or not set. |
Note: Do not use the Oracle Clusterware commandscrs_register , crs_profile , crs_start or crs_stop on resources with names beginning with the prefix ora unless either Oracle Support asks you to, or unless Oracle has certified you as described in http://metalink.oracle.com . Server Control (SRVCTL) is the correct utility to use on Oracle resources. You can create resources that depend on resources that Oracle has defined. You can also use the Oracle Clusterware commands to inspect the configuration and status. |
Table B-2 alphabetically lists the Oracle Clusterware commands that this appendix describes. Note that the -q
option runs all commands in quiet mode. This means that no messages are displayed on the console.
Table B-2 Oracle Clusterware Commands Summary
Command | Description |
---|---|
Inspects the permissions associated with a resource. |
|
Creates, validates, deletes, and updates an Oracle Clusterware application profile |
|
|
Registers configuration information for an application with the OCR. |
|
Relocates an application profile to another node. |
|
Sets permissions associated with a resource. |
|
Lists the status of an application profile. |
|
Starts applications that have been registered. |
|
Stops an Oracle Clusterware application. |
|
Removes the configuration information for an application profile from the OCR. |
Note: On platforms that do not have a group concept, the group permissions areNULL or not set. |
Inspects the permissions associated with a resource.
Creates, validates, deletes, and updates an Oracle Clusterware application profile. It works on the user's copy of a profile. This command does not operate against the database that the Oracle Clusterware is using.
You can also use crs_profile
to generate a template script. The crs_profile
command creates new application profiles and validates, updates, deletes, or lists existing profiles. An application profile assigns values to attributes that define how a resource should be managed or monitored in a cluster. For the root
user, profiles are written to the CRS home
/crs/profile
directory. For non-privileged users, the profile is written to the CRS home
/crs/public
directory. Values in the profile that are left blank are ignored and may be omitted if not required. Omitted profile variables that are required for a resource type can cause validation or registration to fail.
After you have created an application profile and registered the application with the Oracle Clusterware using the crs_register
command, you can use other Oracle Clusterware commands, such as crs_stat
, crs_start
, crs_stop
, crs_relocate
, and crs_unregister
, on the application. You must register applications using the crs_register
command before the other Oracle Clusterware commands are available to manage the application. The crs_profile
command may have other options for defining user-defined attributes in a profile.
Use the crs_profile
command with the following syntax to create an application profile template:
crs_profile -create resource_name -t application [-a action_script] [-B executable_pathname] [-dir directory] [-d description] [-p placement_policy] [-h hosting_nodes] [-r required_resources] [-l optional_resources] [-o option,[...]] [attribute_flag attribute_value] [...] [-f] [-q]
To create an application profile from an application profile template:
crs_profile -create resource_name -I template_file [-f] [-q]
To validate the application profile syntax of a profile, enter the following command:
crs_profile -validate resource_name [-q]
To list one or more application profiles:
crs_profile -print [resource_name [...]] [-q]
To create an application profile template from an existing application profile:
crs_profile -template resource_name [-O template_file] [-q]
To update an application profile:
crs_profile -update resource_name [option [...]] [-q]
To delete an application profile and its associated action program:
crs_profile -delete resource_name [-q]
Note: Thecrs_profile -delete command deletes the resource profile file but does not delete the action script file. |
Table B-3 crs_profile Options
Option | Description |
---|---|
|
Creates a resource for the indicated application according to the specified options. A |
|
Indicates an application or application resource type. |
|
Specifies the action program for the application. An action program has start, stop, and check entry points that are called by the Oracle Clusterware. You can specify either a full path name for the script file or its filename. |
|
Specifies the location of the application executable and causes the |
|
Specifies the file location. |
|
Specifies the description of the application. Enclose the description in double quotation marks ( |
|
Specifies the policy according to which the Oracle Clusterware selects the node on which to start or restart the application. You can specify |
|
Specifies an ordered list of nodes, separated by white space, that can host the application. If there is more than one node, then the list must be enclosed in double quotation marks ( |
|
Specifies an ordered list of resources, separated by spaces, on which the application depends. These resources must be active on any node on which the application is running. If there are multiple required resources, then the list must be enclosed in double quotation marks ( |
|
Specifies an ordered list of optional resources, separated by white space. If there are multiple optional resources specified, then the list must be enclosed in double quotation marks ( |
|
comma-delimited list of attribute option names and their values. To see the list of attribute option names, run the |
|
Forces relocation of the specified applications, all applications dependent on them and all applications that they are dependent upon. This option is required for relocating applications that require another application or one that is required by any |
Table B-4 Options for the -o Flag
Option | Description |
---|---|
|
Sets the maximum time for an action program to run. The Oracle Clusterware commands and the Oracle Clusterware daemon return an error message and post an event to Event Manager (EVM) when they invoke action program entry points and the script does not complete its execution within this time. The default is 60 seconds. |
|
When set to |
|
When set to |
|
Sets the time (in seconds) at which the check entry point of the application's action program runs. The check interval is the maximum amount of time that an application can be unavailable to clients before the Oracle Clusterware attempts to restart it. The default check interval is 60 seconds. |
|
Specifies the number of times that the Oracle Clusterware may detect an application or application resource failure within the failure interval before it marks the application or application resource as unavailable and stops monitoring it. The value must be in the range |
|
Specify the time (in seconds) during which the failure threshold is calculated and applied. The default failure interval is |
|
Specifies the number of times that the Oracle Clusterware attempts to restart the application or application resource on the current node before attempting to relocate it. The default number of restart attempts is |
|
Specifies the number of seconds that the Oracle Clusterware waits before attempting to relocate the application resource. An application resource that was running on a cluster node that failed restarts immediately on that node if it becomes available again within the failover delay period. If application resources are dependent on each other due to required resources defined in application profiles, then all interdependent application resources wait for the largest failover delay that you have defined for any of the resources. The default failover delay is |
The following is an example of using the crs_profile
command to create the application profile for an application named dtcalc
:
crs_profile -create dtcalc
The following is an example of using the crs_profile
command to validate the application profile named dtcalc
:
crs_profile -validate dtcalc
If you do not specify either the -a
or -B
options, then the profile is created without an action program value. You should create a readable, executable script and update the profile with this script's value before attempting to start the application. If you specify the -a
option alone, then the action program specified must exist at the specified location or in the default directory if no path is specified. Otherwise, the command fails.
The crs_register
command registers one or more applications specified with the resource_name
parameter for each application. This command requires write access to the target application. This command only succeeds if the profile is found either in the default location or in the directory specified by the -dir
option. An application must be registered in order for the Oracle Clusterware to monitor the resource or to start, restart, or relocate a highly available application associated with an application resource. An application registration must be updated for any changes to an application profile to take effect. This command requires full administrative privileges.
An application can be registered or updated only if the Oracle Clusterware daemon is active and an Oracle Clusterware application profile exists in the profile directory for this application. If fields are missing from an application profile, then the profile is merged with the default profile template and Oracle uses the values in the default profile template.
The ownership and default permissions for the application are set during the registration process. You can register any .cap
file as long as the permissions for the file permit read
and write
, for example, crs_profile
and crs_register
must be able to read the file. By default, the user who registers the application is the owner of the application. If the profile cannot be registered, then the Oracle Clusterware displays messages explaining why. Use the crs_stat
command to verify that the application is registered.
You can use the crs_register
command to register and update applications. Use the following crs_register
syntax to register an application:
crs_register resource_name [-dir directory_path] [...] [-u] [-f] [-q]
The resource_name
[...]
parameter can be the name of one or more application resources as specified in an application profile. If you do not specify any options, then the crs_relocate
command relocates each specified application resource according to its placement policy and required resource lists. The Oracle Clusterware does not relocate a resource if there are interdependent application resources unless you specify the -f
option. A profile must exist for the application that you are registering.
The -dir
option specifies where the .cap
file is if it is not in the default directory.
Use crs_register
-u
immediately after a crs_profile
-update
or a manual edit of an application profile to ensure that the changes take effect immediately.
Table B-5 crs_register Options
Option | Description |
---|---|
|
Relocates each indicated application or application resource to the specified node regardless of its placement policy. If required resources are not available on the destination node or if the application resource is restricted from that node, then the |
|
Relocates all running applications or application resources from the |
|
Forces relocation of the specified applications, all applications dependent on them and all applications that they are dependent upon. This option is necessary for relocating any application that requires another application or one that is required by any |
Use the following crs_register
command syntax to update a registered application:
crs_register resource_name -update [option ...] [-o option,...] [-q]
The following example registers an application named postman
for which an application profile exists in the CRS home
/crs/profile
directory:
CRS home/bin/crs_register postman
Note: The profile will be in thecrs/profile directory if the profile is created by the root user. The profile will be in the crs/public directory if the profile is created by any other user. |
Oracle displays a corresponding text message for the following error conditions:
No root privilege
The Oracle Clusterware daemon is not running
Resource specified on the command line does not match the resource specified in the profile
Resource is already registered with the Oracle Clusterware daemon
Resource type cannot be updated
The crs_relocate
command relocates applications and application resources as specified by the command options that you use and the entries in your application profile. The specified application or application resource must be registered and running under the Oracle Clusterware in the cluster environment before you can relocate it. The command displays a message if you specify a cluster node that is unavailable or if the attempt to relocate failed. You must have full administrative privileges to use this command. When you perform a crs_relocate
command, the Oracle Clusterware first runs the stop entry point of the action program on the node on which it is currently running. The Oracle Clusterware then performs the start entry point of the action program to start it on a new node.
If the Oracle Clusterware fails to stop the application or application resource on the current node due to an action program error, then it marks it as UNKNOWN
. You cannot run crs_relocate
on a resource in this state. Instead, run a crs_stop
-f
command on the resource and restart it with crs_start
to return it to the ONLINE
state before you attempt to relocate it again. If the Oracle Clusterware fails to restart an application resource, then you may need to check the resource action program.
If the action program start entry point fails to run successfully, then the stop entry point is run. If the stop entry point fails to run successfully, then the state is marked as UNKNOWN
and relocation attempts are aborted. If the stop entry point succeeds, then the state is set to OFFLINE
. The target state remains ONLINE
however, so subsequent cluster node failures or restarts can cause the Oracle Clusterware to attempt to restart the application. If you have not specified the node to which to relocate it and if there are available cluster nodes that satisfy the placement criteria, then the Oracle Clusterware attempts to start the application on one of these available nodes.
If one or more user-defined attributes have been defined for application resources, then you can specify values for these attributes when relocating an application with the crs_relocate
command. The specified value is passed to the action program as an environment variable with the attribute name.
The actions that the Oracle Clusterware takes while relocating an application resource are echoed on the command line. You can also monitor them using the Event Manager (EVM). Standard error and standard output from a resource action program that is started by the crs_relocate
command are redirected to the standard error and standard output for crs_relocate
. Note that if the Oracle Clusterware daemon starts an application, then standard error and standard output of the action program is lost. Within an action program, you can check for user invocation of the action program using reason codes.
Use the crs_relocate
command with the following syntax:
crs_relocate resource_name [...] [-c cluster_node] [-f] [-q] crs_relocate resource_name [-c cluster_node] [-q] crs_relocate [USR_attribute_name=value] [...] resource_name [-c cluster_node] [-q] crs_relocate -s source_node [-c cluster_node] [-q]
Table B-6 crs_relocate Options
Option | Description |
---|---|
|
Lists resources, owners, and permissions for all resources. |
|
Lists resources, owners, and permissions for a specified resource. |
|
Lists information for all resources in a tabular form. |
|
Lists how many times a resource has been restarted or has failed within the resource failure interval; the maximum number of times that a resource can be restarted or can fail; and the target state of the application. Also lists normal status information. |
The following example relocates an application resource to the node known as rac1
:
crs_relocate postman -c rac1 Attempting to stop `postman` on node `rac2` Stop of `postman` on node `rac1` succeeded Attempting to start `postman` on node `rac1` Start of `postman` on node `rac1` succeeded
The following example attempts to relocate all application resources from node rac2
to node rac1
:
crs_relocate -s rac2 -c rac1 Attempting to stop `postman` on node `rac2` Stop of `postman` on node `rac2` succeeded. Attempting to start `postman` on node `rac1` Start of `postman` on node `rac1` succeeded. Attempting to stop `calc` on node `rac2` Stop of `calc` on node `rac2` succeeded. Attempting to start `calc` on node `rac1` Start of `calc` on node `rac1` succeeded.
If a user-defined attribute USR_DEBUG
has been defined, then the following example runs the stop and start entry point of the action program with the USR_DEBUG
environment variable set to FALSE
. This overrides any value set in the application profile. In the corresponding action program, if you add the following line to the appropriate section of the action program, then you can view the value:
echo $USR_DEBUG
Then run the following command:
# crs_relocate USR_DEBUG=false database
Modifies the permissions associated with a resource. This command is similar to the chmod
command in UNIX-based systems or the Windows desktop options, in this order: File, Properties, Security, and Permissions.
Use the crs_setperm
command with the following syntax:
crs_setperm resource_name -u aclstring [-q] crs_setperm resource_name -x aclstring [-q] crs_setperm resource_name -o user_name [-q] crs_setperm resource_name -g group_name [-q]
In the previous example syntax, -u
updates the acl string, -x
deletes the acl string, -o
changes the owner of the resource, and -g
changes the primary group of the resource, and aclstring
is one of the following:
user:username:rwx group:groupname:r-x other::r--
The crs_stat
command provides status information for resources on the cluster nodes. To query resources with the crs_stat
command, resource files must have read and execute permissions (r
and x
permissions on UNIX-based systems). An exception is the -g
option, that anyone can use to verify whether a resource exists.
Resources are either ONLINE
or OFFLINE
as shown in the STATE
attribute. An application resource in the ONLINE
state is running successfully on a cluster node. This cluster node is shown indicating its state.
The TARGET
value shows the state to which the Oracle Clusterware attempts to set the resource. If the TARGET
value is ONLINE
and a cluster node fails, then the Oracle Clusterware attempts to restart the application on another node if possible. If there is a condition forcing a resource STATE
to be OFFLINE
, such as a required resource that is OFFLINE
, then the TARGET
value remains ONLINE
and the Oracle Clusterware attempts to start the application or application resource once the condition is corrected.
A TARGET
value for all non-application resources should be ONLINE
unless the resource has a failure count higher than the failure threshold, in which case the TARGET
is changed to OFFLINE
. The Oracle Clusterware then treats the resource as if its STATE
were OFFLINE
. If the STATE
is ONLINE
and the TARGET
is OFFLINE
, then you can reset the target value to ONLINE
using the crs_start
command.
The verbose status -v
gives additional information that may be useful, especially for troubleshooting. The RESTART_COUNT
value shows how many times an application resource has been restarted on a single cluster node. The maximum number of restarts before the Oracle Clusterware stops restarting the application is equal to RESTART_ATTEMPTS
. FAILURE_COUNT
shows the number of times that a resource has failed within the FAILURE_INTERVAL
defined in the application profile. The maximum number of failures before the Oracle Clusterware stops restarting an application is equal to the value set for the FAILURE_THRESHOLD
parameter. If a cluster node fails and applications are waiting to be relocated due to the profile FAILOVER_DELAY
attribute, then the verbose status also shows the FAILOVER_STATUS
field. The FAILOVER_STATUS
field is not shown at any other time. The FAILOVER_STATUS
field shows the node the application failed on and how much time is left waiting for that node to restart before restarting on another node.
Use the crs_stat
command with the following syntax:
crs_stat [resource_name [...]] [-v] [-l] [-q] [-c cluster_node]
crs_stat [resource_name [...]] -t [-v] [-q] [-c cluster_node]
crs_stat -p [resource_name [...]] [-q]
crs_stat [-a] resource_name -g
crs_stat [-a] resource_name -r [-c cluster_node]
crs_stat -f [resource_name [...]] [-q] [-c cluster_node]
crs_stat -ls resource_name
To view information about all resources, enter the command with no arguments.
Table B-7 crs_stat Options
Option | Description |
---|---|
|
Lists resources, owners, and permissions for all resources. |
|
Lists resources, owners, and permissions for a specified resource. |
|
Lists information for all resources in a tabular form. |
|
Lists how many times a resource has been restarted or has failed within the resource failure interval, the maximum number of times that a resource can be restarted or can fail, and the target state of the application. Also lists normal status information. |
-v
— Displays extended information about the status of resources. Extra attributes shown include RESTART_COUNT
and FAILURE_COUNT
. The RESTART_COUNT
attribute shows the number of restarts of the application that have been attempted since it was started. The FAILURE_COUNT
attribute shows how many failures have occurred during the last FAILURE_THRESHOLD
in seconds. The attribute FAILOVER_STATUS
shows the time at which an application resource started while waiting to relocate due to a cluster node failure if the resource has a FAILOVER_DELAY value greater than 0. It is not displayed otherwise.
-l
— Displays the status in a list (non-tabular) format. This is the default format.
-t
— Displays the status in tabular format.
-p
resource_name
[...]]— Displays the status of the in-memory profile for the specified resources. If no resources are specified, then the status of the in-memory profile for all registered resources is displayed. If a resource is not registered, its status is not displayed.
-a
resource_name
— Used with the -g
or -r
option to verify whether the specified resource is registered or running under the Oracle Clusterware. Specify the name of the resource as listed in its application profile.
-f
— Displays all information about the resource including extended information (-v
) and the in-memory profile (-p
).
-g
— Returns 0
(zero) if the specified application or application resource is registered with the Oracle Clusterware; returns 1
if it is not. This option only works if a single resource is specified with the -a
option.
-r
— Returns 0
(zero) if the specified application or application resource is running under the Oracle Clusterware; returns 1
if it is not. This option can only be successful if a single resource is specified with the -a
option.
-c
cluster_node
— Displays information about applications or application resources on the specified cluster node.
The following example displays the status information for the postman
application:
crs_stat postman NAME=postman TYPE=application TARGET=ONLINE STATE=ONLINE on rac2
The following example displays the status information in a tabular form:
crs_stat -t Name Type Target State Host ---------------------------------------------------------------- cluster_lockd application ONLINE ONLINE rac2 dhcp application OFFLINE OFFLINE
The following example shows the output for the command crs_stat
with the -v
option for the node rac2
:
crs_stat -v NAME=cluster_lockd TYPE=application RESTART_ATTEMPTS=30 RESTART_COUNT=0 FAILURE_THRESHOLD=0 FAILURE_COUNT=0 TARGET=ONLINE STATE=ONLINE on rac2
The crs_start
command sets an application or application resource target state to ONLINE
and attempts to start specified registered applications or application resources. The target state is the state that the Oracle Clusterware attempts to achieve. You must have full administrative privileges to use this command.
There are several user-defined attributes available for starting an application with crs_start
. The specified value is passed to the action program as an environment variable with the attribute name.
If you do not specify one node on which to start the application and there are available cluster nodes that satisfy the placement criteria, then the Oracle Clusterware attempts to start the application on one of the available nodes. You must stop a resource that has failed before restarting it. You should also confirm why your action program is failing.
The crs_start
command starts dependent resources as defined in the application profile REQUIRED_RESOURCE
fields. After a registered resource is started, you must use the crs_stop
command to end its execution.
The crs_start
command displays status messages and if there are problems starting an application, then feedback is displayed. If network, tape, or media changer resources are defined as required resources for an application or as an application resource that is started, then messages stating that the Oracle Clusterware is attempting to start these non-application resources appear. The Oracle Clusterware is not actually attempting to start these resources, but is testing the state of the devices. You can ignore these messages.
Standard error and standard output from a resource action program invoked by crs_start
are redirected to the standard error and standard output for crs_start
. Note that if the Oracle Clusterware daemon starts an application, then standard error and standard output of the action program is lost. Within an action program, you can check for user invocation of the action program using reason codes.
crs_start resource_name [...] [-c cluster_node] [-q] [-f] crs_start -all [-q] crs_start [USR_attribute_name=value] [...] resource_name [-c node_name] [-q]
For resource_name
[...], the names are as specified in an application profile of one or more resources to be started. The resource must be registered with the Oracle Clusterware. You can use the following options:
-c
node_name
—Starts each indicated resource on the specified node if the cluster node is enabled by the placement policy and resource dependencies. If the cluster node specified is not enabled by the placement policy and resource dependencies, then the crs_start
command fails. If the specified node is not available, the command fails. If one of the specified resources fails to start, then the command still attempts to start other resources listed on the command line.
-all
—Starts all registered Oracle Clusterware applications or application resources on active cluster nodes, according to their placement policies and required resource lists.
-q
—Runs the crs_start
command in quiet mode; no messages are displayed.
-f
—Forces starting of a specified application or application resource if all of the required resources are available or can be started. Any applications or application resources in the specified application profile's required resource list are started if not currently running or are relocated if they are running on another cluster node. Use this option with only one specified application resource at a time.
The following example starts an application named postman
:
crs_start postman Attempting to start `postman` on node `rac1` Start of `postman` on node `rac1` succeeded.
The following example starts the application on a specific cluster node rac2
:
crs_start -c rac2 postman Attempting to start `postman` on node `rac2` Start of `postman` on node `rac2` succeeded.
A failure has occurred. Oracle displays a corresponding text message for the following error conditions:
No root privilege
The Oracle Clusterware daemon is not running
The application is running
A start action program is not found
The cluster node was specified and it was not available
A timeout was reached before the startup was unsuccessful
Stops an application on the specified node. You can run the crs_stat
command to verify that the application you specify is stopped.
Use the crs_stop
command with the following syntax:
crs_stop resource_name [...] [-f] [-q] crs_stop -c cluster_node [...] [-q] crs_stop -all [-q] crs_stop [USR_attribute_name=value] [...] resource_name [-q] -c cluster_node [...]
Specifies one or more active cluster nodes on which to stop all of the applications or application resources. You can use the following options:
-all
—Stops all applications or application resources on all active cluster nodes.
-f
—Forces termination of the indicated applications or application resources and all application resources dependent on the specified resources. This option is useful to stop all application resources when the crs_stop
command fails because of application resources that are dependent on the specified resource or if the application is in the UNKNOWN
state because of an unsuccessful stop. This option makes crs_stop
ignore any errors that are reported by an action program.
The crs_unregister
command removes the registration information of Oracle Clusterware resources from the binary Oracle Clusterware registry database. The Oracle Clusterware will no longer acknowledge this resource. An application associated with a resource that is unregistered is no longer highly available. You must have full administrative privileges to use this command.
Upon successful completion of the crs_unregister
command, the resource is removed from the online Oracle Clusterware environment. You cannot unregister a resource that is a required resource for another resource. You must stop the resource by using the crs_stop
command before unregistering it.
Use the crs_unregister
command with the following syntax:
crs_unregister resource_name [...] [-q]
The only option available for this command is -q
, that runs the crs_unregister
command in quiet mode, which means no messages are displayed.
The following example unregisters a highly available application called postman
:
crs_unregister postman
Oracle displays a corresponding text message for the following error conditions:
No root privilege
CAA daemon is not running
The application is running
The application is not registered
See Also: Chapter 14, "Making Applications Highly Available Using the Oracle Clusterware" for information about using the Oracle Clusterware commands |
The APIs described in this section provide access to operational control of resources that the Oracle Clusterware manages. The API is used to register user applications to the Oracle Clusterware system so that they can be managed by the Oracle Clusterware and made highly available. When an application is registered, the application can be started and its state queried. If the application is no longer to be run, it can be stopped and unregistered from the Oracle Clusterware. The Oracle Clusterware services are provided by another process, such as the crsd
process, running outside the database server. These APIs communicate with the crsd
process using an IPC mechanism.
Initializes a context for communications with the Oracle Clusterware.
ctx
—Context to initialize, caller allocated storage
errf
—A Callback function for the error info, or NULL
errCtx
—Context for the error callback func, or NULL
flags
—CLSCRS_FLAG_TRACE
, to enable tracing of lower layers
CLSCRS_FLAG_USETHREADS
—Enables using the clscrs
context in multiple threads
Returns the correct node name. If you issue this command within a configured cluster, then this is the name as known to the clusterware. If not in a cluster, then the name is as known through other clusterware means. Getting a node name may require a lot of resources in the first call, especially if CLSCRS
was not initialized with a pre-existing CSS context.
Creates a call environment describing the parameters to the Oracle Clusterware calls. The memory is owned by clscrs
which is released by a call to clscrs_env_delete
.
Sets an attribute or value argument in an environment for the Oracle Clusterware calls; the value may be NULL
.
Deletes an environment for the Oracle Clusterware calls. The environment must be created again before use. You cannot delete an environment and then set new parameters.
Direct the Oracle Clusterware to start a named set of resources. If a host is specified, then start there, otherwise start according to the placement policy for the resources in question. If the flag is async
, then msgf
is never called and Oracle returns the OK
status after initiating the call to the Oracle Clusterware, and the actual starts are performed asynchronously, and msgf
will never be called. If flag is not async
and msgf
is not NULL
, then msgf
will be driven one line at a time with collected output from the start programs.
ctx
—The context
names
—The resource(s) to start
num_names
—The number of resources in names[] to start
host
—The host name on which to start the resource, may be NULL
env
—Environment arguments to start
msgf
—User message callback, may be NULL
msgp
—User callback argument, may be NULL
msgf
—Callback function
msgf
—Callback function
Direct the Oracle Clusterware to stop a named set of resources. The flag enables async
stop.
Direct the Oracle Clusterware to run the check actions for the identified resources. A delay can be specified to indicate a time to wait in seconds before the check action is performed on the server. This occurs after the call returns. This can be used to let something run before performing the check. For each resource identified by the in_splist
, a status will be returned in the op_status
, indicating whether the resource exists and whether the caller has permission to invoke operations on the resource. A resource that is explicitly named with no pattern matching will have a NOTFOUND
error. A pattern that has no matches will return no error. There will be no valid attributes returned for the resources. There is no way of knowing exactly when the checks will actually be run or be completed. Returns SUCCESS
if the operation status of all of the identified resources is SUCCESS
, otherwise FAILURE
and specific status will be found in the op_status
entries. The caller must create the op_status
list before the call and destroy it when done.
Register the resources in the input resource list. The attributes for the resources are encapsulated in the input resource list. The output op_status
list contains the results of the register operation for each resource and contains no valid resource attributes. The caller must create and populate the in_reslist
and must create the op_status
list. Both the lists must be destroyed by the caller. The op_status
list cannot be reused with another API call, you must create and destroy it for each API call.One or more attributes of an already registered resource can be modified by passing the CLSCRS_FLAG_REG_UPDATE
flag. The flags apply to all resources in the input reslist.
in_reslist [in]
—List of resources to be registered
flags [in]
—CLSCRS_FLAG_REG_UPDATE or 0
op_status [out]
—Resource list holding the status of the register operation for each resource
Unregister the resources in the input list of resource names. The output op_status
list contains the results of the unregister operation for each resource. The caller must create and populate the rqlist
and must create the op_status
list. Both the lists must be destroyed by the caller. The op_status
list cannot be reused with another API call. You must create and destroy it for each API call.
rqlist [in]
—List of resources names to be unregistered
flags [in]
—Option flags
op_status [out]
—Resource list holding the status of the unregister operation for each resource
Obtains information about the resources identified in rqlist
. The resources can be restricted to a specific node given in the nodename parameter. The information is returned in the output out_reslist
.If the rqlist
is NULL
, information about all registered resources is returned. If the node name is not NULL
, the result is restricted to resources running on the specific node. Otherwise, all nodes in the cluster are considered.The res_flags
are used to scope the resource domain that is matched. There are no values for this parameter. The res_attrs
identifies the attributes to be returned in the out_reslist
. The caller may create a specific list of attributes of interest or use a pre-defined list returned by one of the macros CLSCRS_ATTRS_NONE
, CLSCRS_ATTRS_ALL
, CLSCRS_ATTRS_STATE
, CLSCRS_ATTRS_SHORT
. The attribute list applies to all resources identified by the rqlist
. Any errors for a resource are returned in the output out_reslist
.
rqlist [in]
—List of resource names to query
nodename [in]
—Query resources running only on the given node (optional, may be NULL
)
res_attrs [in]
—List to specify the attributes to be returned for each resource
res_flags [in]
—Flags to restrict the resources being matched
out_reslist [out]
—List holding the returned resource information
This section describes functions for creating, managing, and destroying resources and the attributes associated with resources. The following structures are used in this section:
clscrs_sp
—This is a stringpair (sp
) structure. It contains a name and a value string. The value may be NULL
. It is created and destroyed and its contents can be examined and the value replaced. An sp
may be a member of exactly one stringpair list (splist
).
clscrs_splist
—A stringpair list (splist
) is a list of zero or more stringpairs used in various contexts. Sometimes the list contains names and values, sometimes the list contains only names. The list is created and destroyed; members can be retrieved by name, added, deleted, replaced, and the list can be traversed with first
and next
operations.
clscrs_res
—This represents a resource abstraction that contains the name of a resource and additional data about the context in which it is used. Sometimes it contains resource attribute data and other times it contains status and return message about an operation. A resource may be in exactly one resource list.
clscrs_reslist
—A resource list is an abstraction used to contain information about zero or more resources. A resource list is created, appended, iterated over, and destroyed.
This section describes the following export operations:
This section describes stringpair operations.
Change the value part of a stringpair. The new value may be NULL
. After the call returns, the memory of the value can be recycled.
Parameters
sp [in]
—Stringpair to set the value for
value [in]
—Value component of the stringpair (may be NULL
)
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the sp argument is NULL
Syntax
clscrsret clscrs_sp_set(clscrs_sp *sp, const oratext *value);
Get the name and value components of a stringpair.
Parameters
sp [in]
—Stringpair for which the name and value are being obtained
name [out]
—Name component of the stringpair
value [out]
—Value component of the stringpair (may be NULL
)
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADARG
if the sp argument is NULL
Syntax
clscrsret clscrs_sp_get(clscrs_sp *sp, oratext **name, oratext **value);
Get the value component of a stringpair.
Parameters
sp [in]
—Stringpair for which the name and value are being obtained
value [out]
—Value component of the stringpair (may be NULL
)
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the sp
argument is NULL
Syntax
clscrsret clscrs_sp_get_value(clscrs_sp *sp, oratext **value);
This section describes the splist
operations.
Create a new stringpair list. The memory for the splist
is allocated by the function.
Parameters
ctx [in]
—clscrs context
splist [out]
—The new stringpair list created
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADCTX
if the context is NULL
Syntax
clscrsret clscrs_splist_create(clscrs_ctx *ctx, clscrs_splist **splist);
Create a new stringpair list (splist
) and set the name and value for the first stringpair in the list. The memory for the splist
is allocated by the function.
Parameters
ctx [in]
—clscrs context
name [in]
—Name component of the stringpair
value [in]
—Value component of the stringpair (may be NULL
)
sp [out]
—The new stringpair created
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADCTX
if the context is NULL
clscrsretBADARG
if the name argument is NULL
Syntax
clscrsret clscrs_splist_create_and_set(clscrs_ctx *ctx, const oratext *name, const oratext *value, clscrs_splist **splist);
Add a new stringpair (sp
) to a stringpair list (splist
).
Parameters
splist [in]
—splist
to add the new {name, value}
stringpair.
name [in]
—Name component of the stringpair
value [in]
—Value component of the stringpair (may be NULL
)
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADARG
if the name argument is NULL
Syntax
clscrsret clscrs_splist_append(clscrs_splist *splist, const oratext *name, const oratext *value);
Get the first stringpair (sp
) from a stringpair list (splist
).
Parameters
name [in]
—splist
to get the first sp
from
sp [out]
—The first sp
from the given splist
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the splist is NULL
clscrsretEMPTY
if there are no stringpair elements in the splist
Syntax
clscrsret clscrs_splist_first(clscrs_splist *splist, clscrs_sp **sp);
Get the current next stringpair (sp
) from a stringpair list (splist
). This function is called to iterate over the stringpairs in a splist
.
Parameters
name [in]
—splist
to get the next sp
from
sp [out]
—The next sp
{name, value} in the given splist
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the splist is NULL
clscrsretENDLIST
if there are no more stringpair elements in the splist
Syntax
clscrsret clscrs_splist_next(clscrs_splist *splist, clscrs_sp **sp);
Replace the value for a stringpair (sp
) in a stringpair list (splist
).
Parameters
splist [in]
—Splist
to add the new {name, value} stringpair.
name [in]
—Name for which the value is being replaced.
value [in]
—Replacement value for the name (may be NULL
)
Returns
clscrsretSUCC
on successclscrsretBADARG
if the name argument is NULL
clscrsretBADARG
if the name argument is NULL
clscrsretBADARG
if the name argument is NULL
Syntax
clscrsret clscrs_splist_replace(clscrs_splist *splist, const oratext *name, const oratext *value);
Delete a stringpair (sp
) from a stringpair list (splist
).
Parameters
splist [in]
—Splist
from which to delete the {name, value}
stringpair.
splist [in]
—Name to be deleted from the given splist
.
Returns
clscrsretSUCC
on success
clscrsretNONAME
if there is no stringpair matching the given name
clscrsretBADARG
if the name argument is NULL
Syntax
clscrsret clscrs_splist_delete_sp(clscrs_splist *splist, const oratext *name);
Find the value for a stringpair (sp
) in a stringpair list (splist
).
Parameters
splist [in]
—Splist
to look into
name [in]
—Name for which the value is looked up
value [out]
—Value associated with the given name in the given splist
Returns
clscrsretSUCC
on success
clscrsretNONAME
if there is no stringpair matching the given name
clscrsretBADARG
if the name argument is NULL
Syntax
clscrsret clscrs_splist_find(clscrs_splist *splist, const oratext *name, oratext **value);
Count the number of stringpairs (sp
) in a stringpair list (splist
).
Parameters
splist [in]
—Splist
to count the number of stringpairs.
count [out]
—The number of stringpairs in the given splist
.
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the splist is NULL
Syntax
clscrsret clscrs_splist_count(clscrs_splist *splist, ub4 *count);
Free the memory for a stringpair list (splist
).
Parameter
splist [in]
—Splist
to destroy
Returns
clscrsretSUCC
on success
Syntax
clscrsret clscrs_splist_destroy(clscrs_splist **splist);
Create a new resource. The memory for the resource structure is allocated by the function. The memory is freed when a resource list (clscrs_reslist
) is destroyed through clscrs_reslist_destroy()
.
Parameters
ctx [in]
—clscrs
context
resname [in]
—Name of the resource
res [out]
—The new resource created
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADCTX
if the context is NULL
clscrsretBADARG
if the resource name is NULL
Syntax
clscrsret clscrs_res_create(clscrs_ctx *ctx, const oratext *resname, clscrs_res **res);
Get the name of a resource.
Parameters
res [in]
—Resource for which the name is obtained
name [out]—Name of the resource
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the resource argument is NULL
Syntax
clscrsret clscrs_res_get_name(clscrs_res *res, oratext **name);
Set a resource attribute for a resource.
Paramters
res [in]
—Resource for which the attribute is set
attrname [in]
—Name of the resource attribute
value [in]
—Value for the resource attribute (may be NULL
)
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the attribute name is NULL
clscrsretNOMEM
if no memory can be allocated
Syntax
clscrsret clscrs_res_set_attr(clscrs_res *res, const oratext *attrname, const oratext *value);
Get a resource attribute for a resource.
Parameters
res [in]
—Resource for which the attribute is obtained
attrname [in]
—Name of the resource attribute
value [out]
—Value for the resource attribute
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the attribute name is NULL
clscrsretNOMEM
if no memory can be allocated
Syntax
clscrsret clscrs_res_get_attr(clscrs_res *res, const oratext *attrname, oratext **value);
Get the attribute list for a resource. The attribute list is a list of stringpairs. The client does not allocate the memory for attribute list.
Paramters
res [in]
—Resource for which the attribute list
attrlist [out]
—List of attributes for the given resource
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the resource is NULL
clscrsretNOMEM
if no memory can be allocated
clscrsretNOATTRS
if there are no attributes set for the resource
Syntax
clscrsret clscrs_res_get_attr_list(clscrs_res *res, clscrs_splist **attrlist);
Set the attribute list for a resource. The attribute list is a list of stringpairs. The list is created from the clscrs_splist_create
call.
Parameters
res [in]
—Resource for which the attribute list is set
attrlist [in]
—List of attributes to be set for the given resource
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the resource is NULL
Syntax
clscrsret clscrs_res_set_attr_list(clscrs_res *res, clscrs_splist *attrlist);
Get the number of attributes for a resource.
Parameters
res [in]
—Resource for which number of attributes is obtained
count [out]
—Number of attributes for the given resource
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the resource is NULL
Syntax
clscrsret clscrs_res_attr_count(clscrs_res *res, ub4 *count);
Get the status of an operation for a resource. The memory for the msg is allocated by the function.
Parameters
res [in]
—Resource for which the operation status is obtained
status [out]
—Status of an operation on the given resource
msg [out]
—Text message for the result of an operation on the resource
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretNOMSG
if there is no msg available
clscrsretBADARG
if the resource is NULL
Syntax
clscrsret clscrs_res_get_op_status(clscrs_res *res, CLSCRS_STAT *status, oratext **msg);
Get the registration status of a resource.
Parameters
res [in]
—Resource for which the operation status is set
registered [out]
—Boolean indicating whether the resource is registered
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADARG
if the resource is NULL
Syntax
clscrsret clscrs_res_get_registered(clscrs_res *res, boolean *registered);
Get the nodelist currently hosting the resource, or NULL
if there is no host for the resource or there are no attributes. The caller need not allocate memory for the nodelist.
Parameters
res [in]
—Resource for which the nodelist is obtained
nodelist [out]
—Splist
holding the node(s)
Returns
clscrsretSUCC
on success
clscrsretBADARG
if the resource is NULL
Syntax
clscrsret clscrs_res_get_node_list(clscrs_res *res, clscrs_splist **nodelist);
Free the memory for a resource.
Parameter
res [in]
—Resource for which the memory is freed
Returns
clscrsretSUCC
on success
Syntax
clscrsret clscrs_res_destroy(clscrs_res **res);
Create a new resource list. The memory for the resource list is allocated by the function.
Parameters
ctx [in]
——clscrs
context
reslist [out]
—Resource list (empty) that is created
Returns
clscrsretSUCC
on success
clscrsretNOMEM
if no memory can be allocated
clscrsretBADCTX
if the context is NULL
Syntax
clscrsret clscrs_reslist_create(clscrs_ctx *ctx, clscrs_reslist **reslist);
Add a resource to a resource list.
Parameters
reslist [in]
—Resource list to add the resource to
res [in]
—Resource to add
Returns
clscrsretSUCC
on success
clscrsretBADARG
if reslist is NULL
clscrsretRESEXISTS
if the resource already exists in reslist
Syntax
clscrsret clscrs_reslist_append(clscrs_reslist *reslist, clscrs_res *res);
Get the first resource on a resource list.
Parameters
reslist [in]
—Resource list for which the first resource is obtained
res [out]—The first resouce on the resource list
Returns
clscrsretSUCC
on success.
clscrsretBADARG
if reslist is NULL
clscrsretEMPTY
if there are no resources in the list
Syntax
clscrsret clscrs_reslist_first(clscrs_reslist *reslist, clscrs_res **res);
Get the current next resource from the resource list. This function is called to iterate over the resources in a resource list.
Parameters
reslist [in]
—Resource list for which the first resource is obtained
res [out]
—The next resouce on the resource list
Returns
clscrsretSUCC
on success
clscrsretBADARG
if reslist is NULL
clscrsretENDLIST
if there are no more resources in the list
Syntax
clscrsret clscrs_reslist_next(clscrs_reslist *reslist, clscrs_res **res);
Find a resource in a resource list.
Parameters
reslist [in]
—Resource list (empty) that is created
name [in]
—Name of the resource that is being obtained
res [out]
—The resouce corresponding to the given name
Returns
clscrsretSUCC
on success
clscrsretNORES
if the resource is not found
clscrsretBADARG
if reslist or name is NULL
Syntax
clscrsret clscrs_reslist_find(clscrs_reslist *reslist, const oratext *name, clscrs_res **res);
Count the number of resources in a resource list.
Parameters
reslist [in]
—Resource list for which the count is obtained
count [out]
—Number of resources in the resource list
Returns
clscrsretSUCC
on success
clscrsretBADARG
if reslist is NULL
Syntax
clscrsret clscrs_reslist_count(clscrs_reslist *reslist, ub4 *count);
Delete a resource from a resource list.
Parameters
reslist [in]
—Resource list from which to delete the resource
name [in]
—Name of the resource to delete
Returns
clscrsretSUCC
on success
clscrsretBADARG
if reslist or name is NULL
clscrsretNORES
if the resource is not in reslist
Syntax
clscrsret clscrs_reslist_delete_res(clscrs_reslist *reslist,
const oratext *name);
Free the memory for a resource list.
Parameters
reslist [in]
—Resource list for which the memory is to be freed
Returns
clscrsretSUCC
on success
Syntax
clscrsret clscrs_reslist_destroy(clscrs_reslist **reslist);
Retrieve the error message corresponding to the return codes from a clscrs
API. The memory for the error message is allocated by the caller. If the buffer is not large enough, the length is returned in msg_len
.
Parameters
ctx [in]
—clscrs
context
err_code [in]
—Error code returned from the clscrs
API
msg [out]
—Message corresponding to err_code
msg_len [inout
]—Length of the message buffer.
Returns
clscrsretSUCC
on success
Syntax
clscrsret clscrs_get_error_message(clscrs_ctx *ctx, clscrsret err_code, oratext *msg, sb4 msg_len);
Get the list of attributes corresponding to an attribute group identifier.
Parameters
ctx [in]
—clscrs
context
attrgrp [in]
—Attribute group that identifies a group of attributes
attrlist [out]
—List of attributes returned that corresponds to the attribute group
Returns
clscrsretSUCC
on success
Syntax
clscrs_splist* clscrs_get_fixed_attrlist(clscrs_ctx *ctx, clscrs_attr_grp attrgrp);
This section describes resource functions. The clscrs_res
resource abstraction contains the name of a resource and additional data appropriate to the context in which it is used. Sometimes it carries status and error return information about an operations. Other times it contains attribute data as input to an operation. A resource may be in exactly one resource list. If so, its successor may be found with the NEXT
operation.
Creates a single resource and fills in a handle to it. The resname
must be provided, and cannot be NULL
.
Returns a pointer to the name of a resource. The returned name pointer is only valid as long as the resource exists.
If there is a valid operation error value in the resource, fill in the stat and the pointer to an error message and return SUCCESS
. May fill in a NULL
to the msg. If there is no valid operation status, returns INVALID
.
Returns an splist
holding the nodes currently hosting the resource, or NULL
if there is no host for the resource or there are no attributes. The count of the list may obtained and the list iterated. The list is owned by the resource and will be destroyed when the resource is destroyed. This operation is a special case, interpreting the semantics of the attribute or attributes that may hold the current hosting member list. There is no specified ordering of the list.
Fills in a pointer to the value of the attribute with the given name and returns SUCCESS
if found, or FAILURE
if the name is not present in the attribute set of the resource, and INVALID
if there is no attribute list in the resource. May assert if given an invalid resource handle.
Sets the value of the attribute with the given name and returns SUCCESS
or FAILURE
if the name is not present in the attribute set of the resource. If the attribute already exists, then its current value will be replaced. On return, the memory for the name and value may be recycled.
Fill in the number of attributes that will be returned with a scan using an attrIter
. Returns SUCCESS
if there are attributes. If there are no attributes, returns INVALID
, but still sets the count to zero.
Returns an splist
for the attributes of the resource, allowing next()
operations for a scan. The list is owned by the resource, which will destroy it when the resource is destroyed. Returns SUCCESS
if there is an attribute list, or INVALID
if there is not one in the resource. There is no specified ordering of the list.
This section describes the resource list operations. The clscrs_reslist
resource list is an abstraction that contains information about zero or more resources. A list is created, appended, iterated over, and destroyed.
Creates a resource list and fills a handle.
Fills a count of the number of resources in a list.
Fills a handle to the first resource in the list of resources. If the list is empty, fill in NULL
.
Fills a handle to the next resource in the list of resources. If the list is empty, fill in NULL
.