Monday, March 18, 2019

RAC DB on OCI PaaS

Unlike other cloud vendors, in OCI it is possible to create a 2 node RAC without any third party software. The minimum shape needed for creating a 2 node RAC for virtual machine type is VM.Standard(x).2. This will automatically enables the node count spinner allowing it to be changed to 2 nodes (currently the max number of nodes). Additionally cluster name could be specified. Rest of the steps are similar to creating a single instance DB.
For this post 18.3 RAC DB was created in private subnet. The Database specifications are shown below.
The database details are shown below.
An app server on a public subnet on the same VCN is able to resolve the SCAN without any other user configurations.
nslookup rac-scan.londbsubnet.lonvcn.oraclevcn.com
Server:         169.254.169.254
Address:        169.254.169.254#53

Non-authoritative answer:
Name:   rac-scan.londbsubnet.lonvcn.oraclevcn.com
Address: 172.21.0.7
Name:   rac-scan.londbsubnet.lonvcn.oraclevcn.com
Address: 172.21.0.8
Name:   rac-scan.londbsubnet.lonvcn.oraclevcn.com
Address: 172.21.0.6
The hostnames will be suffixed with node number when the cluster is created.
The subnet CIDR block is treated as the public network and second 192.168.* network is created for private interconnect.
oifcfg getif
eth0  172.21.0.0  global  public
eth1  192.168.16.0  global  cluster_interconnect,asm
The /etc/oratab files on all nodes are empty of any ASM or DB instance informations. These need to be added manually if needed.

The RAC configuration is role separated. Following roles exists for oracle and grid user. There are no separate groups for backupdba, kmdba, dgdba or racdba.
[opc@rac1 ~]$ id oracle
uid=101(oracle) gid=1001(oinstall) groups=1001(oinstall),1006(asmdba),1003(dba),1002(dbaoper)
[opc@rac1 ~]$ id grid
uid=102(grid) gid=1001(oinstall) groups=1001(oinstall),1006(asmdba),1005(asmoper),1004(asmadmin),1002(dbaoper)
There's no user equivalence between nodes for oracle or grid user.
cluvfy stage -post crsinst -n all

Verifying User Equivalence ...FAILED (PRVG-2019, PRKC-1191)
PRVF-4009 : User equivalence is not set for nodes: rac2

[oracle@rac1 ~]$ ssh rac2
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

[oracle@rac2 ~]$ ssh rac1
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

[grid@rac1 ~]$ ssh rac2
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

[grid@rac2 ~]$ ssh rac1
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Oracle documentation mentions (this documentation may not be relevant any more) that user equivalence exists for opc user. But that too didn't exists.
[opc@rac1 ~]$ ssh rac2
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

[opc@rac2 ~]$ ssh rac1
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).


