码迷,mamicode.com
首页 > 其他好文 > 详细

DATAGUARD 在线重建备库

时间:2014-09-13 19:56:45      阅读:398      评论:0      收藏:0      [点我收藏+]

标签:des   blog   io   os   ar   for   文件   数据   2014   

环境: 
OS: CentOS 6.5 X64  DB: oracle 10.2.0.5
故障:之前由于错误激活备库主写导致主备日志同步,重建备库

1.关闭备库,删除数据文件及控制文件,redo文件
rm -rf *.log rm -rf *.ctl rm -rf *.dbf

2.主库备库
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 09/13/2014 17:32:18
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 2380478464 bytes disk space from 2147483648 limit
备份的时候出现此错误,这是由于备份的归档日志超过了数据库默认的备份空间容量(为flash_recovery_area).
SQL> show parameters db_recovery_file_dest

NAME                         TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest               string     /u01/app/oracle/flash_recovery
                              _area
db_recovery_file_dest_size          big integer 2G
将主库的db_recovery_file_dest_size 扩大到4G

SQL> 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-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=1 stamp=857934488
input archive log thread=1 sequence=4 recid=3 stamp=858007446
input archive log thread=1 sequence=5 recid=5 stamp=858008785
input archive log thread=1 sequence=6 recid=7 stamp=858009084
input archive log thread=1 sequence=7 recid=9 stamp=858009195
input archive log thread=1 sequence=8 recid=11 stamp=858009210
input archive log thread=1 sequence=9 recid=13 stamp=858009668
input archive log thread=1 sequence=10 recid=15 stamp=858009683
input archive log thread=1 sequence=11 recid=17 stamp=858009702
input archive log thread=1 sequence=12 recid=19 stamp=858009732
input archive log thread=1 sequence=13 recid=20 stamp=858009737
input archive log thread=1 sequence=14 recid=21 stamp=858009750
input archive log thread=1 sequence=15 recid=23 stamp=858009765
input archive log thread=1 sequence=16 recid=24 stamp=858009776
input archive log thread=1 sequence=17 recid=25 stamp=858009794
input archive log thread=1 sequence=18 recid=28 stamp=858009817
input archive log thread=1 sequence=19 recid=30 stamp=858009846
input archive log thread=1 sequence=20 recid=32 stamp=858009866
input archive log thread=1 sequence=21 recid=35 stamp=858009908
input archive log thread=1 sequence=22 recid=39 stamp=858010410
input archive log thread=1 sequence=23 recid=41 stamp=858011048
input archive log thread=1 sequence=24 recid=43 stamp=858011098
input archive log thread=1 sequence=25 recid=45 stamp=858011962
input archive log thread=1 sequence=26 recid=47 stamp=858012039
input archive log thread=1 sequence=27 recid=49 stamp=858012458
input archive log thread=1 sequence=28 recid=50 stamp=858012493
input archive log thread=1 sequence=29 recid=52 stamp=858012545
input archive log thread=1 sequence=30 recid=55 stamp=858012614
input archive log thread=1 sequence=31 recid=57 stamp=858012692
input archive log thread=1 sequence=32 recid=58 stamp=858012748
input archive log thread=1 sequence=33 recid=60 stamp=858012806
input archive log thread=1 sequence=34 recid=63 stamp=858012901
input archive log thread=1 sequence=35 recid=65 stamp=858012986
input archive log thread=1 sequence=36 recid=67 stamp=858013083
input archive log thread=1 sequence=37 recid=68 stamp=858013186
input archive log thread=1 sequence=38 recid=70 stamp=858013254
input archive log thread=1 sequence=39 recid=73 stamp=858013356
input archive log thread=1 sequence=40 recid=75 stamp=858013449
input archive log thread=1 sequence=41 recid=77 stamp=858013577
input archive log thread=1 sequence=42 recid=79 stamp=858018255
input archive log thread=1 sequence=43 recid=81 stamp=858019538
input archive log thread=1 sequence=44 recid=82 stamp=858019747
input archive log thread=1 sequence=45 recid=85 stamp=858020928
input archive log thread=1 sequence=46 recid=87 stamp=858020930
input archive log thread=1 sequence=47 recid=89 stamp=858021699
input archive log thread=1 sequence=48 recid=90 stamp=858021700
input archive log thread=1 sequence=49 recid=93 stamp=858076987
input archive log thread=1 sequence=50 recid=95 stamp=858158029
input archive log thread=1 sequence=51 recid=97 stamp=858161261
input archive log thread=1 sequence=52 recid=99 stamp=858165545
input archive log thread=1 sequence=53 recid=101 stamp=858176150
input archive log thread=1 sequence=54 recid=102 stamp=858176234
input archive log thread=1 sequence=55 recid=103 stamp=858183498
input archive log thread=1 sequence=56 recid=104 stamp=858185684
input archive log thread=1 sequence=57 recid=105 stamp=858186930
input archive log thread=1 sequence=58 recid=106 stamp=858187380
input archive log thread=1 sequence=59 recid=107 stamp=858187931
input archive log thread=1 sequence=60 recid=108 stamp=858188097
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
channel ORA_DISK_1: finished piece 1 at 13-SEP-14
piece handle=/u01/app/oracle/flash_recovery_area/NETDATA_PD/backupset/2014_09_13/o1_mf_annnn_TAG20140913T173457_b183y2s7_.bkp tag=TAG20140913T173457 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:27
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/archive/netdata/1_3_857898543.arc recid=1 stamp=857934488
archive log filename=/u01/app/oracle/archive/netdata/1_4_857898543.arc recid=3 stamp=858007446
archive log filename=/u01/app/oracle/archive/netdata/1_5_857898543.arc recid=5 stamp=858008785
archive log filename=/u01/app/oracle/archive/netdata/1_6_857898543.arc recid=7 stamp=858009084
archive log filename=/u01/app/oracle/archive/netdata/1_7_857898543.arc recid=9 stamp=858009195
archive log filename=/u01/app/oracle/archive/netdata/1_8_857898543.arc recid=11 stamp=858009210
archive log filename=/u01/app/oracle/archive/netdata/1_9_857898543.arc recid=13 stamp=858009668
archive log filename=/u01/app/oracle/archive/netdata/1_10_857898543.arc recid=15 stamp=858009683
archive log filename=/u01/app/oracle/archive/netdata/1_11_857898543.arc recid=17 stamp=858009702
archive log filename=/u01/app/oracle/archive/netdata/1_12_857898543.arc recid=19 stamp=858009732
archive log filename=/u01/app/oracle/archive/netdata/1_13_857898543.arc recid=20 stamp=858009737
archive log filename=/u01/app/oracle/archive/netdata/1_14_857898543.arc recid=21 stamp=858009750
archive log filename=/u01/app/oracle/archive/netdata/1_15_857898543.arc recid=23 stamp=858009765
archive log filename=/u01/app/oracle/archive/netdata/1_16_857898543.arc recid=24 stamp=858009776
archive log filename=/u01/app/oracle/archive/netdata/1_17_857898543.arc recid=25 stamp=858009794
archive log filename=/u01/app/oracle/archive/netdata/1_18_857898543.arc recid=28 stamp=858009817
archive log filename=/u01/app/oracle/archive/netdata/1_19_857898543.arc recid=30 stamp=858009846
archive log filename=/u01/app/oracle/archive/netdata/1_20_857898543.arc recid=32 stamp=858009866
archive log filename=/u01/app/oracle/archive/netdata/1_21_857898543.arc recid=35 stamp=858009908
archive log filename=/u01/app/oracle/archive/netdata/1_22_857898543.arc recid=39 stamp=858010410
archive log filename=/u01/app/oracle/archive/netdata/1_23_857898543.arc recid=41 stamp=858011048
archive log filename=/u01/app/oracle/archive/netdata/1_24_857898543.arc recid=43 stamp=858011098
archive log filename=/u01/app/oracle/archive/netdata/1_25_857898543.arc recid=45 stamp=858011962
archive log filename=/u01/app/oracle/archive/netdata/1_26_857898543.arc recid=47 stamp=858012039
archive log filename=/u01/app/oracle/archive/netdata/1_27_857898543.arc recid=49 stamp=858012458
archive log filename=/u01/app/oracle/archive/netdata/1_28_857898543.arc recid=50 stamp=858012493
archive log filename=/u01/app/oracle/archive/netdata/1_29_857898543.arc recid=52 stamp=858012545
archive log filename=/u01/app/oracle/archive/netdata/1_30_857898543.arc recid=55 stamp=858012614
archive log filename=/u01/app/oracle/archive/netdata/1_31_857898543.arc recid=57 stamp=858012692
archive log filename=/u01/app/oracle/archive/netdata/1_32_857898543.arc recid=58 stamp=858012748
archive log filename=/u01/app/oracle/archive/netdata/1_33_857898543.arc recid=60 stamp=858012806
archive log filename=/u01/app/oracle/archive/netdata/1_34_857898543.arc recid=63 stamp=858012901
archive log filename=/u01/app/oracle/archive/netdata/1_35_857898543.arc recid=65 stamp=858012986
archive log filename=/u01/app/oracle/archive/netdata/1_36_857898543.arc recid=67 stamp=858013083
archive log filename=/u01/app/oracle/archive/netdata/1_37_857898543.arc recid=68 stamp=858013186
archive log filename=/u01/app/oracle/archive/netdata/1_38_857898543.arc recid=70 stamp=858013254
archive log filename=/u01/app/oracle/archive/netdata/1_39_857898543.arc recid=73 stamp=858013356
archive log filename=/u01/app/oracle/archive/netdata/1_40_857898543.arc recid=75 stamp=858013449
archive log filename=/u01/app/oracle/archive/netdata/1_41_857898543.arc recid=77 stamp=858013577
archive log filename=/u01/app/oracle/archive/netdata/1_42_857898543.arc recid=79 stamp=858018255
archive log filename=/u01/app/oracle/archive/netdata/1_43_857898543.arc recid=81 stamp=858019538
archive log filename=/u01/app/oracle/archive/netdata/1_44_857898543.arc recid=82 stamp=858019747
archive log filename=/u01/app/oracle/archive/netdata/1_45_857898543.arc recid=85 stamp=858020928
archive log filename=/u01/app/oracle/archive/netdata/1_46_857898543.arc recid=87 stamp=858020930
archive log filename=/u01/app/oracle/archive/netdata/1_47_857898543.arc recid=89 stamp=858021699
archive log filename=/u01/app/oracle/archive/netdata/1_48_857898543.arc recid=90 stamp=858021700
archive log filename=/u01/app/oracle/archive/netdata/1_49_857898543.arc recid=93 stamp=858076987
archive log filename=/u01/app/oracle/archive/netdata/1_50_857898543.arc recid=95 stamp=858158029
archive log filename=/u01/app/oracle/archive/netdata/1_51_857898543.arc recid=97 stamp=858161261
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_52_857898543.arc thread=1 sequence=52
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_53_857898543.arc thread=1 sequence=53
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_54_857898543.arc thread=1 sequence=54
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_55_857898543.arc thread=1 sequence=55
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_56_857898543.arc thread=1 sequence=56
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_57_857898543.arc thread=1 sequence=57
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_58_857898543.arc thread=1 sequence=58
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_59_857898543.arc thread=1 sequence=59
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_60_857898543.arc thread=1 sequence=60
Finished backup at 13-SEP-14

