RAC Attack - Oracle Cluster Database at Home/RAC Attack 12c/Service Failover

  Login to collabn1 as the oracle user. Create a new service svctest with RAC1 as a preferred instance and RAC2 as an available instance. This means that it will normally run on the RAC1 instance but will failover to the RAC2 instance if RAC1 becomes unavailable. 

If you haven't created a container database, omit the -pdb parameter.

collabn1:/home/oracle[RAC1]$ srvctl add service -d RAC -pdb PDB -s svctest -r RAC1 -a RAC2 -P BASIC collabn1:/home/oracle[RAC1]$ srvctl start service -d RAC -s svctest

 Examine where the service is running by checking lsnrctl on both nodes and looking at the SERVICE_NAMES init parameter on both nodes. 

collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest Service svctest is running on instance(s) RAC1 collabn1:/home/oracle[RAC1]$ lsnrctl services ... Service "svctest.racattack" has 1 instance(s). Instance "RAC1", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:1 refused:0 state:ready LOCAL SERVER

collabn2:/home/oracle[RAC2]$ lsnrctl services

SQL> col value format a60 SQL> SQL> select name, pdb, inst_id from gv$services; NAME                              PDB                               INST_ID -- -- -- svctest                           PDB                                  1 pdb.racattack                     PDB                                  1 pdb.racattack                     PDB                                  2

 Use SHUTDOWN ABORT to kill the instance where service svctest is running. 

SQL> show user USER is "SYS" SQL> select instance_name from v$instance; INSTANCE_NAME RAC1 SQL> shutdown abort; ORACLE instance shut down. SQL>

 Wait a few moments and then repeat step 2. What has happened? 

collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest

 Restart the instance that you killed. 

collabn1:/home/oracle[RAC1]$ srvctl status database -d RAC Instance RAC1 is not running on node collabn1 Instance RAC2 is running on node collabn2 collabn1:/home/oracle[RAC1]$ srvctl start instance -d RAC -i RAC1 collabn1:/home/oracle[RAC1]$ srvctl status database -d RAC Instance RAC1 is running on node collabn1 Instance RAC2 is running on node collabn2 collabn1:/home/oracle[RAC1]$

 Repeat step 2. Where is the service running now? 

collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest

 Manually failover the service. Confirm where it is now running. Note that this does not disconnect any current sessions 

collabn1:/home/oracle[RAC1]$ srvctl relocate service -d RAC -s svctest -i RAC2 -t RAC1 collabn1:/home/oracle[RAC1]$ srvctl status service -d RAC -s svctest