The cluster does not use GNS. Below is the full list of resources at the end of the cluster creation.
Resource Name                       Type                           Target             State              Host
-------------                       ------                         -------            --------           ----------
ora.ASMNET1LSNR_ASM.lsnr            ora.asm_listener.type          ONLINE             ONLINE             rac1
ora.ASMNET1LSNR_ASM.lsnr            ora.asm_listener.type          ONLINE             ONLINE             rac2
ora.DATA.COMMONSTORE.advm           ora.volume.type                ONLINE             ONLINE             rac1
ora.DATA.COMMONSTORE.advm           ora.volume.type                ONLINE             ONLINE             rac2
ora.DATA.dg                         ora.diskgroup.type             ONLINE             ONLINE             rac1
ora.DATA.dg                         ora.diskgroup.type             ONLINE             ONLINE             rac2
ora.LISTENER.lsnr                   ora.listener.type              ONLINE             ONLINE             rac1
ora.LISTENER.lsnr                   ora.listener.type              ONLINE             ONLINE             rac2
ora.LISTENER_SCAN1.lsnr             ora.scan_listener.type         ONLINE             ONLINE             rac1
ora.LISTENER_SCAN2.lsnr             ora.scan_listener.type         ONLINE             ONLINE             rac2
ora.LISTENER_SCAN3.lsnr             ora.scan_listener.type         ONLINE             ONLINE             rac2
ora.RECO.dg                         ora.diskgroup.type             ONLINE             ONLINE             rac1
ora.RECO.dg                         ora.diskgroup.type             ONLINE             ONLINE             rac2
ora.asm                             ora.asm.type                   ONLINE             ONLINE             rac1
ora.asm                             ora.asm.type                   ONLINE             ONLINE             rac2
ora.cdbrac_lhr1fq.db                ora.database.type              ONLINE             ONLINE             rac1
ora.cdbrac_lhr1fq.db                ora.database.type              ONLINE             ONLINE             rac2
ora.cvu                             ora.cvu.type                   ONLINE             ONLINE             rac2
ora.data.commonstore.acfs           ora.acfs.type                  ONLINE             ONLINE             rac1
ora.data.commonstore.acfs           ora.acfs.type                  ONLINE             ONLINE             rac2
ora.net1.network                    ora.network.type               ONLINE             ONLINE             rac1
ora.net1.network                    ora.network.type               ONLINE             ONLINE             rac2
ora.ons                             ora.ons.type                   ONLINE             ONLINE             rac1
ora.ons                             ora.ons.type                   ONLINE             ONLINE             rac2
ora.proxy_advm                      ora.proxy_advm.type            ONLINE             ONLINE             rac1
ora.proxy_advm                      ora.proxy_advm.type            ONLINE             ONLINE             rac2
ora.qosmserver                      ora.qosmserver.type            OFFLINE            OFFLINE
ora.rac1.vip                        ora.cluster_vip_net1.type      ONLINE             ONLINE             rac1
ora.rac2.vip                        ora.cluster_vip_net1.type      ONLINE             ONLINE             rac2
ora.scan1.vip                       ora.scan_vip.type              ONLINE             ONLINE             rac1
ora.scan2.vip                       ora.scan_vip.type              ONLINE             ONLINE             rac2
ora.scan3.vip                       ora.scan_vip.type              ONLINE             ONLINE             rac2
Similar to single instance DB RAC DB too consists of two ASM disk groups. OCR and vote is stored in the DATA disk group. The backup location for OCR is also the DATA disk group.
SQL> select name,total_mb,free_Mb from v$asm_diskgroup;

NAME                             TOTAL_MB    FREE_MB
------------------------------ ---------- ----------
DATA                               262144     253408
RECO                               262144     257380

cat /etc/oracle/ocr.loc
#Device/file +DATA getting replaced by device +DATA/dbSyslw4gbgsa/OCRFILE/registry.255.1002113311
ocrconfig_loc=+DATA/dbSyslw4gbgsa/OCRFILE/registry.255.1002113311


[grid@rac1 ~]$ crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   1e4fd3b7b9364fdfbf4dbf41ffde36d9 (/dev/DATADISK3) [DATA]
 
ocrconfig -showbackuploc
The Oracle Cluster Registry backup location is [+DATA].
ASM disks are SCSI attached and permissions are set with udev rules.
SQL> select name,path from v$asm_disk;

NAME                           PATH
------------------------------ ------------------------------
RECODISK4                      /dev/RECODISK4
RECODISK3                      /dev/RECODISK3
RECODISK2                      /dev/RECODISK2
RECODISK1                      /dev/RECODISK1
DATA_0003                      /dev/DATADISK4
DATA_0000                      /dev/DATADISK3
DATA_0001                      /dev/DATADISK2
DATA_0002                      /dev/DATADISK1


[grid@rac1 admin]$ ls -l /dev/DATA*
lrwxrwxrwx 1 root root 3 Mar  5 14:58 /dev/DATADISK1 -> sdb
lrwxrwxrwx 1 root root 3 Mar  5 14:58 /dev/DATADISK2 -> sdc
lrwxrwxrwx 1 root root 3 Mar  5 14:58 /dev/DATADISK3 -> sdd
lrwxrwxrwx 1 root root 3 Mar  5 14:58 /dev/DATADISK4 -> sde


[grid@rac1 admin]$ ls -l /dev/disk/by-id/ | egrep "sdb|sdc|sdd|sde"
lrwxrwxrwx 1 root root  9 Mar  5 14:59 scsi-36012159faf2d4794be5ab57d8a5b7498 -> ../../sdc
lrwxrwxrwx 1 root root 10 Mar  5 12:32 scsi-36012159faf2d4794be5ab57d8a5b7498-part1 -> ../../sdc1
lrwxrwxrwx 1 root root  9 Mar  5 14:59 scsi-36022a3f8dffa46b4a57049af3a2dd275 -> ../../sdb
lrwxrwxrwx 1 root root 10 Mar  5 12:32 scsi-36022a3f8dffa46b4a57049af3a2dd275-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  9 Mar  5 14:59 scsi-360748b62328c4ff6bb8fe3e9e4f04826 -> ../../sdd
lrwxrwxrwx 1 root root 10 Mar  5 12:32 scsi-360748b62328c4ff6bb8fe3e9e4f04826-part1 -> ../../sdd1
lrwxrwxrwx 1 root root  9 Mar  5 14:59 scsi-360923cd17c134686829d791e2b4ff82f -> ../../sde
lrwxrwxrwx 1 root root 10 Mar  5 12:32 scsi-360923cd17c134686829d791e2b4ff82f-part1 -> ../../sde1

