High Level Project description

In this article we describe migration of Standalone Oracle DB to 2 Node RAC with Physical Standby, from one datacenter (DC1) into another datacenter (DC2) without direct connectivity between the datacenters. The goal is to switch to DC2, and in DC2 “RAC primary + standby” configuration needed to be activated immediately. We were able to perform this migration in less than 1hr downtime. But time may vary depending on amount archivelogs to be applied to destination on time you bring production down for final cutover.

Source

  • Solaris 10 Sparc Machine
  • Oracle Database 11.2.0.4.5
  • Standalone configuration
  • Non-ASM.
  • 7 TB DB Size

Target

  • Solaris 10 Sparc Machine
  • Oracle Database 11.2.0.4.5
  • Two Node RAC + Physical Standby configuration
  • ASM

Here is a diagram of database migration from DC1 to DC2.

Diagram of Oracle 11g Database migration from  DC1 to DC2. Singles instance to 2 node RAC and Standby

We have only datacenter 2 access.
All source files from Datacenter1 were FTPed into
Datacenter2. Initially we got FTPed RMAN Full backup, controlfile and Standby controlfile with init parameter file. We restored the DB in RAC1 and STDBY, then maintained them in MOUNT state. In order to keep DBs between DC1 and DC2 in sync before final cutover, archivelogs were FTP to DC2 and applied to RAC1 and STDBY in automatic fashion.
When Archive log apply was handled, we configured physical standby dataguard between RAC1, RAC2 and STDBY.
Cutover day we did complete recovery on RAC1/2 and opened database without Resetlogs (!). So, same DB Incarnation continued on RAC1/2 and so on STDBY.

It was a customer requirement NOT to RESETLOG.

Implementation details

PRODDB:

Backup database, controlfile, archive logs, standby control files.

RMAN> Backup database;  
SQL> alter database create standby controlfile as ‘/home/oracle/standby.ctl’;  

Rman backup includes controlfile. Transfer backups and pfile to target db.

RAC1/RAC2 (OLTP) Configuration:

Add below parameter in pfile file and create spfile using pfile.

	db_create_file_dest='+DATA'  
	control_files='+DATA'  
	db_unique_name=primary  
	instance_name=rac1  
	rac1.undo_tablespace='UNDOTBS01'  
	rac2.undo_tablespace='UNDOTBS02'  
	cluster_database_instances=2  
	cluster_database=true  
	rac1.instance_number=1  
	rac2.instance_number=2  
	rac1.thread=1  
	rac2.thread=2  
	archive_log_config='DG_CONFIG(primary,standby)';  
	archive_log_dest_1='location=/export/home/oracle/archivelog';  
	standby_file_management='AUTO'  
	
SQL> create spfile from pfile=’/home/oracle/primary/init.ora’;  

Startup RAC1 to nomount state.

SQL> startup nomount;

Rman Restore controlfile from backup in RAC1

RMAN> restore controlfile from '/export/home/oracle/rman/c-2910588647-20150623-00';

Mount the database on RAC1.

SQL> alter database mount.

Restore database with ASM location on RAC1.

RMAN> run {  
set newname for database to '+DATA';  
restore database;  
switch datafile all;  
recover database;  
}  
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby';  

Same pfile transfer to RAC2 with instance_name modification. Password file should be shared to RAC2 and STDBY. TNS entry should be created and accessed on each other.

Shutdown immediate and startup mount RAC1

SQL> shutdown immediate  
SQL> startup mount;  

Apply archivelogs daily on RAC1 until PRODDB stop ready for cutover.

SQL> recover database until cancel using backup controlfile;

STDBY(ODS) Configuration:

Create spfile with standby parameter modifications.

 archive_log_config='DG_CONFIG(primary,standby)';  
 archive_log_dest_1='location=/export/home/oracle/archivelog';  
 fal_client='standby'  
 fal_server='primary'  
 standby_file_management='AUTO'  
 db_unique_name=standby  
 instance_name=standby  

Restore controlfile and mount the database

