DataGuard主库归档文件丢失,备库不需重建实验

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:1654

DataGuard主库归档文件丢失,备库不需重建实验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 NO839 YES840 NO840 YES841 NO841 YES842 NO843 NO 5)将未传到备库的归档文件mv或rm掉[oracle@primary orcl]$ mv -v 1_842_899802738.arc 1_842_899802738.arc.bak[oracle@primary orcl]$ mv -v 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)查询目前备库的scnSQL> 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 2016Copyright (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/forstandby_%u' tag=forstandby;Starting backup at 24-MAR-16using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=46 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00001 name=/u01/oracle/oradata/orcl/system01.dbfinput datafile file number=00002 name=/u01/oracle/oradata/orcl/sysaux01.dbfinput datafile file number=00003 name=/u01/oracle/oradata/orcl/undotbs01.dbfinput datafile file number=00005 name=/u01/oracle/oradata/orcl/qxt01.dbfinput datafile file number=00006 name=/u01/sun01.dbfinput datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbfchannel ORA_DISK_1: starting piece 1 at 24-MAR-16channel ORA_DISK_1: finished piece 1 at 24-MAR-16piece handle=/u01/backup/forstandby_05r19oki tag=FORSTANDBY comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:35channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setchannel ORA_DISK_1: starting piece 1 at 24-MAR-16channel ORA_DISK_1: finished piece 1 at 24-MAR-16piece handle=/u01/backup/forstandby_06r19olm tag=FORSTANDBY comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 24-MAR-16 10)传送增量文件到备库[oracle@primary backup]$ scp -v forstandby_0* [email]oracle@192.168.8.71[/email]:/u01/backup/oracle@192.168.8.71's password:forstandby_05r19oki 100% 10MB 10.2MB/s 00:01forstandby_06r19olm 100% 13MB 12.5MB/s 00:00 11) 备库查询传输过来的文件[oracle@standby backup]$ ll -lrttotal 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 forstandby_05r19oki-rw-r----- 1 oracle oinstall 13139968 Mar 24 14:29 forstandby_06r19olm 12)查询备库schema信息RMAN> report schema; using target database control file instead of recovery catalogRMAN-06139: WARNING: control file is not current for REPORT SCHEMAReport 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.dbf2 620 SYSAUX *** /u01/oracle/oradata/dg/sysaux01.dbf3 70 UNDOTBS1 *** /u01/oracle/oradata/dg/undotbs01.dbf4 5 USERS *** /u01/oracle/oradata/dg/users01.dbf5 50 QXT *** /u01/oracle/oradata/dg/qxt01.dbf6 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 bytesFixed Size 2257352 bytesVariable Size 499125816 bytesDatabase Buffers 281018368 bytesRedo Buffers 2596864 bytes 14) 从备份片里恢复standby控制文件RMAN> restore standby controlfile from '/u01/backup/forstandby_06r19olm';Starting restore at 24-MAR-16allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=19 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/u01/oracle/oradata/dg/control01.ctloutput file name=/u01/oracle/fast_recovery_area/dg/control02.ctlFinished restore at 24-MAR-16 15) 备库启动到mount阶段,并注册备份集RMAN> alter database mount;database mountedreleased 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/forstandby_06r19olmFile Name: /u01/backup/forstandby_05r19oki Do you really want to catalog the above files (enter YES or NO)? yescataloging files...cataloging done List of Cataloged Files=======================File Name: /u01/backup/forstandby_06r19olmFile Name: /u01/backup/forstandby_05r19oki 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-15BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20151230T092724Piece Name: /u01/backup/backup_899803644_1_1.bakList of Datafiles in backup set 1File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/system01.dbf2 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/sysaux01.dbf3 Full 964412 30-DEC-15 /u01/oracle/oradata/dg/undotbs01.dbf4 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-15BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20151230T092724Piece Name: /u01/backup/backup_899803700_2_1.bakSPFILE Included: Modification time: 30-DEC-15SPFILE db_unique_name: ORCLControl 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-16BP Key: 3 Status: AVAILABLE Compressed: NO Tag: FORSTANDBYPiece Name: /u01/backup/forstandby_06r19olmControl 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-16BP Key: 4 Status: AVAILABLE Compressed: NO Tag: FORSTANDBYPiece Name: /u01/backup/forstandby_05r19okiList of Datafiles in backup set 4File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/system01.dbf2 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/sysaux01.dbf3 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/undotbs01.dbf4 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/users01.dbf5 Incr 2357390 24-MAR-16 /u01/oracle/oradata/dg/qxt01.dbf6 Incr 2357390 24-MAR-16 /u01/sun01.dbf 16) 使用如下语句恢复RMAN> recover database noredo;Starting recover at 24-MAR-16using channel ORA_DISK_1channel ORA_DISK_1: starting incremental datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00001: /u01/oracle/oradata/dg/system01.dbfdestination for restore of datafile 00002: /u01/oracle/oradata/dg/sysaux01.dbfdestination for restore of datafile 00003: /u01/oracle/oradata/dg/undotbs01.dbfdestination for restore of datafile 00004: /u01/oracle/oradata/dg/users01.dbfdestination for restore of datafile 00005: /u01/oracle/oradata/dg/qxt01.dbfdestination for restore of datafile 00006: /u01/sun01.dbfchannel ORA_DISK_1: reading from backup piece /u01/backup/forstandby_05r19okichannel ORA_DISK_1: piece handle=/u01/backup/forstandby_05r19oki tag=FORSTANDBYchannel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01Finished recover at 24-MAR-16

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】