cat /etc/udev/rules.d/70-names.rules
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36022a3f8dffa46b4a57049af3a2dd275", SYMLINK+="DATADISK1",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36012159faf2d4794be5ab57d8a5b7498", SYMLINK+="DATADISK2",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="360748b62328c4ff6bb8fe3e9e4f04826", SYMLINK+="DATADISK3",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="360923cd17c134686829d791e2b4ff82f", SYMLINK+="DATADISK4",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="360bc2c20ddc145ceafa98bc1bb1532d3", SYMLINK+="RECODISK1",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="3606feb49caf045598f66042c2831ad38", SYMLINK+="RECODISK2",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="360ad6aca673e4d0a8d2d52aded3ee466", SYMLINK+="RECODISK3",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="360f2aa11901e4736b65d54f96f000dcf", SYMLINK+="RECODISK4",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="3606e328f14b14ddf9042d0eca9038593", SYMLINK+="localdisk",  OWNER="grid",  GROUP="asmadmin",  MODE="0660"
Manual intervention is needed to create the time synchronization between the two nodes. Although NTP service is running, it is not synchronized with an external time source.
Verifying Clock Synchronization ...FAILED
  Verifying Network Time Protocol (NTP) ...FAILED
    Verifying NTP daemon is synchronized with at least one external time source
    ...FAILED
    rac1: PRVG-13602 : NTP daemon is not synchronized with any external time
          source on node "rac1".
As the ntp.conf file is present, the ctss runs in observe mode.
[grid@rac1 ~]$ crsctl check ctss
CRS-4700: The Cluster Time Synchronization Service is in Observer mode.
This also mentioned in oracle documentation where it is recommended "that you configure NTP on both nodes in a 2-node RAC DB System to synchronize time across the nodes. If you do not configure NTP, then Oracle Clusterware configures and uses the Cluster Time Synchronization Service (CTSS), and the cluster time might be out-of-sync with applications that use NTP for time synchronization".
The ntpd file is missing the -x option which prevents setting the clock backwards.
cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
Once the time synchronization is established it could be verified with
cluvfy comp clocksync
Though the cluster was 18c, the oracle home is a read/write home. Not a read only home which was introduced in 18c.
echo $ORACLE_HOME
/u01/app/oracle/product/18.0.0.0/dbhome_1
[oracle@rac2 bin]$ ./orabasehome
/u01/app/oracle/product/18.0.0.0/dbhome_1
The RAC DB created has two log groups per thread.
SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME     CON_ID
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ --------- ----------
         1          1          3 1073741824        512          1 YES INACTIVE               1262776 05-MAR-19      1264208 05-MAR-19          0
         2          1          4 1073741824        512          1 NO  CURRENT                1264244 05-MAR-19   1.8447E+19 05-MAR-19          0
         3          2          5 1073741824        512          1 NO  CURRENT                1262779 05-MAR-19   1.8447E+19                    0
         4          2          4 1073741824        512          1 YES INACTIVE               1242884 05-MAR-19      1262779 05-MAR-19          0
The RAC DB is a administrator managed DB.
srvctl config database -db cdbrac_lhr1fq -a
Database unique name: cdbrac_lhr1fq
Database name: cdbrac
Oracle home: /u01/app/oracle/product/18.0.0.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/CDBRAC_LHR1FQ/PARAMETERFILE/spfile.269.1002115587
Password file: +DATA/CDBRAC_LHR1FQ/PASSWORD/pwdcdbrac_lhr1fq.259.1002114845
Domain: londbsubnet.lonvcn.oraclevcn.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: RECO,DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
Database is enabled
Database is individually enabled on nodes:
Database is individually disabled on nodes:
OSDBA group: dba
OSOPER group: dbaoper
Database instances: cdbrac1,cdbrac2
Configured nodes: rac1,rac2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed
Both DB System patching and DB patching happens in a rolling fashion. Other DB versions where OJVM patch is needed (non-rolling patch) may require total outage. But at least in this case with 18c the patch applying happened rolling fashion.


