Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7094270
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: Oracle

2014-04-01 10:38:51

DataGuard主备之间可能由于网络等原因,造成备库和主库之间的归档日志不一致,这样就产生了gap。
解决gap的步骤:
1.在备库获得gap的详细信息
2.将需要的归档日志从主库拷贝到备库
3.备库将归档日志注册,然后应用。
 
--备库alert日志提示gap详情  
Media Recovery Waiting for thread 1 sequence 7057
Fetching gap sequence in thread 1, gap sequence 7057-7080
FAL[client]: Error fetching gap sequence, no FAL server specified
Mon Mar 24 11:39:40 CST 2014
FAL[client]: Failed to request gap sequence 
 GAP - thread 1 sequence 7057-7080
 DBID 768411208 branch 784810891
FAL[client]: All defined FAL servers have been attempted.

--也可以在备库查询gap
select * from v$archive_gap;

--为了方便,组装拷贝语句
--如果归档日志在ASM中,先通过rman将归档日志拷贝到OS,然后scp到备库standby归档目录;
--如果归档日志在OS上,直接scp到备库standby归档目录即可。
@Pirmary
select length('+DG1/primary/archivelog/2014_03_21/') from dual;
LENGTH('+DG1/PRIMARY/ARCHIVELOG/2014_03_21/')
---------------------------------------------
                                           35
  
--get copy command
select 'copy archivelog '''||NAME||''' to ''/tmp/'||substr(name,35)||''' ;' 
from v$archived_log 
where  SEQUENCE#>7060 
and SEQUENCE#<=7080 
and thread#=1 
and NAME<>'standby service name';

--copy archive logs from asm to OS
rman target /
copy archivelog '+DG1/primary/archivelog/2014_03_21/thread_1_seq_7061.393.842805877' to '/tmp/thread_1_seq_7061.393.842805877' ;
copy archivelog '+DG1/primary/archivelog/2014_03_21/thread_1_seq_7062.472.842816319' to '/tmp/thread_1_seq_7062.472.842816319' ;
copy archivelog '+DG1/primary/archivelog/2014_03_21/thread_1_seq_7063.414.842825435' to '/tmp/thread_1_seq_7063.414.842825435' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7064.308.842843087' to '/tmp/thread_1_seq_7064.308.842843087' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7065.278.842847011' to '/tmp/thread_1_seq_7065.278.842847011' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7066.415.842847023' to '/tmp/thread_1_seq_7066.415.842847023' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7067.469.842850077' to '/tmp/thread_1_seq_7067.469.842850077' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7068.402.842864915' to '/tmp/thread_1_seq_7068.402.842864915' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7069.475.842868603' to '/tmp/thread_1_seq_7069.475.842868603' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7070.413.842869761' to '/tmp/thread_1_seq_7070.413.842869761' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7071.312.842871319' to '/tmp/thread_1_seq_7071.312.842871319' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7072.407.842874331' to '/tmp/thread_1_seq_7072.407.842874331' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7073.405.842874917' to '/tmp/thread_1_seq_7073.405.842874917' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7074.328.842875663' to '/tmp/thread_1_seq_7074.328.842875663' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7075.296.842876043' to '/tmp/thread_1_seq_7075.296.842876043' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7076.452.842886921' to '/tmp/thread_1_seq_7076.452.842886921' ;
copy archivelog '+DG1/primary/archivelog/2014_03_22/thread_1_seq_7077.446.842906131' to '/tmp/thread_1_seq_7077.446.842906131' ;
copy archivelog '+DG1/primary/archivelog/2014_03_23/thread_1_seq_7078.348.842928271' to '/tmp/thread_1_seq_7078.348.842928271' ;
copy archivelog '+DG1/primary/archivelog/2014_03_23/thread_1_seq_7079.347.842928277' to '/tmp/thread_1_seq_7079.347.842928277' ;
copy archivelog '+DG1/primary/archivelog/2014_03_23/thread_1_seq_7080.367.842929387' to '/tmp/thread_1_seq_7080.367.842929387' ;


--send archive logs to standby
scp thread_1_seq_70* 10.1.1.10:/tmp

--get  standby register archivelog command
--同样在主库执行,获得注册语句
select 'ALTER DATABASE REGISTER PHYSICAL LOGFILE ''/tmp/'||substr(name,35)||''';' from v$archived_log where  SEQUENCE#>7060 and SEQUENCE#<=7080 and thread#=1 and NAME<>'standby service name';

ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7061.393.842805877';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7062.472.842816319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7063.414.842825435';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7064.308.842843087';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7065.278.842847011';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7066.415.842847023';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7067.469.842850077';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7068.402.842864915';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7069.475.842868603';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7070.413.842869761';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7071.312.842871319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7072.407.842874331';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7073.405.842874917';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7074.328.842875663';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7075.296.842876043';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7076.452.842886921';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7077.446.842906131';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7078.348.842928271';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7079.347.842928277';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7080.367.842929387';



@Standby
--register gap archivelog to standby
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7061.393.842805877';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7062.472.842816319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7063.414.842825435';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7064.308.842843087';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7065.278.842847011';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7066.415.842847023';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7067.469.842850077';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7068.402.842864915';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7069.475.842868603';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7070.413.842869761';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7071.312.842871319';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7072.407.842874331';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7073.405.842874917';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7074.328.842875663';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7075.296.842876043';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7076.452.842886921';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7077.446.842906131';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7078.348.842928271';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7079.347.842928277';
ALTER DATABASE REGISTER PHYSICAL LOGFILE '/tmp/thread_1_seq_7080.367.842929387';

--if standby is real apply,then standby will AUTO Apply archivelog
--if not,please open real apply 
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

--get real apply info
set linesize 200
col name for a70
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select  NAME,THREAD#,FIRST_TIME,sequence#,applied from v$archived_log order by  FIRST_TIME,THREAD#,sequence#,DEST_ID;

--you can see alert log ,it also show archivelog apply info
tail -f alert.log

--make sure no gap between Primary and Standby
SQL> select * from v$archive_gap;

--Clean
@Priamry
cd /tmp
rm thread_*

RMAN> crosscheck archivelog all;
RMAN> list archivelog all;
RMAN> delete expired archivelog all;
 


阅读(590) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~