19 February 2010

Basic RAC Commands

Starting Up and Shutting Down with SRVCTL
Enter the following SRVCTL syntax from the command line, providing the required
database name and instance name, or include multiple instance names to start
multiple specific instances:

For administrator-managed databases, enter a comma-delimited list of instance names:

$ srvctl start instance -d db_unique_name -i instance_name_list [-o start_options]

In Windows you must enclose a comma-delimited list in double quotation marks ("").
For policy-managed databases, enter a single node name:

$ srvctl start instance -d db_unique_name -n node_name [-o start_options]

Note that this command also starts all enabled and non-running services that have
AUTOMATIC management policy, and for which the database role matches one of the
service's roles.

To stop one or more instances, enter the following SRVCTL syntax from the command
line:

$ srvctl stop instance -d db_unique_name [ -i "instance_name_list" |
-n node_name ] [ -o stop_options ]

You can enter either a comma-delimited list of instance names to stop several instances
or you can enter a node name to stop one instance. In Windows you must enclose a
comma-delimited list in double quotation marks ("").

This command also stops the services related to the terminated instances on the nodes
where the instances were running. As an example, the following command shuts
down the two instances, orcl3 and orcl4, on the orcl database using the
immediate stop option:

$ srvctl stop instance -d orcl -i "orcl3,orcl4" -o immediate

To start or stop your entire cluster database, that is, all of the instances and its enabled
services, enter the following SRVCTL commands:

$ srvctl start database -d db_unique_name [-o start_options]
$ srvctl stop database -d db_unique_name [-o stop_options]

The following SRVCTL command, for example, mounts all of the non-running
instances of an Oracle RAC database:

$ srvctl start database -d orcl -o mount


Verifying That Instances are Running
To verify that instances are running, on any node from a SQL*Plus prompt enter the
following, where password is the password:

CONNECT SYS/as SYSDBA
Enter password: password
SELECT * FROM V$ACTIVE_INSTANCES;

This query returns output similar to the following:
INST_NUMBER INST_NAME
----------- -----------------
1 db1-sun:db1
2 db2-sun:db2
3 db3-sun:db3

The output columns for this example are shown in Table 3–2.

Table 3–2 Descriptions of V$ACTIVE_INSTANCES Columns
Column Description


Column
Description
INST_NUMBER
Identifies the instance number.
INST_NAME
Identifies the host name and instance name as host_name:instance_name.


Terminating Sessions On a Specific Cluster Instance

You can use the ALTER SYSTEM KILL SESSION statement to terminate a session on
a specific instance. When a session is terminated, any active transactions of the session
are rolled back, and resources held by the session (such as locks and memory areas)
are immediately released and available to other sessions.
Using this statement enables you to maintain strict application service-level
agreements in Oracle RAC environments. Often, the goal of a service-level agreement
is to execute a transaction in a specified time limit. In an Oracle RAC environment, this
may require terminating a transaction on an instance and retrying the transaction on
another instance within a specified time frame.
To terminate sessions, follow these steps:

Query the value of the INST_ID column in the GV$SESSION dynamic
performance view to identify which session to terminate
Issue the ALTER SYSTEM KILL SESSION and specify the session index number
(SID) and serial number of a session that you identified with the GV$SESSION
dynamic performance view.
KILL SESSION 'integer1, integer2[, @integer3]'
For integer1, specify the value of the SID column.
For integer2, specify the value of the SERIAL# column.
For the optional integer3, specify the ID of the instance where the session to
be killed exists. You can find the instance ID by querying the GV$ tables.
To use this statement, your instance must have the database open, and your
session and the session to be terminated must be on the same instance unless you
specify integer3.

If the session is performing some activity that must be completed, such as waiting for
a reply from a remote database or rolling back a transaction, then Oracle Database
waits for this activity to complete, marks the session as terminated, and then returns
control to you. If the waiting lasts a minute, then Oracle Database marks the session to
be terminated and returns control to you with a message that the session is marked to be terminated. The PMON background process then marks the session as terminated when the activity is complete.
Share:

0 reacties:

Post a Comment