Skip to main content

Use dataguard to migrate Oracle RAC database

1. copy password file

if it's 12c database.

run as grid : asmcmd>pwcopy --dbuniquename dbname +datadg/dbname/PASSWORD/pwddbname.277.905359761 /networkbackuplocation/pwddbname.277.905359761
the copy is successful although the output has a message ASMCMD-9456: password file should be located on an ASM disk group"

run as root : asmcmd>pwcopy --dbuniquename dbname_rac /networkbackuplocation/pwddbname.277.905359761 +datadg/orapwdbname_rac
ASMCMD [+] > ls -l +datadg/orapwdbname_rac
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   FEB 02 11:00:00  N    orapwdbname_rac => +datadg/ASM/PASSWORD/pwdasm.284.934889179

or

run as grid : ASMCMD [+datadg] > pwcopy /networkbackuplocation/pwddbname.277.905359761 +datadg/dbname_rac/PASSWORD/pwdbname_rac
copying /networkbackuplocation/pwddbname.277.905359761 -> +datadg/dbname_rac/PASSWORD/pwdbname_rac
ASMCMD [+datadg/ASM/password] > ls -l +datadg/dbname_rac/PASSWORD/pwdbname_rac
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   FEB 02 14:00:00  N    pwdbname_rac => +datadg/ASM/PASSWORD/pwdasm.284.934898903
run as oracle : srvctl modify database -d dbname_rac -pwfile +datadg/dbname_rac/PASSWORD/pwdbname_rac

ASMCMD [+] > ls -l +datadg/orapwdbname_rac
Type      Redund  Striped  Time             Sys  Name
PASSWORD  UNPROT  COARSE   FEB 02 11:00:00  N    orapwdbname_rac => +datadg/ASM/PASSWORD/pwdasm.284.934889179

if it's 11g database:
scp $ORACLE_HOME/dbs/orapwdbname1 @vdclracdev01:$ORACLE_HOME/dbs/orapwdbname_1


2. prepare source database.
alter database force logging;
alter system set log_archive_dest_2 = 'SERVICE=dbname_rac VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dbname_rac' scope=both;
alter system set log_archive_config  = 'dg_config=(dbname_rac,dbname)' scope=both;
create pfile='/networkbackuplocation/init.ora' from spfile;
ALTER SYSTEM SET fal_server='dbname_rac' SCOPE=BOTH;   -- on primary db side

3. backup source database
run {
allocate channel d1 type disk format '/networkbackuplocation/%U';
allocate channel d2 type disk format '/networkbackuplocation/%U';
allocate channel d3 type disk format '/networkbackuplocation/%U';
allocate channel d4 type disk format '/networkbackuplocation/%U';
backup database plus archivelog ;
}

backup current controlfile format '/networkbackuplocation/controlfile'


4. dbca create standby database
4b create tnsnames.ora entry on both side so they can connect to each other
dbname.OPS.company.com =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = vdclractst04.bcferries.corp)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = dbname.OPS.company.com)
    )
  )

dbname_rac.company.com =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = scan.stg01.rac.bcferries.corp)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dbname_rac)
    )
  )

5. prepare standby database
add this line: *.db_unique_name='dbname_rac' to /networkbackuplocation/init.ora
shutdown abort; or srvctl srvctl stop database -d dbname_rac
startup nomount pfile='/networkbackuplocation/init.ora';
create spfile='+datadg/dbname_rac/spfiledbname_rac.ora' from pfile='/networkbackuplocation/init.ora';
asmcmd ls -l +datadg/dbname_rac/spfiledbname_rac.ora
shutdown abort;
startup nomount;
show parameter spfile;
ALTER SYSTEM SET fal_server='dbname.ops.company.com' SCOPE=BOTH;   --- on standby db side
alter system set service_names='dbname_rac.company.com,dbname,dbname.company.com' scope=both;
alter system set log_archive_dest_2 = 'SERVICE=dbname.OPS.company.com VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dbname' scope=both;