Starting backup at 13-SEP-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/netdata/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/netdata/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/netdata/example01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/netdata/HTSDK_01.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/netdata/HTSDK_INDEX_01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/netdata/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/netdata/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
channel ORA_DISK_1: finished piece 1 at 13-SEP-14
piece handle=/u01/backup/NETDATA_7.dbf tag=TAG20140913T173725 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:06
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
channel ORA_DISK_1: finished piece 1 at 13-SEP-14
piece handle=/u01/backup/NETDATA_8.dbf tag=TAG20140913T173725 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 13-SEP-14

Starting backup at 13-SEP-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=61 recid=109 stamp=858188374
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
channel ORA_DISK_1: finished piece 1 at 13-SEP-14
piece handle=/u01/app/oracle/flash_recovery_area/NETDATA_PD/backupset/2014_09_13/o1_mf_annnn_TAG20140913T173934_b1846q4v_.bkp tag=TAG20140913T173934 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
RMAN-08137: WARNING: archive log not deleted as it is still needed
archive log filename=/u01/app/oracle/archive/netdata/1_61_857898543.arc thread=1 sequence=61
Finished backup at 13-SEP-14

RMAN> quit


Recovery 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/backup
oracle@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/backup
oracle@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.ctl
cp stcontrol01.ctl /u01/app/oracle/oradata/netdata/control02.ctl
cp stcontrol01.ctl /u01/app/oracle/oradata/netdata/control03.ctl

