1)模拟环境,修改主库参数,延迟归档传输到备库
SQL> alter system set log_archive_dest_state_2=defer;
System altered.
2)在主库进行一些DML操作
SQL> create table neal as select * from dba_objects;
Table created.
SQL> delete from neal where rownum<1000;
999 rows deleted.
SQL> commit;
Commit complete.
3)切换日志,产生归档
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
4)查询归档日志应用情况
SQL> select SEQUENCE#,APPLIED from v$archived_log order by SEQUENCE# asc;
SEQUENCE# APPLIED
---------- ---------
839 NO
839 YES
840 NO
840 YES
841 NO
841 YES
842 NO
843 NO
5)将未传到备库的归档文件mv或者rm掉
[oracle@primary orcl]$ mv 1_842_899802738.arc 1_842_899802738.arc.bak
[oracle@primary orcl]$ mv 1_843_899802738.arc 1_843_899802738.arc.bak
[oracle@primary orcl]$ ll -lrth
-rw-r----- 1 oracle oinstall 6.5K Mar 24 14:10 1_842_899802738.arc.bak
-rw-r----- 1 oracle oinstall 11M Mar 24 14:18 1_843_899802738.arc.bak
6)查询目前备库的scn
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
2356278
7)停止备库的应用功能
SQL> alter database recover standby database cancel;
8)将主库延迟归档传输功能恢复
SQL> alter system set log_archive_dest_state_2=enable;
System altered.
9)主库进行基于scn的增量备份
[oracle@primary orcl]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Mar 24 14:24:52 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1427583471)
RMAN> backup incremental from scn 2356278 database format='/u01/backup/incstandby_%u' tag=incstandby;
Starting backup at 24-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=46 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/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/u01/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/u01/oracle/oradata/orcl/qxt01.dbf
input datafile file number=00006 name=/u01/sun01.dbf
input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-MAR-16
channel ORA_DISK_1: finished piece 1 at 24-MAR-16
piece handle=/u01/backup/incstandby_05r19oki tag=INCSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
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 24-MAR-16
channel ORA_DISK_1: finished piece 1 at 24-MAR-16
piece handle=/u01/backup/incstandby_06r19olm tag=INCSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 24-MAR-16
10)传送增量文件到备库
[oracle@primary backup]$ scp incstandby_0* oracle@192.168.8.71:/u01/backup/
oracle@192.168.8.71's password:
incstandby_05r19oki 100% 10MB 10.2MB/s 00:01
incstandby_06r19olm 100% 13MB 12.5MB/s 00:00
11)备库查询传输过来的文件
[oracle@standby backup]$ ll -lrt
total 1134124
-rw-r----- 1 oracle oinstall 1127710720 Dec 30 09:02 backup_899803644_1_1.bak
-rw-r----- 1 oracle oinstall 9830400 Dec 30 09:03 backup_899803700_2_1.bak
-rw-r----- 1 oracle oinstall 10657792 Mar 24 14:28 incstandby_05r19oki
-rw-r----- 1 oracle oinstall 13139968 Mar 24 14:29 incstandby_06r19olm
12)查询备库schema信息
RMAN> report schema;
using target database control file instead of recovery catalog
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name DG
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 760 SYSTEM *** /u01/oracle/oradata/dg/system01.dbf
2 620 SYSAUX *** /u01/oracle/oradata/dg/sysaux01.dbf
3 70 UNDOTBS1 *** /u01/oracle/oradata/dg/undotbs01.dbf
4 5 USERS *** /u01/oracle/oradata/dg/users01.dbf
5 50 QXT *** /u01/oracle/oradata/dg/qxt01.dbf
6 10 SUN *** /u01/sun01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/oracle/oradata/dg/temp01.dbf
13)备库启动到nomount阶段
RMAN> startup nomount;
Oracle instance started
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 499125816 bytes
Database Buffers 281018368 bytes
Redo Buffers 2596864 bytes
14)从备份片里恢复standby控制文件
RMAN> restore standby controlfile from '/u01/backup/incstandby_06r19olm';
Starting restore at 24-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oracle/oradata/dg/control01.ctl
output file name=/u01/oracle/fast_recovery_area/dg/control02.ctl
Finished restore at 24-MAR-16
15)备库启动到mount阶段,并注册备份集
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> catalog start with '/u01/backup/';
searching for all files that match the pattern /u01/backup/
List of Files Unknown to the Database
=====================================
File Name: /u01/backup/incstandby_06r19olm
File Name: /u01/backup/incstandby_05r19oki
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/incstandby_06r19olm
File Name: /u01/backup/incstandby_05r19oki
16)查看备份集注册情况
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 1.05G DISK 00:00:52 30-DEC-15
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20151230T092724
Piece Name: /u01/backup/backup_899803644_1_1.bak
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/system01.dbf
2 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/sysaux01.dbf
3 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/undotbs01.dbf
4 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 9.36M DISK 00:00:07 30-DEC-15
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20151230T092724
Piece Name: /u01/backup/backup_899803700_2_1.bak
SPFILE Included: Modification time: 30-DEC-15
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 964412 Ckp time: 30-DEC-15
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Incr 12.52M DISK 00:00:00 24-MAR-16
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: INCSTANDBY
Piece Name: /u01/backup/incstandby_06r19olm
Control File Included: Ckp SCN: 2357421 Ckp time: 24-MAR-16
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Incr 10.16M DISK 00:00:00 24-MAR-16
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: INCSTANDBY
Piece Name: /u01/backup/incstandby_05r19oki
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/system01.dbf
2 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/sysaux01.dbf
3 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/undotbs01.dbf
4 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/users01.dbf
5 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/qxt01.dbf
6 Incr 2357390 24-MAR-16 /u01/sun01.dbf
17)使用如下语句恢复
RMAN> recover database noredo;
Starting recover at 24-MAR-16
using channel ORA_DISK_1
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/oracle/oradata/dg/system01.dbf
destination for restore of datafile 00002: /u01/oracle/oradata/dg/sysaux01.dbf
destination for restore of datafile 00003: /u01/oracle/oradata/dg/undotbs01.dbf
destination for restore of datafile 00004: /u01/oracle/oradata/dg/users01.dbf
destination for restore of datafile 00005: /u01/oracle/oradata/dg/qxt01.dbf
destination for restore of datafile 00006: /u01/sun01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/incstandby_05r19oki
channel ORA_DISK_1: piece handle=/u01/backup/incstandby_05r19oki tag=INCSTANDBY
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 24-MAR-16
Author:NEAL
DATE:2016-03-31
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29812844/viewspace-2071630/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29812844/viewspace-2071630/