Similar to single instance DB, RAC DB can also be associated with a data guard configuration. The London region where the initial RAC DB was created had an issue creating a data guard association. Oracle support also confirmed that there are intermittent issues when creating a data guard for RAC DB. However, it was possible to create a RAC DB with data guard association in the Frankfurt region. Following screenshot is of this new RAC DB (as such some names are different).
The DG protection mode is maximum performance.
DGMGRL> show configuration

Configuration - raccdb_fra2bg_raccdb_fra359

  Protection Mode: MaxPerformance
  Members:
  raccdb_fra2bg - Primary database
    raccdb_fra359 - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 19 seconds ago)
Primary Database
DGMGRL> show database raccdb_fra2bg

Database - raccdb_fra2bg

  Role:               PRIMARY
  Intended State:     TRANSPORT-ON
  Instance(s):
    raccdb1
    raccdb2

Database Status:
SUCCESS
Standby Database has both instance up and running, with one being the apply instance.
DGMGRL> show database raccdb_fra359

Database - raccdb_fra359

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 1 second ago)
  Apply Lag:          0 seconds (computed 1 second ago)
  Average Apply Rate: 1.00 KByte/s
  Real Time Query:    ON
  Instance(s):
    raccdb1 (apply instance)
    raccdb2

Database Status:
SUCCESS
Switchover could be performed from the console.
DGMGRL> show configuration

Configuration - raccdb_fra2bg_raccdb_fra359

  Protection Mode: MaxPerformance
  Members:
  raccdb_fra359 - Primary database
    raccdb_fra2bg - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 58 seconds ago)

Related Posts
Data Guard on OCI PaaS DB

Thursday, March 7, 2019

Changing ORACLE_BASE, ORACLE_HOME and GI_HOME in a Oracle Restart Setup

This post gives the steps for changing the location of ORACLE_BASE, ORACLE_HOME, oracle Inventory and Grid Infrastructure in a Oracle restart setup. The current and new paths for these items are given in the table below.

ItemCurrent LocationFuture Location
ORACLE_BASE/opt/app/oracle/u01/app/oracle
ORACLE_HOME/opt/app/oracle/product/11.2.0/dbhome_1/u01/app/oracle/product/11.2.0/dbhome_1
GI_HOME/opt/app/oracle/product/12.1.0/grid/u01/app/oracle/product/12.1.0/grid
Oracle Inventory/opt/app/oraInventory/u01/app/oraInventory

As could be seen from the locations the GI home is a 12.1 while the DB runs out of a 11.2 (11.2.0.4) home.

1. It is assumed the mount point /u01 exists. Create the two base directories first, that is the Oracle base and oracle inventory directories and set the necessary permissions.
# cd /u01/

# mkdir -p app/oracle
# mkdir -p app/oraInventory

# chmod 775 oracle
# chmod 770 oraInventory

# chown oracle:oinstall oracle
# chown grid:oinstall oraInventory
2. Stop the database and the HA service.
srvctl stop database -d westdb
crsctl stop has
3. Detach the current GI home from the inventory.
[grid@west bin]$ ./runInstaller -silent -waitforcompletion -detachHome ORACLE_HOME='/opt/app/oracle/product/12.1.0/grid'
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4097 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
'DetachHome' was successful.
Check the GI home was removed from the inventory by checking in the inventory.xml
<HOME NAME="OraGI12Home1" LOC="/opt/app/oracle/product/12.1.0/grid" TYPE="O" IDX="1" REMOVED="T"/>
4. Create the future GI Home location.
mkdir -p /u01/app/oracle/product/12.1.0/
Copy the current grid folder to the future location.
cd /opt/app/oracle/product/12.1.0
cp -pR grid /u01/app/oracle/product/12.1.0/
5. Clone the GI Home in the new location. Pass the new Oracle base, GI home and oracle inventory locations to the clone script.
cd /u01/app/oracle/product/12.1.0/grid/clone/bin
$ perl clone.pl -silent ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/12.1.0/grid 
ORACLE_HOME_NAME=OraGI12Home1 INVENTORY_LOCATION=/u01/app/oraInventory CRS=true