6. clean up origional datafiles
asmcmd rm +datadg/dbname_rac/datafile/*
asmcmd rm +datadg/dbname_rac/tempfile/*
asmcmd rm +datadg/dbname_rac/online*/*
asmcmd rm +datadg/dbname_rac/control*/*
asmcmd rm +fradg/dbname_rac/control*/*
asmcmd rm +fradg/dbname_rac/online*/*


7. duplicate standby database in rman
rman target=sys/password@dbname.ops.company.com auxiliary /
run {
allocate auxiliary channel d1 type disk;
allocate auxiliary channel d2 type disk;
allocate auxiliary channel d3 type disk;
allocate auxiliary channel d4 type disk;
duplicate target database for standby;
}

8. recover standby database
alter database open;  -- one instance only
--recover managed standby database using current logfile disconnect;
--or
recover managed standby database   disconnect;
-- alter system archive log current;  -- run on primary db side

set linesize 200
select * from v$dataguard_stats;

SELECT inst_id,PROCESS, pid,client_pid,client_process,STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM gV$MANAGED_STANDBY
where (process='RFS' and thread#<>0) or process<>'RFS'
order by process, inst_id,thread#;

create table dropit (col1 int);
alter system archive log current;
select * from dropit;

9. switchover:
on origional primary side:
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SHUTDOWN ABORT;
startup;
recover managed standby database disconnect;

on origional standby side:
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
ALTER DATABASE OPEN;
create table dropit2 (col1 int);
alter system archive log current;

on new standby side:
select * from dropit2;
set linesize 200
select * from v$dataguard_stats;

10. enable RAC on new primary database:

   ALTER DATABASE ADD LOGFILE THREAD 2
    GROUP 4 ('+datadg','+fradg') size 500M,
    GROUP 5 ('+datadg','+fradg') size 500M,
    GROUP 6 ('+datadg','+fradg') size 500M
   
   
      ALTER DATABASE ADD LOGFILE THREAD 3
        GROUP 7 ('+datadg','+fradg') size 500M,
        GROUP 8 ('+datadg','+fradg') size 500M,
    GROUP 9 ('+datadg','+fradg') size 500M

    select thread#,group#,bytes ,status from v$log;

   
    ALTER DATABASE ENABLE PUBLIC THREAD 2;
    ALTER DATABASE ENABLE PUBLIC THREAD 3;
srvctl start database -d dbname_rac

10 decouple dataguard:
alter system set log_archive_config='NODG_CONFIG' scope=both;
shutdown and delete dataguard database.

Comments

Popular posts from this blog

Opatch apply/lsinventory error: oneoff is corrupted or does not exist

I am applying the quarterly patch for 19c RDBMS, I tried using napply but failed, but somehow it corrupted the inventory though nothing applied. further apply and lsinventory command ran into error like this: $ ./OPatch/opatch lsinventory Oracle Interim Patch Installer version 12.2.0.1.21 Copyright (c) 2020, Oracle Corporation.  All rights reserved. Oracle Home       : /u02/app/oracle/19.0.0 Central Inventory : /u01/app/oraInventory    from           : /u02/app/oracle/19.0.0/oraInst.loc OPatch version    : 12.2.0.1.21 OUI version       : 12.2.0.7.0 Log file location : /u02/app/oracle/19.0.0/cfgtoollogs/opatch/opatch2020-09-08_13-35-59PM_1.log Lsinventory Output file location : /u02/app/oracle/19.0.0/cfgtoollogs/opatch/lsinv/lsinventory2020-09-08_13-35-59PM.txt -------------------------------------------------------------------------------- Inventory load failed... OPatch cannot load inventory ...

oracle dba_hist_sysmetric_summary

found this blog is helpful to get CPU and IO statistics on oracle database. http://shob-dbadmin.blogspot.ca/2012/12/how-to-find-total-io-of-database.html courtesy to  Shomil Bansal , below are hist writing, not mine. How to find total IO of the database instance Total IO of database instance is sum of the physical reads, physical writes and redo writes. There are several views to find these values. v$sysmetric  - Reports metric values for only the most current time sample 60 secs. v$sysmetric_summary  - Reports metric values for time sample of 1 hour. v$sysmetric_history  - Reports metric values every 60 sec from the time instance is up. Better way to analyse IO using this view to take deltas between two time periods. dba_hist_sysmetric_history  - All the above views are refreshed when the instance is restarted. This view, part of AWR, stores the historical stats. I have used this view for my report. Query: ====== set lines 350...

ORA_RMAN_SGA_TARGET

assume that we lost all the files of oracle database but we do have rman backup, when trying to bring up a dummy database before restore start, I get this error. RMAN> startup nomount force; WARNING: cannot translate ORA_RMAN_SGA_TARGET value startup failed: ORA-01078: failure in processing system parameters ORA-01565: error in identifying file '+DATA/PROD/spfilePROD.ora' ORA-17503: ksfdopn:2 Failed to open file +DATA/PROD/spfilePROD.ora ORA-15056: additional error message ORA-17503: ksfdopn:DGOpenFile05 Failed to open file +DATA/prod/spfileprod.ora ORA-17503: ksfdopn:2 Failed to open file +DATA/prod/spfileprod.ora ORA-15173: entry 'spfileprod.ora' does not exist in directory 'prod' ORA-06512: at line 4 starting Oracle instance without parameter file for retrival of spfile RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =================================...