Friday, April 7, 2017

Converting Non RAC database to RAC database

Make sure we have core database ready which will be converted to RAC environment. We will be using database duplication of RMAN to move file from system core database to ASM enabled RAC environment. Once after moving from file system to ASM conversion from single instance to multiple instance database takes place. Database would be on ASM shared storage and each instance is start on each cluster node.Make multi-instance database, cluster aware so that failover and load balancing can be achieved. Make sure we have a core database ready to convert to RAC environment on server to complete the practice.


Scenario:-

Single Instance Database Name :- orcl

RAC Database Name :- sorcl

Nodes :- rac1.dba.com
             rac2.dba.com


Perform Cloning and create single instance target database

In very first step we'll perform simple database cloning on rac1.dba.com. For this we have multiple options, suppose we use RMAN duplicate command e.g. duplicate target database to 'sorcl'. Below is sample init file of my database


$vi $ORACLE_HOME/dbs/initsorcl.ora
# Set the RAC database name
db_name ="sorcl"
# set the location of the duplicate clone control file.
control_files ='+DATA/dev/controlfile/current.288.822251901'
#set the below parameters for default location of data files
db_create_file_dest='+DATA'
# set below parameter to create two members for each redo
db_create_online_log_dest_1='+DATA'
# set the location as per your environment
log_archive_dest_1='LOCATION=+DATA'
log_archive_format='arch_%r_%s_%t.arc'
# set below parameter as per your environment
diagnostic_dest= ='/u01/app/oracle'
#Set the below to the same as the production target
db_block_size = 8192
sga_target=537919488
remote_login_passwordfile=exclusive
undo_management =AUTO
undo_retention =10800
undo_tablespace =UNDOTBS1
audit_file_dest='/u01/app/oracle/admin/sorcl/adump'


After completing database duplication successfully, Now database is available to convert to RAC environment, but still single database.

Create UNDO and REDO for second instance

In order to convert single database to cluster database we need to create one UNDO for each instance and two redo log groups minimum as each instance changes are unique.
Create second thread of online redo logs in order to start instance 2 and enable thread 2.It is always recommended to create redo log groups across disk groups for redundancy


SYS@orcl>alter database add logfile thread 2 group 4('+DATA') size 50m reuse;

SYS@orcl>alter database add logfile thread 2 group 5('+DATA') size 50m reuse;

#Enable thread
SYS@orcl>alter database enable thread 2;

#Create UNDO tablespace for second instance
SYS@orcl>create undo tablespace UNDOTBS2 datafile '+DATA' size 500M;


Add Cluster Related parameters

The duplicated instance does not have any cluster related parameters, we need to add the cluster parameter in order to convert single instance to RAC. Add below cluster related parameters to initsorcl.ora


*.cluster_database_instances=2
*.cluster_database=true
sorcl1.instance_number=1
sorcl2.instance_number=2
sorcl 1.thread=1
sorcl 2.thread=2
sorcl 1.undo_tablespace='UNDOTBS1'
sorcl 2.undo_tablespace='UNDOTBS2'


Copy the updated init.ora file to node2 e.g. rac2.dba.com and rename the files as per instance name


scp initsorcl.ora oracle@rac2.dba.com:/u01/app/oracle/product/11.2.0/db_1/dbs/initsorcl.ora

on RAC1: $cp initsorcl.ora initsorcl1.ora

on RAC2: $cp initsorcl.ora initsorcl2.ora


Stop Listener and Database

As we are going to start sorcl instance as sorcl1 and sorcl2 let us stop sorcl instance from node1 e.g. rac1.dba.com and listener also.


Stop the listener.

Shutdown the sorcl database.


Start first instance


Export ORACLE_SID=sorcl1

#Create password file
$orapwd file=orapw$ORACLE_SID password=oracle

> startup
select instance_name from v$instance;


Start Second Instance


#create directory structure for audit_file_dest in node2 as well

export ORACLE_SID=sorcl2

#create password file
$orapwd file=orapw$ORACLE_SID password=oracle

> startup
select instance_name from v$instance;


Register the RAC database (sorcl) and instances (sorcl1 & sorcl2) with CRS

Now sorcl database is having two instance one on each RAC nodes. In order manage these instances and database let us make sorcl db and instance cluster aware.


export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

srvctl add database -d sorcl -o /u01/app/oracle/product/11.2.0/db_1

srvctl add instance -d sorcl -i sorcl1 -n rac1

srvctl add instance -d sorcl -i sorcl2 -n rac2

crsctl stat res -t


Update SPFILE Location

Let us create spfile from pfile and place spfile on shared location. Use pfile to point to spfile.


[oracle@rac3 ~]$ export ORACLE_SID=sorcl1

[oracle@rac3 ~]$ sqlplus / as sysdba

SYS@sorcl1>create spfile='+DATA' from pfile;
File created.

#Keeps an entry on each node in initsorcl1.ora initsorcl2.ora
spfile=' +DATA/SORCL/PARAMETERFILE/spfile.491.940617585'

#Restart the database in order to take effect of spfile
srvctl stop database -d sorcl

srvctl modify database -d sorcl -p '+DATA/SORCL/PARAMETERFILE/spfile.491.940617585'

srvctl start database -d sorcl

[oracle@rac1 ~]$ srvctl status database -d sorcl
Instance sorcl2 is running on node rac1
Instance sorcl1 is running on node rac2


Check clusterware and Database Status


[oracle@rac1 ~]$ crsctl stat res -t
[oracle@rac1 ~]$ cluvfy comp crs -n all -verbose



2 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in ORACLE SOLARIS, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on ORACLE SOLARIS. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Avishek Priyadarshi
    MaxMunus
    E-mail: avishek@maxmunus.com
    Skype id: avishek_2 .
    Ph:(0) 8553177744 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete
  2. Thanks Avishek for good words !!

    ReplyDelete