Monday, March 16, 2020

Roll Forward Physical Standby Database using RMAN incremental backup


1.      Current_scn from primary database and standby database.
   


PRIMARY

[oracle@ranesh ~]$ cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.182.130 ranesh.doyensys.com  ranesh
192.168.182.129 ranesh2.doyensys.com ranesh2

SQL> select name,db_unique_name,database_role,log_mode,flashback_on from v$database;
NAME              DB_UNIQUE_NAME                    DATABASE_ROLE   LOG_MODE     FLASHBACK_ON
--------- ------------------------------ ---------------- ------------ ------------------
WARANGAL  warangal                                PRIMARY      ARCHIVELOG   YES

SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1918456

RMAN target /
BACKUP INCREMENTAL FROM SCN 1918456 DATABASE FORMAT '/u01/ForStandby_%U' tag 'FORSTANDBY';

Starting backup at 31-JAN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=70 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/warangal/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/warangal/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/warangal/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ranesh.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/warangal/users01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ramya.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ranesh333.dbf
channel ORA_DISK_1: starting piece 1 at 31-JAN-20
piece handle=/u01/ForStandby_15unbt32_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:57
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 31-JAN-20
channel ORA_DISK_1: finished piece 1 at 31-JAN-20
piece handle=/u01/ForStandby_16unbt8k_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 31-JAN-20

[oracle@ranesh backup]$ scp -p ForStandby_16unbt8k_1_1oracle@192.168.182.131:/u01
168.182.131's password:
ForStandby_15unbt32_1_1                       100%   15MB  15.1MB/s   00:01 
 
[oracle@ranesh backup]$ scp -p ForStandby_16unbt8k_1_1 oracle@192.168.182.131:/u01
oracle@192.168.182.131's password:
ForStandby_16unbt8k_1_1                       100%   10MB   9.9MB/s   00:01 
 
[oracle@ranesh backup]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jan 31 12:12:29 2020

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: WARANGAL (DBID=4024448274)

RMAN> backup current controlfile for standby format '/u01/stb.ctl'; 

Starting backup at 31-JAN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=55 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 31-JAN-20
channel ORA_DISK_1: finished piece 1 at 31-JAN-20
piece handle=/u01/stb.ctl tag=TAG20200131T121242 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 31-JAN-20


STANDY BY

SQL> select name,db_unique_name,database_role,log_mode,open_mode,flashback_on from v$database;
NAME              DB_UNIQUE_NAME                    DATABASE_ROLE   LOG_MODE     OPEN_MODE          FLASHBACK_ON
--------- ------------------------------ ---------------- ------------ -------------------- ------------------
WARANGAL  mumbai                                 PHYSICAL STANDBY ARCHIVELOG   READ ONLY                YES

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
  1927001

[oracle@ranesh2 u01]$ chmod -R 777 backup

[oracle@ranesh2 u01]$ ls

app  backup  lost+found

[oracle@ranesh2 u01]$ cd backup/

[oracle@ranesh2 backup]$ ls -ltr
total 35744
-rwxrwxrwx. 1 oracle oinstall 15826944 Jan 31  2020 ForStandby_15unbt32_1_1
-rwxrwxrwx. 1 oracle oinstall 10387456 Jan 31  2020 ForStandby_16unbt8k_1_1
-rwxrwxrwx. 1 oracle oinstall 10387456 Jan 31  2020 stb.ctl

RMAN> CATALOG START WITH '/u01/backup/ForStandby'        
2> ;

using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/backup/ForStandby

List of Files Unknown to the Database
=====================================
File Name: /u01/backup/ForStandby_16unbt8k_1_1
File Name: /u01/backup/ForStandby_15unbt32_1_1

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/backup/ForStandby_16unbt8k_1_1
File Name: /u01/backup/ForStandby_15unbt32_1_1

RMAN> recover database noredo;

 

Starting recover at 31-JAN-20

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=34 device type=DISK

channel ORA_DISK_1: starting incremental datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

destination for restore of datafile 00001: /u01/app/oracle/oradata/STAND/system01.dbf

destination for restore of datafile 00003: /u01/app/oracle/oradata/STAND/sysaux01.dbf

destination for restore of datafile 00004: /u01/app/oracle/oradata/STAND/undotbs01.dbf

destination for restore of datafile 00005: /u01/app/oracle/oradata/STAND/example01.dbf

destination for restore of datafile 00006: /u01/app/oracle/oradata/STAND/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/ForStandby_0sunot75_1_1

channel ORA_DISK_1: piece handle=/u01/backup/ForStandby_0sunot75_1_1 tag=FORSTANDBY

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

 

starting media recovery

 

media recovery complete, elapsed time: 00:00:00

Finished recover at 31-JAN-20


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1577058304 bytes
Fixed Size                       2924832 bytes
Variable Size                 503320288 bytes
Database Buffers        1056964608 bytes
Redo Buffers                 13848576 bytes

RMAN> restore standby controlfile from '/u01/backup/stb.ctl';

Starting restore at 31-JAN-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/mumbai/standby1.ctl
Finished restore at 31-JAN-20


RMAN> alter database mount;

Statement processed
released channel: ORA_DISK_1

RMAN> alter database recover managed standby database  disconnect  from session;


Statement processed

No comments:

Table import and export.

Create Data Pump Directory. The first step in Oracle Data Pump is to create an OS level directory which will be used by Oracle for perform...