Oracle 11.2.0.2 RAC安装完成有一段时间了,一直没时间做管理维护这一块的学习,现在开始看RAC的官方文档,下面记录一下学习笔记:
An Oracle RAC database requires three components: cluster nodes, shared storage, and Oracle Clusterware.
Most administration tasks are the same for Oracle single-instance and Oracle RAC databases. This guide provides additional instructions for database administration tasks specific to Oracle RAC, and recommendations for managing Oracle RAC databases.
You can start and stop individual instances in an Oracle RAC database. Starting and stopping oneinstance in an Oracle RAC database does not stop or start the other database instances. To completely stop an Oracle RAC database, you must shut down all of its instances.
1.Starting and Stopping Oracle RAC Databases and Database Instances
1.1 Starting and Stopping with Oracle Enterprise Manager
To start and stop an entire Oracle RAC database, assuming you are using a server parameter file (SPFILE):
-
Go to the following URL and log in to Enterprise Manager:
http://hostname:portnumber/em
For example,
http://racnode1.example.com:1158/em
. -
On the Cluster Database Home page, in the General section, click Startup if the database is down, or Shutdown if the database is started.
The Startup/Shutdown: Specify Credentials page appears.
-
Enter the host credentials for the cluster nodes. The host credentials are the user name and password for a user who is a member of the
OSDBA
orOSOPER
operating system group.The Startup/Shutdown: Select Operation page appears.
-
Click Select All to select all the instances, or then clickShutdown to stop all the database instances orStartup to start all the database instances.
The Startup/Shutdown: Confirmation page appears.
-
Click Yes.
To start and stop individual instances, go to the Startup/Shutdown: Select Operation page and select the database instances, then click Startup or Shutdown to perform the desired operation on the selected database instances. You can also start and shut down instances using SQL*Plus or Server Control (SRVCTL).
Before you can start an Oracle RAC instance, your clusterware and any required operating system-specific processes must be running.
1.2 Starting Up and Shutting Down with SQL*Plus
If you want to start or stop just one instance and you are connected to your local node, you should first ensure that your current environment includes the SID for the local instance. Note that any subsequent commands in your session, whether inside or outside a SQL*Plus session, are associated with that same SID.
To start or shutdown your local instance, initiate a SQL*Plus session and connect with theSYSDBA
orSYSOPER
privilege and then issue the required command. For example to start and mount an instance on your local node, run the following commands in your SQL*Plus session:
CONNECT / AS SYSDBA STARTUP MOUNT
For example, you can use a SQL*Plus session on a local node to perform a transactional shutdown for two instances on remote nodes by connecting to each in turn using the instance's individual alias name. Assume the alias name for the first instance isdb1
and that the alias for the second instance is db2
. Connect to the first instance and shut it down as follows:
CONNECT /@db1 AS SYSDBA SHUTDOWN TRANSACTIONAL
Then connect to and shutdown the second instance by entering the following from your SQL*Plus session:
CONNECT /@db2 AS SYSDBA SHUTDOWN TRANSACTIONAL
It is not possible to start or stop multiple instances, simultaneously, with SQL*Plus, so you cannot start or stop all of the instances for a cluster database with a single SQL*Plus command. You may want to create a script that connects to each instance in turn and start it up and shut it down. However, you must maintain this script manually if you add or drop instances.
1.3 Starting Up and Shutting Down with SRVCTL
Note:
This section assumes that you are using a SPFILE for your database.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:
To start 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 (""
).
To start 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 haveAUTOMATIC
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
andorcl4
, on theorcl
database using theimmediate
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
2 Administering Oracle Clusterware Components
2.1 About Oracle Clusterware
Oracle Real Application Clusters (Oracle RAC) uses Oracle Clusterware as the infrastructure that binds multiple nodes that then operate as a single server. In an Oracle RAC environment,Oracle Clusterware monitors all Oracle components (such as instances and listeners). If a failure occurs, then Oracle Clusterware automatically attempts to restart the failed component and also redirects operations to a surviving component.
Oracle Clusterware includes a high availability framework for managing any application that runs on your cluster. Oracle Clusterware manages applications to ensure they start when the system starts. Oracle Clusterware also monitors the applications to make sure that they are always available. For example, if an application process fails, then Oracle Clusterware attempts to restart the process based on scripts that you customize. If a node in the cluster fails, then you can program application processes that typically run on the failed node to restart on another node in the cluster.
2.2 Managing the Oracle Clusterware Stack
By default, Oracle Clusterware is configured to restart whenever the server it resides on is restarted. During certain maintenance operations, you may be required to stop or start the Oracle Clusterware stack manually.
-
Starting Oracle Clusterware
-
Stopping Oracle Clusterware
Note:
Do not use Oracle Clusterware Control (CRSCTL) commands on Oracle entities (such as resources, resource types, and server pools) that have names beginning withora
unless you are directed to do so by Oracle Support. The Server Control utility (SRVCTL) is the correct utility to use on Oracle entities.
2.2.1 Starting Oracle Clusterware
You use the CRSCTL utility to manage Oracle Clusterware. If the Oracle High Availability Services daemon (OHASD) is running on all the cluster nodes, then you can start the entire Oracle Clusterware stack (all the processes and resources managed by Oracle Clusterware), on all nodes in the cluster by executing the following command on any node:
crsctl start cluster -all
You can start the Oracle Clusterware stack on specific nodes by using the -n
option followed by a space-delimited list of node names, for example:
crsctl start cluster -n racnode1 racnode4
To use the previous command, the OHASD process must be running on the specified nodes.
To start the entire Oracle Clusterware stack on a node, including the OHASD process, run the following command on that node:
crsctl start crs
2.2.2 Stopping Oracle Clusterware
To stop Oracle Clusterware on all nodes in the cluster, execute the following command on any node:
crsctl stop cluster -all
The previous command stops the resources managed by Oracle Clusterware, the Oracle ASM instance, and all the Oracle Clusterware processes (except for OHASD and its dependent processes).
To stop Oracle Clusterware and Oracle ASM on select nodes, include the -n
option followed by a space-delimited list of node names, for example:
crsctl stop cluster -n racnode1 racnode3
If you do not include either the -all
or the -n
option in thestop cluster
command, then Oracle Clusterware and its managed resources are stopped only on the node where you execute the command.
To completely shut down the entire Oracle Clusterware stack, including the OHASD process, use thecrsctl stop crs
command. CRSCTL attempts to gracefully stop the resources managed by Oracle Clusterware during the shutdown of the Oracle Clusterware stack. If any resources that Oracle Clusterware manages are still running after executing thecrsctl stop crs
command, then the command fails. You must then use the-f
option to unconditionally stop all resources and stop the Oracle Clusterware stack, for example:
crsctl start crs -all -f
Note:
When you shut down the Oracle Clusterware stack, you also shut down the Oracle Automatic Storage Management (Oracle ASM) instances. If the Oracle Clusterware files (voting disk and OCR) are stored in an Oracle ASM disk group, then the only way to shut down the Oracle ASM instances is to shut down the Oracle Clusterware stack.
3. Managing Oracle ASM Instances
3.1 Starting Up an Oracle ASM Instance
This section describes how to start Oracle ASM instances under the following topics:
-
Connecting To and Starting Up an Oracle ASM Instance
-
Starting Up an Oracle ASM instance with an Incorrect SPFILE Path
-
About Mounting Disk Groups at Startup
-
About Restricted Mode
Connecting To and Starting Up an Oracle ASM Instance
You start an Oracle ASM instance similarly to the way in which you start an Oracle database instance with some minor differences.
When starting an Oracle ASM instance, note the following:
-
To connect to a local Oracle ASM instance with SQL*Plus, set the
ORACLE_SID
environment variable to the Oracle ASM system identifier (SID).The default Oracle ASM SID for a single-instance database is
+ASM
, and the default SID for Oracle ASM for an Oracle RAC node is+ASM
node_number
wherenode_number
is the number of the node. TheORACLE_HOME
environment variable must be set to the Grid Infrastructure home where Oracle ASM was installed.Note:
Oracle recommends that you do not change the default Oracle ASM SID name. -
The initialization parameter file must contain the following entry:
INSTANCE_TYPE = ASM
This parameter indicates that an Oracle ASM instance, not a database instance, is starting.
-
When you run the
STARTUP
command, rather than trying to mount and open a database, this command attempts to mount Oracle ASM disk groups.For information about disk groups that are mounted at startup time, see "About Mounting Disk Groups at Startup".
After the Oracle ASM instance has started, you can mount disk groups with the
ALTER DISKGROUP...MOUNT
command. See "Mounting and Dismounting Disk Groups" for more information. -
The associated Oracle database instance does not have to be running when you start the associated Oracle ASM instance.
The following list describes how Oracle ASM interprets SQL*Plus STARTUP
command parameters.
-
FORCE
ParameterIssues a
SHUTDOWN ABORT
to the Oracle ASM instance before restarting it.If an Oracle Automatic Storage Management Cluster File System (Oracle ACFS) file system is currently mounted on Oracle ADVM volumes, the file system should first be dismounted. Otherwise, applications encounter I/O errors and Oracle ACFS user data and metadata may not be written to storage before the Oracle ASM storage is fenced. For information about dismounting an Oracle ACFS file system, see "Deregistering, Dismounting, and Disabling Volumes and Oracle ACFS File Systems".
-
MOUNT
orOPEN
ParameterMounts the disk groups specified in the
ASM_DISKGROUPS
initialization parameter. This is the default if no command parameter is specified. -
NOMOUNT
ParameterStarts up the Oracle ASM instance without mounting any disk groups.
-
RESTRICT
ParameterStarts up an instance in restricted mode that enables access only to users with both the
CREATE
SESSION
andRESTRICTED
SESSION
system privileges. You can use theRESTRICT
clause in combination with theMOUNT
,NOMOUNT
, andOPEN
clauses.See Also:
"About Restricted Mode" for more informationIn restricted mode, database instances cannot use the disk groups. In other words, databases cannot open files that are in that disk group. Also, the disk group cannot be mounted by any other instance in the cluster. Mounting the disk group in restricted mode enables only one Oracle ASM instance to mount the disk group. This mode is useful to mount the disk group for repairing configuration issues.
The following is a sample SQL*Plus session for starting an Oracle ASM instance.
SQLPLUS
/NOLOG
SQL>
CONNECT
SYS
AS
SYSASM
Enter
password:
sys_password
Connected
to
an
idle
instance.
SQL>
STARTUP
ASM
instance
started
Total System Global Area 71303168 bytes
Fixed Size 1069292 bytes
Variable Size 45068052 bytes
ASM Cache 25165824 bytes
ASM disk groups mounted
For more information about user authentication, see "Authentication for Accessing Oracle ASM Instances".
See Also:
-
Oracle Database Administrator's Guide for more information about using environment variables to select instances
-
Oracle Database Administrator's Guide for more information about starting up and shutting down Oracle instances
-
Oracle Real Application Clusters Administration and Deployment Guide for information about starting an Oracle ASM instance with
SRVCTL
in Oracle RAC -
Oracle Clusterware Administration and Deployment Guide for information about Oracle Clusterware Cluster subcomponent processes and background processes
-
Oracle Database Concepts for information about Oracle database background processes
-
Oracle Database Reference for a description of the Oracle background processes
Starting Up an Oracle ASM instance with an Incorrect SPFILE Path
If the SPFILE path in the GPNP profile is incorrect, you can start the Oracle ASM instance as follows:
-
Create a PFILE with one line in it that identifies the path to the SPFILE.
For example:
Create the
/u01/oracle/dbs/spfileasm_init.ora
file that contains:SPFILE='+DATA/asm/asmparameterfile/asmspfile.ora'
-
Start up the instance using the initialization parameter file.
For example:
SQL>
STARTUP
PFILE=/u01/oracle/dbs/spfileasm_init.ora
-
After the instance is running, use the ASMCMD
spset
command to update the SPFILE path in the GPNP profile. See "spset".For example:
ASMCMD>
spset
+DATA/asm/asmparameterfile/asmspfile.ora
See Also:
Oracle Database Administrator's Guide for more information about usingSTARTUP
with a non-default server parameter file
About Mounting Disk Groups at Startup
At startup, the Oracle ASM instance attempts to mount the following disk groups:
-
Disk groups specified in the
ASM_DISKGROUPS
initialization parameter -
Disk group used by Cluster Synchronization Services (CSS) for voting files
-
Disk groups used by Oracle Clusterware for Oracle Cluster Registry (OCR)
-
Disk group used by the Oracle ASM instance to store the ASM server parameter file (SPFILE)
If no disk groups are found in the previous list, then the Oracle ASM instance does not mount any disk groups at startup. After the Oracle ASM instance has started, you can mount disk groups with the ALTER DISKGROUP...MOUNT
command. For more information, see "Mounting and Dismounting Disk Groups".
About Restricted Mode
You can use the STARTUP
RESTRICT
command to control access to an Oracle ASM instance while you perform maintenance. When an Oracle ASM instance is active in this mode, all of the disk groups that are defined in the ASM_DISKGROUPS
parameter are mounted in RESTRICTED
mode. This prevents databases from connecting to the Oracle ASM instance. In addition, the restricted clause of the ALTER
SYSTEM
statement is disabled for the Oracle ASM instance. The ALTER
DISKGROUP
diskgroup
MOUNT
statement is extended to enable Oracle ASM to mount a disk group in restricted mode.
When you mount a disk group in RESTRICTED
mode, the disk group can only be mounted by one instance. Clients of Oracle ASM on that node cannot access that disk group while the disk group is mounted in RESTRICTED
mode. The RESTRICTED
mode enables you to perform maintenance tasks on a disk group in the Oracle ASM instance without interference from clients.
Rebalance operations that occur while a disk group is in RESTRICTED
mode eliminate the lock and unlock extent map messaging that occurs between Oracle ASM instances in an Oracle RAC environment. This improves the overall rebalance throughput. At the end of a maintenance period, you must explicitly dismount the disk group and remount it in normal mode.
3.2 Shutting Down an Oracle ASM Instance
The Oracle ASM shutdown process is initiated when you run the SHUTDOWN
command in SQL*Plus. Before you run this command, ensure that the ORACLE_SID
environment variable is set to the Oracle ASM SID so that you can connect to the local Oracle ASM instance. The default Oracle ASM SID for a single-instance database is +ASM
, and the default SID for Oracle ASM for an Oracle RAC node is +ASM
node_number
where node_number
is the number of the node. The ORACLE_HOME
environment variable must be set to the Grid Infrastructure home where Oracle ASM was installed.
Oracle strongly recommends that you shut down all database instances that use the Oracle ASM instance and dismount all file systems mounted on Oracle ASM Dynamic Volume Manager (Oracle ADVM) volumes before attempting to shut down the Oracle ASM instance.
If Oracle Cluster Registry (OCR) or voting files are stored in a disk group, the disk group can only be dismounted by shutting down the Oracle ASM instance as part of shutting down the clusterware on a node. To shut down the clusterware, run crsctl
stop
crs
.
See Also:
-
Oracle Database Administrator's Guide for more information about using environment variables to select instances
-
Oracle Database Administrator's Guide for more information about starting up and shutting down Oracle instances
-
Oracle Clusterware Administration and Deployment Guide for information about managing voting files, Oracle Cluster Registry (OCR), and Oracle Local Registry (OLR)
To shut down an Oracle ASM instance, perform the following steps:
SQLPLUS /NOLOG
SQL> CONNECT SYS
AS SYSASM
Enter
password:
sys_password
Connected.
SQL> SHUTDOWN NORMAL
For more information about user authentication, see "Authentication for Accessing Oracle ASM Instances".
The following list describes the SHUTDOWN
modes and the behavior of the Oracle ASM instance in each mode.
-
NORMAL
ClauseOracle ASM waits for any in-progress SQL to complete before performing an orderly dismount of all of the disk groups and shutting down the Oracle ASM instance. Before the instance is shut down, Oracle ASM waits for all of the currently connected users to disconnect from the instance. If any database instances are connected to the Oracle ASM instance, then the
SHUTDOWN
command returns an error and leaves the Oracle ASM instance running.NORMAL
is the default shutdown mode. -
IMMEDIATE
orTRANSACTIONAL
ClauseOracle ASM waits for any in-progress SQL to complete before performing an orderly dismount of all of the disk groups and shutting down the Oracle ASM instance. Oracle ASM does not wait for users currently connected to the instance to disconnect. If any database instances are connected to the Oracle ASM instance, then the
SHUTDOWN
command returns an error and leaves the Oracle ASM instance running. Because the Oracle ASM instance does not contain any transactions, theTRANSACTIONAL
mode behaves the same asIMMEDIATE
mode. -
ABORT
ClauseThe Oracle ASM instance immediately shuts down without the orderly dismount of disk groups. This causes recovery to occur upon the next Oracle ASM startup.
If any database instance is connected to the Oracle ASM instance, then the database instance aborts.
If any Oracle Automatic Storage Management Cluster File System (Oracle ACFS) file systems are currently mounted on Oracle ADVM volumes, those file systems should first be dismounted. Otherwise, applications encounter I/O errors and Oracle ACFS user data and metadata may not be written to storage before the Oracle ASM storage is fenced. For information about dismounting an Oracle ACFS file system, see "Deregistering, Dismounting, and Disabling Volumes and Oracle ACFS File Systems". For more information about user authentication on Oracle ASM instance, see "Authentication for Accessing Oracle ASM Instances".