./runInstaller -clone -waitForCompletion  "ORACLE_BASE=/u01/app/oracle" "ORACLE_HOME=/u01/app/oracle/product/12.1.0/grid" "ORACLE_HOME_NAME=OraGI12Home1" "INVENTORY_LOCATION=/u01/app/oraInventory" -silent -paramFile /u01/app/oracle/product/12.1.0/grid/clone/clone_oraparam.ini
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 17853 MB    Passed
Checking swap space: must be greater than 500 MB.   Actual 4097 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-03-07_06-42-57PM. Please wait ...You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2019-03-07_06-42-57PM.log
..................................................   5% Done.
..................................................   10% Done.
..................................................   15% Done.
..................................................   20% Done.
..................................................   25% Done.
..................................................   30% Done.
..................................................   35% Done.
..................................................   40% Done.
..................................................   45% Done.
..................................................   50% Done.
..................................................   55% Done.
..................................................   60% Done.
..................................................   65% Done.
..................................................   70% Done.
..................................................   75% Done.
..................................................   80% Done.
..................................................   85% Done.
..........Could not backup file /u01/app/oracle/product/12.1.0/grid/root.sh to /u01/app/oracle/product/12.1.0/grid/root.sh.ouibak
Could not backup file /u01/app/oracle/product/12.1.0/grid/rootupgrade.sh to /u01/app/oracle/product/12.1.0/grid/rootupgrade.sh.ouibak

Copy files in progress.

Copy files successful.

Link binaries in progress.

Link binaries successful.

Setup files in progress.

Setup files successful.

Setup Inventory in progress.

Setup Inventory successful.

Finish Setup successful.
The cloning of OraGI12Home1 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2019-03-07_06-42-57PM.log' for more details.

Setup Oracle Base in progress.

Setup Oracle Base successful.
..................................................   95% Done.

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/12.1.0/grid/root.sh



..................................................   100% Done.
You have new mail in /var/spool/mail/grid
6. After running the orainstRoot.sh the inventory location gets updated in the /etc/oraInst.loc
/u01/app/oraInventory/orainstRoot.sh

cat /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
7. Running the root.sh will generate a log file which will have commands to run to create a Oracle restart setup or a cluster setup.
Check /u01/app/oracle/product/12.1.0/grid/install/root_west.domain.net_2019-03-07_18-45-23.log for the output of root script

# tail -f /u01/app/oracle/product/12.1.0/grid/install/root_west.domain.net_2019-03-07_18-45-23.log
Now product-specific root actions will be performed.

To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
/u01/app/oracle/product/12.1.0/grid/perl/bin/perl -I/u01/app/oracle/product/12.1.0/grid/perl/lib -I/u01/app/oracle/product/12.1.0/grid/crs/install /u01/app/oracle/product/12.1.0/grid/crs/install/roothas.pl
8. Before running the command mentioned in the log file, the existing Oracle restart configuration need to be de-configured. If not following error will occur.
Using configuration parameter file: /u01/app/oracle/product/12.1.0/grid/crs/install/crsconfig_params
2019/03/07 18:46:12 CLSRSC-350: Cannot configure two CRS instances on the same cluster

2019/03/07 18:46:14 CLSRSC-352: CRS is already configured on this node for the CRS home location /opt/app/oracle/product/12.1.0/grid
To de-configure run the following command.
# /u01/app/oracle/product/12.1.0/grid/perl/bin/perl roothas.pl -deconfig -force
Using configuration parameter file: ./crsconfig_params
2019/03/07 18:47:50 CLSRSC-337: Successfully deconfigured Oracle Restart stack
9. Run the command to create the Oracle restart setup.
# /u01/app/oracle/product/12.1.0/grid/perl/bin/perl -I/u01/app/oracle/product/12.1.0/grid/perl/lib -I/u01/app/oracle/product/12.1.0/grid/crs/install /u01/app/oracle/product/12.1.0/grid/crs/install/roothas.pl
Using configuration parameter file: /u01/app/oracle/product/12.1.0/grid/crs/install/crsconfig_params
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node west successfully pinned.
2019/03/07 18:48:26 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'

