Starting and Stopping RAC Instances
In a RAC environment, multiple instances can have the same RAC database open at the same time. The procedures for starting up and shutting down RAC instances are identical to the procedures used in single-instance Oracle, with the following exception:
– The SHUTDOWN TRANSACTIONAL command with the LOCAL option is useful to shut down an instance after all active transactions on the instance have either committed or rolled back. Transactions on other instances do not block this operation. If you omit the LOCAL option, this operation waits until transactions on all other instances that started before the shutdown are issued either a COMMIT or a ROLLBACK.
– You can start up and shut down instances by using Enterprise Manager, SQL*Plus, or Server Control (srvctl). Both Enterprise Manager and srvctl provide options to start up and shut down all the instances of a RAC database with a single step. Other Oracle utilities that can stop and start instances include RMAN and DGMGRL.
– Shutting down a RAC database mounted or opened by multiple instances means that you need to shut down every instance accessing that RAC database. However, having only one instance opening the RAC database is enough to declare the RAC database open.
Starting and Stopping RAC Instances with srvctl
The srvctl start database command starts a cluster database, its enabled instances, and services. The srvctl stop database command stops a database, its instances, and its services.
The srvctl start instance command starts instances of a cluster database. This command also starts all enabled and nonrunning services that have the listed instances either as preferred or as available instances. The srvctl stop instance command stops instances, and all enabled and running services that have these instances as either preferred or available instances.
You must disable an object that you intend to keep stopped after you issue a srvctl stop command; otherwise, Oracle Clusterware can restart it as a result of another planned operation. srvctl does not support concurrent executions of commands on the same object. Therefore, run only one srvctl command at a time for each database, service, or other object. To use the START or STOP options of the SRVCTLcommand, your service must be an Oracle Clusterware–enabled, nonrunning service.
When shutting down an instance, using the SHUTDOWN TRANSACTIONAL command with the LOCAL option is useful to shut down a particular Oracle RAC database instance. Transactions on other instances do not block this operation. If you omit the LOCAL option, this operation waits until transactions on all other instances that started before you ran the SHUTDOWN command either commit or rollback, which is a valid approach, if you intend to shut down all instances of an Oracle RAC database.
$ srvctl start|stop instance -db db_unique_name –node node_name -instance instance_name_list[-startoption|stopoption open|mount|nomount|normal|transactional|immediate|abort]
srvctl start|stop database -db -eval [-startoption|stopoption open|mount|nomount|normal|transactional|immediate|abort>]
$ srvctl start instance -db orcl -instance orcl1,orcl2
$ srvctl stop instance -db orcl -instance orcl1,orcl2
$ srvctl start database -db orcl -startoption mount
$ srvctl start instance -db orcl -node host01 *** This command will start a Policy-Managed database****
Starting and Stopping RAC Instances 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.
[host01] $ echo $ORACLE_SID orcl1 sqlplus / as sysdba SQL> startup SQL> shutdown immediate
[host02] $ echo $ORACLE_SID orcl2 sqlplus / as sysdba SQL> startup SQL> shutdown immediate
To start-up or shut down your local instance, initiate a SQL*Plus session connected as SYSDBA or SYSOPER, and then issue the required command (for example, STARTUP). You can start multiple instances from a single SQL*Plus session on one node by way of Oracle Net Services. To achieve this, you must connect to each instance by using a Net Services connection string, typically an instance-specific alias from your tnsnames.ora file. For example, you can use a SQL*Plus session on a local node to shut down two instances on remote nodes by connecting to each using the instance’s individual alias name.
It is not possible to start-up or shut down more than one instance at a time in SQL*Plus, so you cannot start or stop all the instances for a cluster database with a single SQL*Plus command. To verify that instances are running, on any node, look at V$ACTIVE_INSTANCES.
Starting and Stopping Pluggable Databases in Oracle RAC
Administering an Oracle RAC-based multitenant container database (CDB) is somewhat similar to administering a non-CDB. The differences are only that some administrative tasks apply to the entire CDB, some apply only to the root, and some apply to specific pluggable databases (PDBs). Administering a PDB involves a small subset of the tasks required to administer a non-CDB. In this subset of tasks, most are the same for a PDB and a non-CDB. There are some differences, however, such as when you modify the open mode of a PDB. Also, a PDB administrator is limited to managing a single PDB and is not affected by other PDBs in the CBD.
You manage PDBs in an Oracle RAC-based CDB by managing services, regardless of whether the PDBs are policy managed or administrator managed. Assign one dynamic database service to each PDB to coordinate start, stop, and placement of PDBs across instances in a clustered container database.
For example, if you have a CDB called raccont with a policy-managed PDB called spark, which is in a server pool called prod, then assign a service called plug to this database using the following command:
$ srvctl add service –db raccont –pdb spark –service plug –serverpool prod
The service plug will be uniformly managed across all nodes in the server pool. If you want to have this service running as a singleton service in the same server pool, use the -cardinality singleton parameter with the preceding command.
To start the PDB spark, you must start the respective service, plug, as follows:
$ srvctl start service -db raccont -service plug
To stop the PDB spark, you must stop the respective service, plug, as follows:
$ srvctl stop service -db raccont -service plug
You can check the status of the database using the srvctl status service command.
$ srvctl status service
Because PDBs are managed using dynamic database services, typical Oracle RAC-based management practices apply. So, if the service plug is in the ONLINE state when Oracle Clusterware is shut down on a server hosting this service, then the service will be restored to its original state after the restart of Oracle Clusterware on this server. This way, starting PDBs is automated as with any other Oracle RAC database.
Switch Between Automatic and Manual Policies
By default, Oracle Clusterware controls database restarts in Oracle RAC environments. In some cases, you may need to minimize the level of control that Oracle Clusterware has over your Oracle RAC database, for example, during database upgrades.
To prevent Clusterware from restarting your RAC database when you restart your system, or to avoid restarting failed instances more than once, configure a management policy to define the degree of control. There are two management policies: AUTOMATIC, which is the default, and MANUAL. If the management policy is set to AUTOMATIC, the database is automatically restored to its previous running condition (started or stopped) upon restart of the database host computer. If MANUAL, the database is never automatically restarted upon restart of the database host computer. A MANUAL setting does not prevent Oracle Restart from monitoring the database while it is running and restarting it if a failure occurs.
$ srvctl config database -db orcl -a Database unique name: orcl Database name: orcl Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1 Oracle user: oracle Spfile: +DATA/orcl/spfileorcl.ora Password file: +DATA/orcl/orapworcl Domain: cluster01.example.com Start options: open Stop options: immediate Database role: PRIMARY Management policy: AUTOMATIC Server pools: orcldb Database instances: Disk Groups: Mount point paths: Services: Type: RAC ...
Use the following SRVCTL command syntax to change the current management policy to either AUTOMATIC, MANUAL, or NORESTART:
$ srvctl modify database -db db_unique_name -policy [AUTOMATIC | MANUAL | NORESTART]
When you add a new database using the srvctl add database command, you can use the -policy parameter to specify the management policy:
$ srvctl add database -db db_unique_name -policy [AUTOMATIC | MANUAL | NORESTART] -oraclehome $ORACLE_HOME -dbname DATA
This command syntax places the new database under the control of Oracle Clusterware. If you do not provide a management policy option, then Oracle Database uses the default value of automatic. After you change the management policy, the Oracle Clusterware resource records the new value for the affected database.