Sunday, February 14, 2016

Manually Migrate a single instance Oracle 12cR1 database with file system storage to an Oracle RAC environment with ASM Storage

Part III - Convert your single instance database to a RAC database

1. Relink the oracle binary with RAC option to enable RAC enable Oracle Real Application Clusters

-- Execute the following on all nodes where the ORACLE_HOME exists:

-- Log in as the ORACLE_HOME owner.

cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk rac_on ioracle



 2. Add RAC specific parameters to the single instance database

-- Startup the single instance DB in SQLPlus and execute the following commands:

SQL> [oracle@testrac1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 14 18:59:21 2016

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 834666496 bytes
Fixed Size 2929888 bytes
Variable Size 624954144 bytes
Database Buffers 201326592 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
SQL> select instance_name,status from gv$instance;

INSTANCE_NAME STATUS
---------------- ------------
RACDB1 OPEN

SQL>

 -- create an pfile from your current spfile and use it to create your RAC spfile in ASM

SQL> create pfile='initRACDB_bkp.ora' from spfile;

File created.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup pfile='initRACDB_bkp.ora'
ORACLE instance started.

Total System Global Area 834666496 bytes
Fixed Size 2929888 bytes
Variable Size 624954144 bytes
Database Buffers 201326592 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
SQL> select instance_name,status from gv$instance;

INSTANCE_NAME STATUS
---------------- ------------
RACDB1 OPEN

SQL> create spfile='+DATA' from pfile='initRACDB_bkp.ora';

File created.

SQL>

Get the value of your newly created spfile using "asmcmd" and use it to create the initRACDB1.ora file under the dbs directory
[oracle@testrac2 ~]$ asmcmd
ASMCMD> ls
DATA/
FRA/
OCR/
ASMCMD> cd DATA/RACDB/PARAMETERFILE
ASMCMD> pwd
+DATA/RACDB/PARAMETERFILE
ASMCMD> ls
spfile.287.903813031
ASMCMD>

-- So your newly created initRACDB1.ora file will look like this
spfile='+DATA/RACDB/PARAMETERFILE/spfile.287.903813031'

-- Shutdown the DB instance again and bring it up with the newly created spfile.
SQL> show parameter pfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup
ORACLE instance started.

Total System Global Area 834666496 bytes
Fixed Size 2929888 bytes
Variable Size 624954144 bytes
Database Buffers 201326592 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
SQL>
SQL> show parameter pfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/RACDB/PARAMETERFILE/spfil
e.287.903813031
SQL>

-- Now add the Oracle RAC-specific parameters to this spfile and use it to start your RAC database

SQL> alter system set cluster_database=TRUE scope=spfile;

System altered.

SQL> alter system set instance_number=1 scope=spfile sid='*';

System altered.

SQL> alter system set instance_number=2 scope=spfile sid='*';

System altered.

SQL> alter system set thread=1 scope=spfile sid='*';

System altered.

SQL> alter system set thread=2 scope=spfile sid='*';

System altered.

SQL> alter system set undo_tablespace='UNDOTBS1' scope=spfile sid='*';

System altered.

SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile;

System altered.

SQL>

-- Copy over the initRACDB1 to the second node in the appropriate directory
[oracle@testrac1 dbs]$ scp initRACDB1.ora oracle@testrac2:/u01/app/oracle/product/12.0.1/db_1/dbs/initRACDB2.ora
initRACDB1.ora 100% 55 0.1KB/s 00:00
[oracle@testrac1 dbs]$

-- Shutdown the single instance and bring it up as an Oracle RAC database after adding it and its accompanying instances to Oracle Restart

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
[oracle@testrac1 dbs]$ srvctl add db -d RACDB -o /u01/app/oracle/product/12.0.1/db_1 -p '+DATA/RACDB/PARAMETERFILE/spfile.287.902596077'
[oracle@testrac1 dbs]$ srvctl add instance -d RACDB -i RACDB1 -n testrac1.brontechsolutions.com
[oracle@testrac1 dbs]$ srvctl add instance -d RACDB -i RACDB2 -n testrac2.brontechsolutions.com
[oracle@testrac1 dbs]$ srvctl start db -d RACDB
[oracle@testrac2 dbs]$ srvctl status db -d RACDB
Instance RACDB1 is running on node testrac1
Instance RACDB2 is running on node testrac2
[oracle@testrac2 dbs]$
SQL> select instance_name,status from gv$instance;

INSTANCE_NAME STATUS
---------------- ------------
RACDB1 OPEN
RACDB2 OPEN

SQL>

Have fum - Your feedback is always welcome...