west     2019/03/07 13:18:58     /u01/app/oracle/product/12.1.0/grid/cdata/west/backup_20190307_131858.olr     459864538
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'west'
CRS-2673: Attempting to stop 'ora.evmd' on 'west'
CRS-2677: Stop of 'ora.evmd' on 'west' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'west' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
2019/03/07 18:50:11 CLSRSC-327: Successfully configured Oracle Restart for a standalone server
10. Check the GI home added to inventory in new inventory location.
<HOME NAME="OraGI12Home1" LOC="/u01/app/oracle/product/12.1.0/grid" TYPE="O" IDX="1" CRS="true"/>
11. Add listener and ASM to the Oracle restart config.
srvctl add listener -l listener -o /u01/app/oracle/product/12.1.0/grid -p 1521
srvctl start listener -l listener
srvctl add asm -l listener -p +data/asm/ASMPARAMETERFILE/REGISTRY.253.881942589 -d "/dev/sd*"
srvctl start asm

 crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       west                     STABLE
ora.FLASH.dg
               ONLINE  ONLINE       west                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       west                     STABLE
ora.asm
               ONLINE  ONLINE       west                     Started,STABLE
ora.ons
               OFFLINE OFFLINE      west                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       west                     STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       west                     STABLE
--------------------------------------------------------------------------------


12. Next step is to move the Oracle home to new location. As this is a role separated setup, write permission must be granted to oracle user for admin and diag directories inside Oracle base.
cd $ORACLE_BASE
chmod 775 admin diag
Create the new Oracle home location and copy the current Oracle home (dbhome_1) to new location.
# cd /u01/app/oracle/product
# mkdir -p 11.2.0

# cd /opt/app/oracle/product/11.2.0
# cp -pR dbhome_1 /u01/app/oracle/product/11.2.0/
13. Clone the DB Home
$ cd /u01/app/oracle/product/11.2.0/dbhome_1/clone/

/u01/app/oracle/product/11.2.0/dbhome_1/perl/bin/perl clone.pl ORACLE_BASE="/u01/app/oracle/" ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1" OSDBA_GROUP=dba OSOPER_GROUP=oper -defaultHomeName

./runInstaller -clone -waitForCompletion  "ORACLE_BASE=/u01/app/oracle/" "ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1" "oracle_install_OSDBA=dba" "oracle_install_OSOPER=oper" -defaultHomeName  -defaultHomeName "CRS=true" -silent -noConfig -nowait
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4097 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-03-07_07-21-14PM. Please wait ...Oracle Universal Installer, Version 11.2.0.4.0 Production
Copyright (C) 1999, 2013, Oracle. All rights reserved.

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2019-03-07_07-21-14PM.log
.................................................................................................... 100% Done.

