利用增量备份恢复因归档丢失造成的DG gap
data guard归档出现gap,悲剧的是丢失的归档在主库上被rman备份时删除了,丢失的归档大约有20几个,数据库大小约2T,如果重建DG将非常耗时间,因此决定利用增量备份的方式恢复DG,主要步骤如下:
0、查看备份库归档应用
SQL> select sequence#,applied from v$archived_log;
1.备份备库spfile文件
SQL> create pfile='/home/ora/pfileRdg.ora' from spfile;
2、查看当前备库scn
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
----------------------------------------
19652214434
3、查看缺失的archivelog
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 160163 160170
2 151303 151309
4、在主库执增量备份
[ora@jzhRAC1 ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 18:10:52 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JZH (DBID=2072634265)
RMAN> run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
backup as compressed backupset incremental from SCN 19652214434 database format '/home/ora/full_db_%d_%T_%s.bak' include current controlfile for standby filesperset=5 tag 'FOR STANDBY';
release channel d1;
release channel d2;
release channel d3;
}
5、将备份传至备库
scp full_db_JZH_20150523_*.bak 192.168.110.115:~/20150523_recover/
6、恢复备库
[ora@jzhDG ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 20:17:59 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JZH (DBID=2072634265, not open)
RMAN> catalog start with '/home/ora/20150523_recover';
[ora@jzhDG ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 20:25:44 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JZH (DBID=2072634265, not open)
RMAN> run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
restore standby controlfile to '/home/ora/control01.ctl';
recover database noredo;
release channel d1;
release channel d2;
release channel d3;
}
如果报下面的错误。(只截取了部分错误),我们可以重启数据库解决。
restore not done; all files readonly, offline, or already restored
Finished restore at 01-APR-12
Starting recover at 01-APR-12
released channel: dsk0
released channel: dsk1
released channel: dsk2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/01/2012 23:14:12
ORA-01219: database not open: queries allowed on fixed tables/views only
7、关闭备库,将恢复出来的control01.ctl覆盖备库控制文件
[ora@jzhDG ~]$ cp control01.ctl /oradata/JZH/standby.ctl
8、启动备库至mount状态
SQL> startup mount
ORACLE instance started.
Total System Global Area 1795162112 bytes
Fixed Size 2084648 bytes
Variable Size 301990104 bytes
Database Buffers 1476395008 bytes
Redo Buffers 14692352 bytes
Database mounted.
9、查看gap
SQL> select * from v$archive_gap;
no rows selected
10、开启备库recover模式
SQL> recover managed standby database disconnect from session;
Media recovery complete.
11、Alter database recover managed standby database cancel;
12、alter database open;
13、SQL> recover managed standby database disconnect from session;
查看备库的归档应用状态。
Select sequence#,applied from v$archived_log;
data guard归档出现gap,悲剧的是丢失的归档在主库上被rman备份时删除了,丢失的归档大约有20几个,数据库大小约2T,如果重建DG将非常耗时间,因此决定利用增量备份的方式恢复DG,主要步骤如下:
0、查看备份库归档应用
SQL> select sequence#,applied from v$archived_log;
1.备份备库spfile文件
SQL> create pfile='/home/ora/pfileRdg.ora' from spfile;
2、查看当前备库scn
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
----------------------------------------
19652214434
3、查看缺失的archivelog
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 160163 160170
2 151303 151309
4、在主库执增量备份
[ora@jzhRAC1 ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 18:10:52 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JZH (DBID=2072634265)
RMAN> run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
backup as compressed backupset incremental from SCN 19652214434 database format '/home/ora/full_db_%d_%T_%s.bak' include current controlfile for standby filesperset=5 tag 'FOR STANDBY';
release channel d1;
release channel d2;
release channel d3;
}
5、将备份传至备库
scp full_db_JZH_20150523_*.bak 192.168.110.115:~/20150523_recover/
6、恢复备库
[ora@jzhDG ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 20:17:59 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JZH (DBID=2072634265, not open)
RMAN> catalog start with '/home/ora/20150523_recover';
[ora@jzhDG ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 20:25:44 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JZH (DBID=2072634265, not open)
RMAN> run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
restore standby controlfile to '/home/ora/control01.ctl';
recover database noredo;
release channel d1;
release channel d2;
release channel d3;
}
如果报下面的错误。(只截取了部分错误),我们可以重启数据库解决。
restore not done; all files readonly, offline, or already restored
Finished restore at 01-APR-12
Starting recover at 01-APR-12
released channel: dsk0
released channel: dsk1
released channel: dsk2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/01/2012 23:14:12
ORA-01219: database not open: queries allowed on fixed tables/views only
7、关闭备库,将恢复出来的control01.ctl覆盖备库控制文件
[ora@jzhDG ~]$ cp control01.ctl /oradata/JZH/standby.ctl
8、启动备库至mount状态
SQL> startup mount
ORACLE instance started.
Total System Global Area 1795162112 bytes
Fixed Size 2084648 bytes
Variable Size 301990104 bytes
Database Buffers 1476395008 bytes
Redo Buffers 14692352 bytes
Database mounted.
9、查看gap
SQL> select * from v$archive_gap;
no rows selected
10、开启备库recover模式
SQL> recover managed standby database disconnect from session;
Media recovery complete.
11、Alter database recover managed standby database cancel;
12、alter database open;
13、SQL> recover managed standby database disconnect from session;
查看备库的归档应用状态。
Select sequence#,applied from v$archived_log;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30345407/viewspace-2139811/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30345407/viewspace-2139811/