6.恢复备库
[oracle@oracle10g-dg2-213-101 ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Sat Sep 13 18:25:57 2014

Copyright (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 sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Sep 13 18:26:25 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

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

8.验证是否同步
备库:
archive log list;
Database log mode            Archive Mode
Automatic archival            Enabled
Archive destination            /u01/app/oracle/archive/netdata
Oldest online log sequence     63
Next log sequence to archive   0
Current log sequence            67
col name format A50;
col dest_name format A40
col error format A20
set 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 YES

col dest_name format A40
SQL>  select dest_name,status,error from v$archive_dest where rownum<3;

DEST_NAME                    STATUS    ERROR
---------------------------------------- --------- --------------------
LOG_ARCHIVE_DEST_1               VALID
LOG_ARCHIVE_DEST_2               VALID

主库:
archive log list;
Database log mode            Archive Mode
Automatic archival            Enabled
Archive destination            /u01/app/oracle/archive/netdata
Oldest online log sequence     65
Next log sequence to archive   67
Current log sequence            67
col name format A50;
SQL> col dest_name format A40
col error format A20
set 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 A40
select dest_name,status,error from v$archive_dest where rownum<3; 

NAME                                  SEQUENCE# APP
-------------------------------------------------- ---------- ---
/u01/app/oracle/archive/netdata/1_66_857898543.arc        66 NO
netdata_sd                                 66 YES

SQL> SQL> 
DEST_NAME                    STATUS    ERROR
---------------------------------------- --------- --------------------
LOG_ARCHIVE_DEST_1               VALID
LOG_ARCHIVE_DEST_2               VALID

 

DATAGUARD 在线重建备库

标签:des   blog   io   os   ar   for   文件   数据   2014   

原文地址:http://www.cnblogs.com/shawnloong/p/3970147.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!