首页 > 代码库 > DATAGUARD 在线重建备库

DATAGUARD 在线重建备库

环境: OS: CentOS 6.5 X64  DB: oracle 10.2.0.5故障:之前由于错误激活备库主写导致主备日志同步,重建备库1.关闭备库,删除数据文件及控制文件,redo文件rm -rf *.log rm -rf *.ctl rm -rf *.dbf2.主库备库channel ORA_DISK_1: starting piece 1 at 13-SEP-14RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of backup plus archivelog command at 09/13/2014 17:32:18ORA-19809: limit exceeded for recovery filesORA-19804: cannot reclaim 2380478464 bytes disk space from 2147483648 limit备份的时候出现此错误,这是由于备份的归档日志超过了数据库默认的备份空间容量(为flash_recovery_area).SQL> show parameters db_recovery_file_destNAME                         TYPE     VALUE------------------------------------ ----------- ------------------------------db_recovery_file_dest               string     /u01/app/oracle/flash_recovery                              _areadb_recovery_file_dest_size          big integer 2G将主库的db_recovery_file_dest_size 扩大到4GSQL> alter system set db_recovery_file_dest_size=4G scope=both;System altered.3.重建备库控制文件RMAN> backup full database format=‘/u01/backup/%d_%s.dbf‘ plus archivelog delete input;Starting backup at 13-SEP-14current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=3 recid=1 stamp=857934488input archive log thread=1 sequence=4 recid=3 stamp=858007446input archive log thread=1 sequence=5 recid=5 stamp=858008785input archive log thread=1 sequence=6 recid=7 stamp=858009084input archive log thread=1 sequence=7 recid=9 stamp=858009195input archive log thread=1 sequence=8 recid=11 stamp=858009210input archive log thread=1 sequence=9 recid=13 stamp=858009668input archive log thread=1 sequence=10 recid=15 stamp=858009683input archive log thread=1 sequence=11 recid=17 stamp=858009702input archive log thread=1 sequence=12 recid=19 stamp=858009732input archive log thread=1 sequence=13 recid=20 stamp=858009737input archive log thread=1 sequence=14 recid=21 stamp=858009750input archive log thread=1 sequence=15 recid=23 stamp=858009765input archive log thread=1 sequence=16 recid=24 stamp=858009776input archive log thread=1 sequence=17 recid=25 stamp=858009794input archive log thread=1 sequence=18 recid=28 stamp=858009817input archive log thread=1 sequence=19 recid=30 stamp=858009846input archive log thread=1 sequence=20 recid=32 stamp=858009866input archive log thread=1 sequence=21 recid=35 stamp=858009908input archive log thread=1 sequence=22 recid=39 stamp=858010410input archive log thread=1 sequence=23 recid=41 stamp=858011048input archive log thread=1 sequence=24 recid=43 stamp=858011098input archive log thread=1 sequence=25 recid=45 stamp=858011962input archive log thread=1 sequence=26 recid=47 stamp=858012039input archive log thread=1 sequence=27 recid=49 stamp=858012458input archive log thread=1 sequence=28 recid=50 stamp=858012493input archive log thread=1 sequence=29 recid=52 stamp=858012545input archive log thread=1 sequence=30 recid=55 stamp=858012614input archive log thread=1 sequence=31 recid=57 stamp=858012692input archive log thread=1 sequence=32 recid=58 stamp=858012748input archive log thread=1 sequence=33 recid=60 stamp=858012806input archive log thread=1 sequence=34 recid=63 stamp=858012901input archive log thread=1 sequence=35 recid=65 stamp=858012986input archive log thread=1 sequence=36 recid=67 stamp=858013083input archive log thread=1 sequence=37 recid=68 stamp=858013186input archive log thread=1 sequence=38 recid=70 stamp=858013254input archive log thread=1 sequence=39 recid=73 stamp=858013356input archive log thread=1 sequence=40 recid=75 stamp=858013449input archive log thread=1 sequence=41 recid=77 stamp=858013577input archive log thread=1 sequence=42 recid=79 stamp=858018255input archive log thread=1 sequence=43 recid=81 stamp=858019538input archive log thread=1 sequence=44 recid=82 stamp=858019747input archive log thread=1 sequence=45 recid=85 stamp=858020928input archive log thread=1 sequence=46 recid=87 stamp=858020930input archive log thread=1 sequence=47 recid=89 stamp=858021699input archive log thread=1 sequence=48 recid=90 stamp=858021700input archive log thread=1 sequence=49 recid=93 stamp=858076987input archive log thread=1 sequence=50 recid=95 stamp=858158029input archive log thread=1 sequence=51 recid=97 stamp=858161261input archive log thread=1 sequence=52 recid=99 stamp=858165545input archive log thread=1 sequence=53 recid=101 stamp=858176150input archive log thread=1 sequence=54 recid=102 stamp=858176234input archive log thread=1 sequence=55 recid=103 stamp=858183498input archive log thread=1 sequence=56 recid=104 stamp=858185684input archive log thread=1 sequence=57 recid=105 stamp=858186930input archive log thread=1 sequence=58 recid=106 stamp=858187380input archive log thread=1 sequence=59 recid=107 stamp=858187931input archive log thread=1 sequence=60 recid=108 stamp=858188097channel ORA_DISK_1: starting piece 1 at 13-SEP-14channel ORA_DISK_1: finished piece 1 at 13-SEP-14piece handle=/u01/app/oracle/flash_recovery_area/NETDATA_PD/backupset/2014_09_13/o1_mf_annnn_TAG20140913T173457_b183y2s7_.bkp tag=TAG20140913T173457 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:02:27channel ORA_DISK_1: deleting archive log(s)archive log filename=/u01/app/oracle/archive/netdata/1_3_857898543.arc recid=1 stamp=857934488archive log filename=/u01/app/oracle/archive/netdata/1_4_857898543.arc recid=3 stamp=858007446archive log filename=/u01/app/oracle/archive/netdata/1_5_857898543.arc recid=5 stamp=858008785archive log filename=/u01/app/oracle/archive/netdata/1_6_857898543.arc recid=7 stamp=858009084archive log filename=/u01/app/oracle/archive/netdata/1_7_857898543.arc recid=9 stamp=858009195archive log filename=/u01/app/oracle/archive/netdata/1_8_857898543.arc recid=11 stamp=858009210archive log filename=/u01/app/oracle/archive/netdata/1_9_857898543.arc recid=13 stamp=858009668archive log filename=/u01/app/oracle/archive/netdata/1_10_857898543.arc recid=15 stamp=858009683archive log filename=/u01/app/oracle/archive/netdata/1_11_857898543.arc recid=17 stamp=858009702archive log filename=/u01/app/oracle/archive/netdata/1_12_857898543.arc recid=19 stamp=858009732archive log filename=/u01/app/oracle/archive/netdata/1_13_857898543.arc recid=20 stamp=858009737archive log filename=/u01/app/oracle/archive/netdata/1_14_857898543.arc recid=21 stamp=858009750archive log filename=/u01/app/oracle/archive/netdata/1_15_857898543.arc recid=23 stamp=858009765archive log filename=/u01/app/oracle/archive/netdata/1_16_857898543.arc recid=24 stamp=858009776archive log filename=/u01/app/oracle/archive/netdata/1_17_857898543.arc recid=25 stamp=858009794archive log filename=/u01/app/oracle/archive/netdata/1_18_857898543.arc recid=28 stamp=858009817archive log filename=/u01/app/oracle/archive/netdata/1_19_857898543.arc recid=30 stamp=858009846archive log filename=/u01/app/oracle/archive/netdata/1_20_857898543.arc recid=32 stamp=858009866archive log filename=/u01/app/oracle/archive/netdata/1_21_857898543.arc recid=35 stamp=858009908archive log filename=/u01/app/oracle/archive/netdata/1_22_857898543.arc recid=39 stamp=858010410archive log filename=/u01/app/oracle/archive/netdata/1_23_857898543.arc recid=41 stamp=858011048archive log filename=/u01/app/oracle/archive/netdata/1_24_857898543.arc recid=43 stamp=858011098archive log filename=/u01/app/oracle/archive/netdata/1_25_857898543.arc recid=45 stamp=858011962archive log filename=/u01/app/oracle/archive/netdata/1_26_857898543.arc recid=47 stamp=858012039archive log filename=/u01/app/oracle/archive/netdata/1_27_857898543.arc recid=49 stamp=858012458archive log filename=/u01/app/oracle/archive/netdata/1_28_857898543.arc recid=50 stamp=858012493archive log filename=/u01/app/oracle/archive/netdata/1_29_857898543.arc recid=52 stamp=858012545archive log filename=/u01/app/oracle/archive/netdata/1_30_857898543.arc recid=55 stamp=858012614archive log filename=/u01/app/oracle/archive/netdata/1_31_857898543.arc recid=57 stamp=858012692archive log filename=/u01/app/oracle/archive/netdata/1_32_857898543.arc recid=58 stamp=858012748archive log filename=/u01/app/oracle/archive/netdata/1_33_857898543.arc recid=60 stamp=858012806archive log filename=/u01/app/oracle/archive/netdata/1_34_857898543.arc recid=63 stamp=858012901archive log filename=/u01/app/oracle/archive/netdata/1_35_857898543.arc recid=65 stamp=858012986archive log filename=/u01/app/oracle/archive/netdata/1_36_857898543.arc recid=67 stamp=858013083archive log filename=/u01/app/oracle/archive/netdata/1_37_857898543.arc recid=68 stamp=858013186archive log filename=/u01/app/oracle/archive/netdata/1_38_857898543.arc recid=70 stamp=858013254archive log filename=/u01/app/oracle/archive/netdata/1_39_857898543.arc recid=73 stamp=858013356archive log filename=/u01/app/oracle/archive/netdata/1_40_857898543.arc recid=75 stamp=858013449archive log filename=/u01/app/oracle/archive/netdata/1_41_857898543.arc recid=77 stamp=858013577archive log filename=/u01/app/oracle/archive/netdata/1_42_857898543.arc recid=79 stamp=858018255archive log filename=/u01/app/oracle/archive/netdata/1_43_857898543.arc recid=81 stamp=858019538archive log filename=/u01/app/oracle/archive/netdata/1_44_857898543.arc recid=82 stamp=858019747archive log filename=/u01/app/oracle/archive/netdata/1_45_857898543.arc recid=85 stamp=858020928archive log filename=/u01/app/oracle/archive/netdata/1_46_857898543.arc recid=87 stamp=858020930archive log filename=/u01/app/oracle/archive/netdata/1_47_857898543.arc recid=89 stamp=858021699archive log filename=/u01/app/oracle/archive/netdata/1_48_857898543.arc recid=90 stamp=858021700archive log filename=/u01/app/oracle/archive/netdata/1_49_857898543.arc recid=93 stamp=858076987archive log filename=/u01/app/oracle/archive/netdata/1_50_857898543.arc recid=95 stamp=858158029archive log filename=/u01/app/oracle/archive/netdata/1_51_857898543.arc recid=97 stamp=858161261RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_52_857898543.arc thread=1 sequence=52RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_53_857898543.arc thread=1 sequence=53RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_54_857898543.arc thread=1 sequence=54RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_55_857898543.arc thread=1 sequence=55RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_56_857898543.arc thread=1 sequence=56RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_57_857898543.arc thread=1 sequence=57RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_58_857898543.arc thread=1 sequence=58RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_59_857898543.arc thread=1 sequence=59RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_60_857898543.arc thread=1 sequence=60Finished backup at 13-SEP-14Starting backup at 13-SEP-14using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00001 name=/u01/app/oracle/oradata/netdata/system01.dbfinput datafile fno=00003 name=/u01/app/oracle/oradata/netdata/sysaux01.dbfinput datafile fno=00005 name=/u01/app/oracle/oradata/netdata/example01.dbfinput datafile fno=00006 name=/u01/app/oracle/oradata/netdata/HTSDK_01.dbfinput datafile fno=00007 name=/u01/app/oracle/oradata/netdata/HTSDK_INDEX_01.dbfinput datafile fno=00002 name=/u01/app/oracle/oradata/netdata/undotbs01.dbfinput datafile fno=00004 name=/u01/app/oracle/oradata/netdata/users01.dbfchannel ORA_DISK_1: starting piece 1 at 13-SEP-14channel ORA_DISK_1: finished piece 1 at 13-SEP-14piece handle=/u01/backup/NETDATA_7.dbf tag=TAG20140913T173725 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:02:06channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetincluding current control file in backupsetincluding current SPFILE in backupsetchannel ORA_DISK_1: starting piece 1 at 13-SEP-14channel ORA_DISK_1: finished piece 1 at 13-SEP-14piece handle=/u01/backup/NETDATA_8.dbf tag=TAG20140913T173725 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 13-SEP-14Starting backup at 13-SEP-14current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=61 recid=109 stamp=858188374channel ORA_DISK_1: starting piece 1 at 13-SEP-14channel ORA_DISK_1: finished piece 1 at 13-SEP-14piece handle=/u01/app/oracle/flash_recovery_area/NETDATA_PD/backupset/2014_09_13/o1_mf_annnn_TAG20140913T173934_b1846q4v_.bkp tag=TAG20140913T173934 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02RMAN-08137: WARNING: archive log not deleted as it is still neededarchive log filename=/u01/app/oracle/archive/netdata/1_61_857898543.arc thread=1 sequence=61Finished backup at 13-SEP-14RMAN> quitRecovery Manager complete.备份完成4.为备库重新创建控制文件SQL> alter database create standby controlfile as ‘/u01/control01.ctl‘;Database altered.5.拷贝备份文件及控制文件至备库相同的备份目录[oracle@oracle10g-dg1-213-100 backup]$ scp /u01/backup/*.dbf oracle@192.168.213.101:/u01/backuporacle@192.168.213.101‘s password:NETDATA_7.dbf                                                                                       100% 1926MB   6.2MB/s   05:11   NETDATA_8.dbf                                                                                       100% 7200KB   7.0MB/s   00:01   [oracle@oracle10g-dg1-213-100 backup]$ scp /u01/control01.ctl oracle@192.168.213.101:/u01/backuporacle@192.168.213.101‘s password:control01.ctl                                                                                       100% 7120KB   7.0MB/s   00:01   [oracle@oracle10g-dg1-213-100 backup]$复制三份控制文件文件到指定控制文件目录cp stcontrol01.ctl /u01/app/oracle/oradata/netdata/control01.ctlcp stcontrol01.ctl /u01/app/oracle/oradata/netdata/control02.ctlcp stcontrol01.ctl /u01/app/oracle/oradata/netdata/control03.ctl6.恢复备库[oracle@oracle10g-dg2-213-101 ~]$ rman target /Recovery Manager: Release 10.2.0.5.0 - Production on Sat Sep 13 18:25:57 2014Copyright (c) 1982, 2007, Oracle.  All rights reserved.connected to target database: NETDATA (DBID=351758316, not open)RMAN> restore database;这里记得不要recover database;7.备库开始接收应用日志[oracle@oracle10g-dg2-213-101 ~]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.5.0 - Production on Sat Sep 13 18:26:25 2014Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> alter database recover managed standby database disconnect from session;8.验证是否同步备库:archive log list;Database log mode            Archive ModeAutomatic archival            EnabledArchive destination            /u01/app/oracle/archive/netdataOldest online log sequence     63Next log sequence to archive   0Current log sequence            67col name format A50;col dest_name format A40col error format A20set line 200;select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log);NAME                                  SEQUENCE# APP-------------------------------------------------- ---------- ---/u01/app/oracle/archive/netdata/1_66_857898543.arc        66 YEScol dest_name format A40SQL>  select dest_name,status,error from v$archive_dest where rownum<3;DEST_NAME                    STATUS    ERROR---------------------------------------- --------- --------------------LOG_ARCHIVE_DEST_1               VALIDLOG_ARCHIVE_DEST_2               VALID主库:archive log list;Database log mode            Archive ModeAutomatic archival            EnabledArchive destination            /u01/app/oracle/archive/netdataOldest online log sequence     65Next log sequence to archive   67Current log sequence            67col name format A50;SQL> col dest_name format A40col error format A20set line 200;select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log);SQL> col dest_name format A40select dest_name,status,error from v$archive_dest where rownum<3; NAME                                  SEQUENCE# APP-------------------------------------------------- ---------- ---/u01/app/oracle/archive/netdata/1_66_857898543.arc        66 NOnetdata_sd                                 66 YESSQL> SQL> DEST_NAME                    STATUS    ERROR---------------------------------------- --------- --------------------LOG_ARCHIVE_DEST_1               VALIDLOG_ARCHIVE_DEST_2               VALID

 

DATAGUARD 在线重建备库