暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ReCreate a dg when primary is crashed.

原创 Great.Li 2021-12-17
360

ReCreate a dg when primary is crashed.


At primary(where db is crashed):

drop database

prerequisite:

1, mount database in exclusive mode (cluster_database=false)

2, enable restricted session.


After drop database in RAC, ONLY archived log and DB cluster service resource is left.

Controlfiles, datafiles, and even spfile in ASMDG is removed.


At standby :

alter database activate standby database ;

alter database open ;



At old primary:

rman target sys/oracle@men_dg auxiliary sys/oracle@men

duplicate target database for standby from active database;

.......


Here I find that some file Location is not as expected, So I remove the files , and the trouble is from here.

1, alter database datafile 13 offline drop ; #if you do not do this first, the file is locked and could't be removed.

2, ASMCMD> rm <datafile 13>


Why I get the unexpected file Location ?

The answer is that I used the parameter "db_file_name_convert" , and match file path name multi-times and only the first match is in effect. So the Right order of file path covert is Let the Most-detailed pathname first. Like this:

alter system set db_file_name_convert= '/oracle/oradata/men/MEN_DG/datafile', '+datadg/men/datafile', '/oracle/oradata','+datadg' scope=spfile;


The following statement can be used to create the missing data file . But when I recover it , I get the trouble again.

alter database create datafile 'OLD_NMAE' as 'NEW_NAME' ;

alter database create datafile 16,17,18 as '+datadg','+datadg', '+datadg' ;


I find that the argument of VALID_FOR is taken current database role as consider, not the remote db.

ALTER SYSTEM SET log_archive_dest_3 = "SERVICE=men lgwr async VALID_FOR=(ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME=men" ;


The correct steps to recove missing datafile on standby database:


1, connect to both primary and standby db by using rman.

rman target sys/oracle@men_dg auxiliary sys/oracle@men


2, backup datafile (which missing on standby) as copy to standby host.

backup as copy datafile 13 auxiliary format '+datadg' ;

backup as copy datafile 14 auxiliary format '+datadg' ;

backup as copy datafile 16 auxiliary format '+datadg' ;

backup as copy datafile 17 auxiliary format '+datadg' ;

backup as copy datafile 18 auxiliary format '+datadg' ;


3, register datafile copy on standby host:

catalog clone datafilecopy

'+DATADG/men/datafile/users.324.1091503783',

'+DATADG/men/datafile/ts_test1.327.1091503787',

'+DATADG/men/datafile/undo1.328.1091503823',

'+DATADG/men/datafile/undo2.330.1091503831',

'+DATADG/men/datafile/users.323.1091503087' ;



4, Because some error in command "switch clone", use rman connect to standby standalone

At Standby host:

rman target /

switch datafile 13,14,16,17,18 to copy;


5, online datafiles .Knowing that only in mount mode could you online datafiles.

shutdown abort

startup mount

alter database datafile 13,14,16,17,18 online ;

SELECT status, FILE#, 'rm '||NAME name, checkpoint_change# FROM V$DATAFILE_header ; #status is online

SELECT status, FILE#, 'rm '||NAME name, checkpoint_change# FROM V$DATAFILE ; #status is recover

at this time, the status info of datafile head and controlfile is not synchronous until db is open.


alter database open ;

recover managed standby database using current logfile disconnect ;


#Discovery knowledge point:

In view v$dataguard_stats , "apply lag" is not null when using real time recover. OR it is null when archived log is used to recover.

apply lag +00 00:00:00


Now successfully recover all missing datafiles ! have fun !



「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论