一、出现gap sequence现象 sqlgt; alter database open;alter database open*第 1 行出现错误:今天的dataguard ,备库恢复open时
一、出现gap sequence现象
sql> alter database open;
alter database open
*
第 1 行出现错误:
今天的dataguard ,备库恢复open时报错:
ora-16004: 备份数据库需要恢复
ora-01152: 文件 1 没有从过旧的备份中恢复
ora-01110: 数据文件 1: 'c:\oracle\product\10.2.0\oradata\sheng\system01.dbf'
虽然archivelog是可以同步的:
sql> select max(sequence#) from v$archived_log;
max(sequence#)
--------------
15
在主库上看到的log:
tue jan 03 19:11:20 2012
fal[server]: fail to queue the whole fal gap
gap - thread 1 sequence 8-8
dbid 1778268600 branch 770765436
备库的alert 日志:
fal[client]: failed to request gap sequence
gap - thread 1 sequence 8-8
dbid 1778268600 branch 770765436
fal[client]: all defined fal servers have been attempted.
-------------------------------------------------------------
check that the control_file_record_keep_time initialization
parameter is defined to a value that is sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
二、修复操作
1、查询备库的scn
sql> select current_scn from v$database;
current_scn
-----------
614090
目的:1)确定主库在这个scn之后是否有添加数据文件,如果添加文件,需要手工在备库添加
2)确定主库增量备份起点
2、确定主库是否添加数据文件
sql> select file#,name from v$datafile where creation_change# > =614090;
未选定行
3、备库停止日志应用
sql> alter database recover managed standby database cancel;
4、主库增量备份并传输到备库上
主库进行增量备份
rman> backup incremental from scn 614090 database format 'c:\soft\sheng_u%' tag 'shp';
说明:主库之前必须要做过rman的全备(没有全备的库,基于scn的增量备份也能够成功)
5、备库上进行恢复
rman> catalog start with 'c:\soft';
rman> recover database noredo;
说明:catalog start with是10g及其以后版本中才存在功能,没有该功能可以采用catalog或者复制主库的控制文件,rman备份放置和主库备份时相同目录实现。
6、主库上创建standby controlfile文件并传输到备库
rman> backup current controlfile for standby format 'c:\soft\sheng_ctl.bck';
7、备库恢复控制文件
rman> shutdown;
rman> startup nomount;
rman> restore standby controlfile from 'c:\soft\sheng_ctl.bck';
rman> alter database mount;
8、清空备库日志组
sql> alter database clear logfile group 1;
注:如果采用了standby log模式,不需要清空,如果清空会出现
sql> alter database clear logfile group 1;
alter database clear logfile group 1
*
error at line 1:
ora-19527: physical standby redo log must be renamed
ora-00312: online log 1 thread 1: ‘c:\....\redo01.log’
说明:如果没有采用standby log模式,有几组需要清空几组
9、备库重设flashback
sql> alter database flashback off;
sql> alter database flashback on;
10、备库重新接收并应用日志
sql> alter database recover managed standby database disconnect from session;
----------------------
我试做上面的操作,发现由于redo位置不同,而引发错误:
发现备库的alert:
rfs[1]: unable to open standby log 6: 313
tue jan 03 20:23:16 2012
errors in file c:\oracle\product\10.2.0\admin\sheng\udump\sheng_rfs_2000.trc:
ora-00313: open failed for members of log group 7 of thread 1
ora-00312: online log 7 thread 1: 'd:\oracle\product\10.2.0\oradata\sheng\redo07.log'
ora-27041: unable to open file
osd-04002: 无法打开文件
o/s-error: (os 21) 设备未就绪。
检查一下log 位置,,发现有问题:
sql> select * from v$logfile;
行将被截断
group# status type member
---------- ------- ------- -----------------------------------------------------
3 online d:\oracle\product\10.2.0\oradata\sheng\redo03.log
2 online d:\oracle\product\10.2.0\oradata\sheng\redo02.log
1 online d:\oracle\product\10.2.0\oradata\sheng\redo01.log
sql> select * from v$log;
在列 first_change# 前截断 (按要求)
group# thread# sequence# bytes members arc status firs
---------- ---------- ---------- ---------- ---------- --- ---------------- ----
1 1 17 52428800 1 yes clearing 03-1
3 1 16 52428800 1 yes inactive 03-1
2 1 18 52428800 1 yes clearing_current 03-1
下面进行修复:
其实在备库的 pfile 中加入:
log_file_name_convert = d:\oracle\product\10.2.0\oradata\sheng\, c:\oracle\product\10.2.0\oradata\sheng\
shutdown immediate
create spfile from pfile;
startup nomount;
alter database mount;
经过上面在备库的操作后,
select * from v$logfile;
group# status type member
---------- ------- ------- -----------------------------------------------------
3 online c:\oracle\product\10.2.0\oradata\sheng\redo03.log
2 online c:\oracle\product\10.2.0\oradata\sheng\redo02.log
1 online c:\oracle\product\10.2.0\oradata\sheng\redo01.log
4 standby c:\oracle\product\10.2.0\oradata\sheng\redo04.log
5 standby c:\oracle\product\10.2.0\oradata\sheng\redo05.log
6 standby c:\oracle\product\10.2.0\oradata\sheng\redo06.log
7 standby c:\oracle\product\10.2.0\oradata\sheng\redo07.log
已选择7行。
发现已经正确。
下面是细节:
主库:
sql> alter system switch logfile;
系统已更改。
sql> select current_scn from v$database;
current_scn
-----------
654580
alert:
tue jan 03 21:22:56 2012
thread 1 advanced to log sequence 19
current log# 3 seq# 19 mem# 0: d:\oracle\product\10.2.0\oradata\sheng\redo03.log
tue jan 03 21:22:57 2012
arc1: standby redo logfile selected for thread 1 sequence 18 for destination log_archive_dest_2
看一下备库的信息:
sql> select current_scn from v$database;
current_scn
-----------
654555
rfs[1]: successfully opened standby log 4: 'c:\oracle\product\10.2.0\oradata\sheng\redo04.log'
tue jan 03 21:22:54 2012
media recovery log c:\oracle\product\10.2.0\oradata\arch\00100018770765436.arc
media recovery waiting for thread 1 sequence 19
-----
到这里为止:
如果 open 出现数据库忙的情况,用一下命令停掉:
alter database recover managed standby database cancel
alter database open read only, 就可以打开数据库了。