DATAGUARD 在线重建备库

环境:
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.拷贝备份文件及控制文件至备库相同的备份目录
[[email protected] backup]$ scp /u01/backup/*.dbf [email protected]:/u01/backup
[email protected]‘s password:
NETDATA_7.dbf                                                                                       100% 1926MB   6.2MB/s   05:11
NETDATA_8.dbf                                                                                       100% 7200KB   7.0MB/s   00:01
[[email protected] backup]$ scp /u01/control01.ctl [email protected]:/u01/backup
[email protected]‘s password:
control01.ctl                                                                                       100% 7120KB   7.0MB/s   00:01
[[email protected] 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.恢复备库
[[email protected] ~]$ 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.备库开始接收应用日志
[[email protected] ~]$ 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
时间: 2024-10-22 19:06:28

DATAGUARD 在线重建备库的相关文章

Oracle主库归档丢失,备库日志有gap,在不重建备库的情况下,恢复备库

本文主要描述Oracle备库日志与主库日志之间有gap,切主库这部分gap的归档日志已经删除或丢失,如何在不重建备库的情况下,恢复备库. 欢迎转载,请注明作者.出处. 作者:张正 blog:http://space.itpub.net/26355921 QQ:176036317 如有疑问,欢迎联系. 在dataguard环境中,由于主库archivelog丢失,且尚未同步到standby,问如何在避免 重建standby的情况下来将standby恢复成功的. 下面是我的测试过程,供参考! —-主

Dataguard搭建灾备库操作手册

数据库:Oracle11gr2 主库 alter database force logging; alter system set db_unique_name='erpdb' scope=spfile;  --我们让主库db_name=db_unique_name alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile; alter system set LOG_ARCHIVE_FORMAT='%t_%s_%r.arc

Oracle 11g Dataguard 暂停物理备库的日志传输

Oracle 11g Dataguard 暂停物理备库的日志传输分类: Oracle2017-07-18 10:03:17这两天生产端的日志产生过多导致灾备端的归档日志目录满的现象,在清除灾备端的日志后发现log_archive_dest_2处于error状态,需要将其enable.在实际生产系统中,通常有这样的场景,例如在系统维护日,对主库进行大量的业务更新,会有大量的DML操作:为了避免主库中的业务更新对备库造成影响,可以暂停主库对备库的日志传输,这样的话,如果主库的更新出现问题,备库还保留

Dataguard主、备库切换方法总结

Dataguard主.备库切换方法总结 2019-04-11 分类:Oracle 阅读(754) 评论(0) 文章目录[隐藏] 一.主备切换: 一.主备切换: 1.将主库切换成物理standby: alter database commit to switchover to physical standby with session shutdown; startup mount; 2.备库执行切换成primary,完成后数据库是mount,需要open: recover managed sta

Dataguard搭建灾备库操作

DJI erpdb库搭建DG 数据库:Oracle11gr2 主库 (下面打井号的不用执行) alter database force logging; alter system set db_unique_name='erp' scope=spfile; --我们让主库db_name=db_unique_name alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile; alter system set LOG_ARC

Oracle 11g Data Guard 物理备库快速配置指南(上)

缘起 最近做了10g和11g的物理备库配置实验,发现 Data Guard 其实很容易,但是缺少好文档.我是参考官方文档做的实验,觉得它写的不是很清楚的. Google 出来两个pdf文档,读了觉得比官方文档强很多.翻译下,也许会对某些朋友有用.翻译的同时我也好更熟悉下这两个文档.好久没翻译过英文了,可以顺便练练手. 原文档下载地址(墙外): Configure Dataguard 11gR2 Physical Standby Part 1 Configure Dataguard 11gR2 P

Data Guard 主备库角色转换

1. switchover操作 1.1 备库先关闭实时日志应用 standby>alter database recover managed standby database cancel; 1.2 主库先判断是否可以支持switchover操作 primary> select switchover_status from v$database; 该值为:TO STANDBY:表示支持.该值为:SESSION ACTIVE:表示主库有激活会话.不妨碍switchover操作. 1.3 启动sw

Oracle11gr2_ADG管理之在备库上模拟failover的过程实战

技术建议和方案. 要求failover后不重建备库,并能够把failover的数据库重新切换回备库 主库为newtest,备库为snewtest 备库上已经开启了闪回 得到一个参考的SCN SQL> select current_scn from v$database; CURRENT_SCN ----------- 4491930 查看闪回数据库特性是打开的. SQL> select flashback_on from v$database; FLASHBACK_ON -----------

dataguard 归档丢失(主库中无此丢失归档处理),备库基于SCN恢复

dataguard 归档丢失(主库中无此丢失归档处理),备库基于SCN恢复 环境: OS: CentOS 6.5 DB: Oracle 10.2.0.5 1.主备库环境 主库: SQL> select dbid,name,LOG_MODE,open_mode,db_unique_name,DATABASE_ROLE,PROTECTION_MODE from v$database; DBID NAME LOG_MODE OPEN_MODE DB_UNIQUE_NAME DATABASE_ROLE