Installation in progress (Thursday, 7 March 2019 19:21:31 o'clock IST)
...........................................................................                                                     75% Done.
Install successful

Linking in progress (Thursday, 7 March 2019 19:21:43 o'clock IST)
Link successful

Setup in progress (Thursday, 7 March 2019 19:22:43 o'clock IST)
Setup successful

End of install phases.(Thursday, 7 March 2019 19:23:08 o'clock IST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts

The cloning of OraHome1 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2019-03-07_07-21-14PM.log' for more details.
Check the inventory is updated with new DB home location.
<HOME NAME="OraDb11g_home1" LOC="/u01/app/oracle/product/11.2.0/dbhome_1" TYPE="O" IDX="2"/>
14. Update the /etc/oratab with the new Oracle home location. Add the database to the Oracle restart configuration.
srvctl add database -d westdb -o /u01/app/oracle/product/11.2.0/dbhome_1 -p +DATA/westdb/spfilewestdb.ora -a "data,flash"
srvctl start database -d westdb
Certain init parameters will refer to paths under previous Oracle base. Change them to reflect the current Oracle base.
show parameter diagnostic_dest
diagnostic_dest                      string      /opt/app/oracle

alter system set diagnostic_dest='/u01/app/oracle' scope=both;
alter system set audit_file_dest='/u01/app/oracle/admin/westdb/adump' scope=spfile;

mkdir -p u01/app/oracle/admin/westdb/adump
15. Stop the database and the Oracle restart stack. Rename the old base location (/opt/app/) to something temporary (/opt/appx/) and start the database. If all steps are followed there shouldn't be any references to previous location. Current oracle base directory could also be found out with orabase.
$ orabase
/u01/app/oracle
Once certain no references to old locations remain those could be removed.

Thursday, February 14, 2019

Local Undo in 12.2 PDB in RAC

In 12.1 all PDBs shared a single undo tablespace. With 12.2 oracle introduced local undo, where each container has it's own undo tablespace on each instance it is opened. Which mode is currently used could be checked with following.
SQL> select * from database_properties where property_name='LOCAL_UNDO_ENABLED';

PROPERTY_NAME        PROPERTY_VALUE  DESCRIPTION
-------------------- --------------- ------------------------------
LOCAL_UNDO_ENABLED   TRUE            true if local undo is enabled
It is possible to move from local undo mode to shared undo mode and vice versa.

In RAC instances this means there would be undo tablespaces per instance and per PDB. However, due to automatic naming convention used this may not be obvious until datafile path is examined. Below example was on a base release of 12.2 with Patch 26124078 applied [ID 2497491.1].

RAC CDB consists of two instances.
SQL> select inst_id,instance_name from gv$instance;

   INST_ID INSTANCE_NAME
---------- ----------------
         1 cdb12c1
         2 cdb12c2
Currently there are no PDBs except the seed.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
The current undo tablespaces are their datafile locations are as follows
    CON_ID TBLSPACE   NAME
---------- ---------- --------------------------------------------------------------------------------
         1 UNDOTBS1   +DATA/ORCL/DATAFILE/undotbs1.279.1000054779
         1 UNDOTBS2   +DATA/ORCL/DATAFILE/undotbs2.289.1000054817
         2 UNDOTBS1   +DATA/ORCL/81B657D10A1B2EE8E0535D00A8C08053/DATAFILE/undotbs1.295.1000054779
Each instance has it's own undo tablespace which is the expected setup on RAC.
SQL> select inst_id,con_id,name,value from gv$parameter where name='undo_tablespace' order by 1;

   INST_ID     CON_ID NAME                      VALUE
---------- ---------- ------------------------- --------------------
         1          1 undo_tablespace           UNDOTBS1
         2          1 undo_tablespace           UNDOTBS2


When creating a PDB and opening it which will create the undo tablespace for remote instance's PDB.
SQL> create pluggable database pdb3 admin user pdb1 identified by pdb1 default tablespace users ;

Pluggable database created.

SQL> alter pluggable database pdb3 open instances=all;

Pluggable database altered.
The alert log on the remote instance shows the creation of this local undo tablespace for the PDB on that instance.
PDB3(3):Opening pdb with no Resource Manager plan active
PDB3(3):CREATE SMALLFILE UNDO TABLESPACE undo_2 DATAFILE '+DATA' SIZE 193986560 AUTOEXTEND ON NEXT 5242880 MAXSIZE 34359721984 ONLINE
2019-02-13T11:35:09.410262+00:00
PDB3(3):[4337] Successfully onlined Undo Tablespace 5.
PDB3(3):Completed: CREATE SMALLFILE UNDO TABLESPACE undo_2 DATAFILE '+DATA' SIZE 193986560 AUTOEXTEND ON NEXT 5242880 MAXSIZE 34359721984 ONLINE
Pluggable database PDB3 opened read write
Login to the PDB and query the instance specific local undo tablespaces.
SQL> alter session set container=pdb3;

Session altered.

SQL> select inst_id,con_id,name,value from gv$parameter where name='undo_tablespace' order by 1;

   INST_ID     CON_ID NAME                      VALUE
---------- ---------- ------------------------- ----------
         1          3 undo_tablespace           UNDOTBS1
         2          3 undo_tablespace           UNDO_2
It appears that the local undo tablespace for PDB on instance 1 uses the same as the CDB$root's undo tablespaces "UNDOTBS1" this is not the case. The datafile for this undo tablesapce shows it's different to root's undo tablespace.
SQL>  select t.con_id,t.name tblspace,d.name from  v$tablespace t, v$datafile d where  d.con_id=t.con_id and t.ts#=d.ts# and t.name like 'UND%' order by 1,2;

    CON_ID TBLSPACE   NAME
---------- ---------- -------------------------------------------------------------------------------
         3 UNDOTBS1   +DATA/ORCL/81C59E3616323828E0535D00A8C059DD/DATAFILE/undotbs1.288.1000121653
         3 UNDO_2     +DATA/ORCL/81C59E3616323828E0535D00A8C059DD/DATAFILE/undo_2.285.1000121707
This shows that each PDB in each instance gets a local UNDO tablespace.

Useful metalink notes
Undo Modes in 12.2 Multitenant Databases - Local and Shared Modes [ID 2169828.1]
Different levels of encrypted undo tablespace across instances PDB In a 12.2 RAC - OCI . [ID 2497491.1]