RMAN> restore controlfile from '/export/home/oracle/standby.ctl';  

SQL> alter database mount standby database;  

Catalog the database backup on standby database to restore.

RMAN> catalog start with '/export/home/oracle/backup';

Restore database through RMAN.

RMAN> run {  
set newname for database to '+DATA';  
restore database;  
switch datafile all;   
recover database;  
}  

Apply archivelogs until production stop.

SQL> recover automatic standby database;

Verify the Sync between Primary and Standby using below script.

SQL> select max(recid) from v$log_history;

Cutover Day

On time of cutover, shutdown PRODDB. Cold copy:

  • to RAC1: controlfile, redolog files and unapplied archivelogs
  • to STDBY: unapplied archivelogs.

Apply archivelogs on RAC1 and STDBY and verify the sync.

SQL> select max(recid) from v$log_history;

on RAC1

SQL> shutdown immediate  
SQL> startup nomount  

Restore controlfile from cold backup on RAC1

RMAN> restore controlfile from '/export/home/oracle/control01.ctl';

Catalog the OLTP datafile location. It is needed because cold copied from DC1 control file contains location of file from PRODDB (non ASM).

RMAN> catalog start with '+DATA/primary';

Below command will get update to new location in controlfile.

RMAN> switch database to copy;

Place redo log files into RAC1 server. Rename current redolog file to cold copy location.

SQL> alter database rename file '/export/home/oracle/backup/redo01.log' to '/export/home/oracle/redo01.log';

Below command will get error for required Recovery when open the database.

SQL> alter database open;

Recover the database and open the database.
Please note - We can open without resetlogs!! (Complete Recovery). How awesome is it.

SQL> recover database;  
SQL> alter database open;  

Add the logfile thread 2 for RAC2

SQL> alter database add logfile thread 2 group 4 ('+DATA') size 250M;  
SQL> alter database add logfile thread 2 group 5 ('+DATA') size 250M;  
SQL> alter database add logfile thread 2 group 6 ('+DATA') size 250M;  
SQL> alter database enable public thread 2;  

Add another Undo tablespace for RAC2 and recreate temporary tablespace.

SQL> create undo tablespace UNDOTBS02 datafile '+DATA';  
SQL> create temporary tablespace temp1 tempfile '+DATA' size 100M;  
SQL> alter database default temporary tablespace temp1;  
SQL> drop tablespace temp including contents and datafiles;  
SQL> create temporary tablespace temp tempfile '+DATA' SIZE 10G;  
SQL> drop tablespace temp1 including contents and datafiles;  

Recreate Redo log groups for RAC1 in ASM. Remember, current online redologs are on filesytem.

SQL> alter database add logfile group 7 '+DATA' size 50m;  
SQL> alter database add logfile group 8 '+DATA' size 50m;  
SQL> alter database add logfile group 9 '+DATA' size 50m;  
SQL> alter system switch logfile;  
SQL> alter system checkpoint;  
SQL> select GROUP#,THREAD#,STATUS from v$log;  
SQL> alter database drop logfile group 1;  
SQL> alter database drop logfile group 2;  
SQL> alter database drop logfile group 3;  
SQL> alter database add logfile group 1 '+DATA' size 250m;  
SQL> alter database add logfile group 2 '+DATA' size 250m;  
SQL> alter database add logfile group 3 '+DATA' size 250m;  
SQL> alter database drop logfile group 7;  
SQL> alter database drop logfile group 8;  
SQL> alter database drop logfile group 9;  

Add Database to cluster with service control utility (srvctl) at OS Level

srvctl add database -d oltp -o $ORACLE_HOME -p +DATA/RAC0/spfile  
srvctl add instance -d oltp -i rac1 -n oltp1  
srvctl add instance -d oltp -i rac2 -n oltp2  

Shutdown the database

SQL> shutdown immediate.

Start the database using srvctl utility.

srvctl start database -d oltp  
srvctl status database -d oltp  

Now Both RAC1/2 instances are open.
Verify the sync between OLTP and ODS.