오라클/참고

오라클 19c rman incarnation 설명 및 복구 시나리오

Manly 2023. 1. 10. 13:15
반응형

OS환경 : Oracle Linux 8.1 (64bit)

 

DB 환경 : Oracle Database 19.9.0.0

 

방법 : 오라클 19c rman incarnation 설명 및 복구 시나리오

 

incarnation 이란?

데이터베이스를 resetlogs 옵션으로 open 할때 마다 incarnation이 생성됨(reset)

일반 recover 완료 후에는 resetlogs 없이도 정상 open 할 수도 있음

하지만 Point In Time Recovery (PITR) 또는 using backup controlfile로 복구한 후에는 resetlogs 옵션으로 데이터베이스를 open 해야 하므로 데이터베이스의 새로운 incarnation이 생성됨

데이터베이스는 서로 다른 두 redo stream의 SCN이 동일하지만 서로 다른 시간에 발생한 경우 혼란을 피하기 위해 새로운 incarnation이 필요함

데이터베이스에 잘못된 redo를 적용하면 데이터베이스가 손상됨

 

단일 데이터베이스에 여러 개의 incarnation이 존재함에 따라 rman이 현재 incarnation 경로에 없는 백업을 처리하는 방식이 결정됨

일반적으로 current incarnation의 데이터베이스를 사용하는 것이 좋음

그럼에도 불구하고 일부 경우에는 데이터베이스를 이전 incarnation로 재설정하는 것이 가장 좋은 방법일수도 있음

예를 들어 사용자가 수행한 Point In Time Recovery (PITR) 결과가 불만족스러울 수 있으며 데이터베이스를 resetlogs 이전 시간으로 되돌리고자 할 수 있음 데이터베이스 incarnation에 대한 이해는 이러한 상황에 대비하는 데 도움이 됨

 

 

incarnation Status 설명

current incarnation(현재 incarnation) : 데이터베이스에 현재 작동(open) 중인 incarnation

parent incarnation(부모 incarnation) : resetlogs 로 open 된 후 직전의 incarnation(현재 incarnation 의 부모 incarnation)

ancestor incarnation(조상 incarnation) : parent incarnation의 parent incarnation(부모 incarnation 의 부모 incarnation), 

모든 ancestor incarnation(조상)의 부모는 현재 incarnation의 ancestor(조상)이기도함

direct ancestral path(direct 조상 경로) : 현재 incarnation의 direct ancestral path는 초기 incarnation에서 시작하여 현재 incarnation의 ancestor(조상), parent incarnation(부모 incarnation) 또는 현재 incarnation으로의 분기만을 포함함

incarnation 번호는 redo stream을 고유하게 태그하고 식별하는 데 사용됨
rman은 이 incarnation history 정보를 catalog에 저장함

 

 

Database Incarnation History 설명

각기 다른 incarnation 번호를 가진 여러 incarnation 을 거치는 데이터베이스

1. 데이터베이스의 incarnation 1은 SCN 1에서 시작하여 SCN 1000에서 SCN 2000까지 계속됨

2_1. incarnation 1의 SCN 2000에서 SCN 1000으로 다시 Point In Time Recovery (PITR)를 수행 한 다음 resetlogs 옵션을 사용하여 데이터베이스를 open 하는 것으로 가정함

2_2. 이제 incarnation 2가 SCN 1000에서 시작하여 SCN 3000까지 계속됨, 이 예시에서 incarnation 1은 incarnation 2의 parent(부모) 임

3_1. incarnation 2의 SCN 3000에서 SCN 2000으로 Point In Time Recovery (PITR)를 수행하고 resetlogs 옵션을 사용하여 데이터베이스를 open 것으로 가정함 

3_2. 이 경우, incarnation 2는 incarnation 3의 parent(부모)이고, incarnation 1은 incarnation 3의 ancestor(조상)임

4_1. 데이터베이스에서 Point In Time Recovery (PITR) 또는 Flashback Database가 발생한 경우 SCN은 현재 incarnation에 따라 여러 시점을 참조할 수 있음

4_2. 예를 들어 위 그림의 SCN 1500 은 incarnation 1 또는 incarnation 2의 SCN을 참조 할 수 있음

 

 

incarnation 복구 시나리오1

이전 게시글에서 catalog db를 이용해 resetlogs 로 복구를 하였기 때문에 현재 incarnation이 2개임

 

 

rman catalog 접속 후 incarnation 확인(Inc Key 컬럼이 incarnation)

1
2
3
4
5
6
7
8
9
10
11
12
13
$ export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
$ rman target / catalog catuser/catuser@catdb
RMAN> list incarnation;
 
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       PARENT  988348     2021-01-26 16:06:44
1       207     ORACLE19 3209222764       CURRENT 1038289    2021-01-29 13:45:25

조회결과 incarnation 2와 incarnation 207이 존재함

CURRENT(현재 incarnation)은 incarnation 207임

 

 

체크포인트 및 로그스위치, 시간확인(추후 시나리오용 작업)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
SQL> alter system checkpoint;
 
System altered.
 
SQL> alter system switch logfile;
 
System altered.
 
SQL> /
 
System altered.
 
SQL> /
 
System altered.
 
SQL> select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') as "date" from dual;
 
date
-------------------
2021-01-29 13:48:29

 

 

sqlplus 접속 후 샘플 테이블 생성(incarnation 207)

1
2
3
4
5
6
7
8
9
SQL> create table newimsi2 as select * from dba_segments;
 
Table created.
 
SQL> select count(*from newimsi2;
 
  COUNT(*)
----------
      4620

 

 

체크포인트 및 로그스위치, 시간확인(추후 시나리오용 작업)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
SQL> alter system checkpoint;
 
System altered.
 
SQL> alter system switch logfile;
 
System altered.
 
SQL> /
 
System altered.
 
SQL> /
 
System altered.
 
SQL> select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') as "date" from dual;
 
date
-------------------
2021-01-29 13:50:23

 

 

테이블 생성 시간 확인

1
2
3
4
5
6
7
8
9
SQL> 
select object_name, to_char(created, 'YYYY-MM-DD HH24:MI:SS') created 
from dba_objects 
where object_name like 'NEWIMSI%';
 
OBJECT_NAME   CREATED
------------ ----------------
NEWIMSI      2021-01-29 13:34:43
NEWIMSI2     2021-01-29 13:50:04

 

 

이전 incarnation(incarnation 2) 으로 돌아가기

1
2
3
4
5
$ rman target / catalog catuser/catuser@catdb
RMAN> reset database to incarnation 2;
 
database reset to incarnation 2
ORA-19910: can not change recovery target incarnation in control file

에러가 발생하는 이유는 현재 db가 open 상태이기 때문

 

 

shutdown 후 mount 상태로 변경

1
2
3
4
5
6
7
8
9
10
11
12
13
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
 
Total System Global Area 1073737800 bytes
Fixed Size            8904776 bytes
Variable Size          654311424 bytes
Database Buffers      406847488 bytes
Redo Buffers            3674112 bytes
Database mounted.

 

 

이전 incarnation(incarnation 2) 으로 돌아가기

1
2
3
4
$ rman target / catalog catuser/catuser@catdb
RMAN> reset database to incarnation 2;
 
database reset to incarnation 2

 

 

위 명령 실행 시 alert log

1
2
3
$ tail -/ORA19/app/oracle/diag/rdbms/oracle19/oracle19/trace/alert*log
2021-01-29T13:52:02.917526+09:00
Setting recovery target incarnation to 1

 

 

incarnation 확인

1
2
3
4
5
6
7
8
9
$ rman target / catalog catuser/catuser@catdb
RMAN> list incarnation;
 
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       CURRENT 988348     2021-01-26 16:06:44
1       207     ORACLE19 3209222764       ORPHAN  1038289    2021-01-29 13:45:25

incarnation 2 가 CURRENT가 되고 incarnation 207은 ORPHAN(고아) 상태가 됨 

 

 

newimsi2 테이블 생성 이전으로 시간 설정 후 이동

newimsi2 테이블 생성시간 : 2021-01-29 13:50:04

1
2
3
4
5
6
7
8
9
10
11
12
$ rman target / catalog catuser/catuser@catdb
RMAN> 
run {
set until time "to_date('2021-01-29 13:49:50','YYYY-MM-DD HH24:MI:SS')";
shutdown abort;
startup nomount;
restore controlfile;
alter database mount;
restore database;
recover database;
alter database open resetlogs;
}

복구가 완료됨

 

로그

 

 

incarnation 확인

1
2
3
4
5
6
7
8
9
$ rman target / catalog catuser/catuser@catdb
RMAN> list incarnation;
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       PARENT  988348     2021-01-26 16:06:44
1       207     ORACLE19 3209222764       ORPHAN  1038289    2021-01-29 13:45:25
1       285     ORACLE19 3209222764       CURRENT 1038289    2021-01-29 13:54:20

run 스크립트에서 resetlogs 로 open 했기 때문에 새로운 incarnation 번호를 부여받음(285)

incarnation 2는 PARENET, incarnation 207이 ORPHAN, incarnation 285 가 CURRENT가 됨

 

 

테이블 확인

1
2
3
4
5
6
7
8
9
10
11
12
SQL> select count(*from newimsi2;
select count(*from newimsi2
                     *
ERROR at line 1:
ORA-00942table or view does not exist
 
 
SQL> select count(*from newimsi; 
 
  COUNT(*)
----------
     22960

newimsi2 는 incarnation 207에서 만든 테이블이기때문에 존재하지 않음

newimsi 는 incarnation 2에서 만들었기 때문에 존재함

 

 

체크포인트 및 로그스위치, 시간확인(추후 시나리오용 작업)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
SQL> alter system checkpoint;
 
System altered.
 
SQL> alter system switch logfile;
 
System altered.
 
SQL> /
 
System altered.
 
SQL> /
 
System altered.
 
SQL> select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') as "date" from dual;
 
date
-------------------
2021-01-29 13:57:12

 

 

incarnation 복구 시나리오2

shutdown 후 더 이전 시점(newimsi 테이블 생성 이전)으로 이동 가능한지 테스트

 

 

shutdown 후 mount 상태로 변경

1
2
3
4
5
6
7
8
9
10
11
12
13
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
 
Total System Global Area 1073737800 bytes
Fixed Size            8904776 bytes
Variable Size          654311424 bytes
Database Buffers      406847488 bytes
Redo Buffers            3674112 bytes
Database mounted.

 

 

이전 incarnation(incarnation 2) 으로 돌아가기

1
2
3
4
$ rman target / catalog catuser/catuser@catdb
RMAN> reset database to incarnation 2;
 
database reset to incarnation 2

 

 

incarnation 확인

1
2
3
4
5
6
7
8
9
$ rman target / catalog catuser/catuser@catdb
RMAN> list incarnation;
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       CURRENT 988348     2021-01-26 16:06:44
1       207     ORACLE19 3209222764       ORPHAN  1038289    2021-01-29 13:45:25
1       285     ORACLE19 3209222764       ORPHAN  1038289    2021-01-29 13:54:20

incarnation 2 가 CURRENT가 됨

나머지는 ORPHAN 상태가됨

 

 

newimsi 테이블 생성 이전으로 시간 설정 후 이동

newimsi 테이블 생성시간 : 2021-01-29 13:34:43

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$ rman target / catalog catuser/catuser@catdb
RMAN> run {
set until time "to_date('2021-01-29 13:33:00','YYYY-MM-DD HH24:MI:SS')";
shutdown abort;
startup nomount;
restore controlfile;
alter database mount;
restore database;
recover database;
alter database open resetlogs;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 
 
executing command: SET until clause
 
Oracle instance shut down
 
connected to target database (not started)
Oracle instance started
 
Total System Global Area    1073737800 bytes
 
Fixed Size                     8904776 bytes
Variable Size                666894336 bytes
Database Buffers             394264576 bytes
Redo Buffers                   3674112 bytes
 
Starting restore at 2021-01-29 14:01:53
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=423 device type=DISK
 
RMAN-00571===========================================================
RMAN-00569=============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571===========================================================
RMAN-03002: failure of restore command at 01/29/2021 14:01:53
RMAN-06026: some targets not found - aborting restore
RMAN-06024: no backup or copy of the control file found to restore

복구가 되지 않음

newimsi 테이블 생성 이후 첫 rman 백업을 진행했기 때문에

그 이전으로는 돌아갈수 없음

 

 

incarnation 복구 시나리오3

다시 newimsi2 생성 이후로 이동(incarnation 207)

1
2
3
4
5
6
7
8
9
10
11
12
13
$ rman target / catalog catuser/catuser@catdb
RMAN> reset database to incarnation 207;
 
database reset to incarnation 207
 
RMAN> list incarnation;
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       PARENT  988348     2021-01-26 16:06:44
1       207     ORACLE19 3209222764       CURRENT 1038289    2021-01-29 13:45:25
1       285     ORACLE19 3209222764       ORPHAN  1038289    2021-01-29 13:54:20

 

 

newimsi2 테이블 생성 이후로 시간 설정 후 이동

newimsi2 테이블 생성시간 : 2021-01-29 13:50:04

$ rman target / catalog catuser/catuser@catdb
RMAN> run {
set until time "to_date('2021-01-29 13:50:30','YYYY-MM-DD HH24:MI:SS')";
shutdown abort;
startup nomount;
restore controlfile;
alter database mount;
restore database;
recover database;
alter database open resetlogs;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 
 
executing command: SET until clause
 
Oracle instance shut down
 
connected to target database (not started)
Oracle instance started
 
Total System Global Area    1073737800 bytes
 
Fixed Size                     8904776 bytes
Variable Size                666894336 bytes
Database Buffers             394264576 bytes
Redo Buffers                   3674112 bytes
 
Starting restore at 2021-01-29 14:06:22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=423 device type=DISK
 
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /ORA19/app/oracle/rman/db_ctl_c-3209222764-20210129-04
channel ORA_DISK_1: piece handle=/ORA19/app/oracle/rman/db_ctl_c-3209222764-20210129-04 tag=TAG20210129T134530
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/ORA19/app/oracle/oradata/ORACLE19/control01.ctl
output file name=/ORA19/app/oracle/oradata/ORACLE19/control02.ctl
Finished restore at 2021-01-29 14:06:24
 
released channel: ORA_DISK_1
Statement processed
 
Starting restore at 2021-01-29 14:06:28
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=423 device type=DISK
 
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /ORA19/app/oracle/oradata/ORACLE19/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /ORA19/app/oracle/oradata/ORACLE19/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /ORA19/app/oracle/oradata/ORACLE19/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /ORA19/app/oracle/oradata/ORACLE19/users01.dbf
channel ORA_DISK_1: reading from backup piece /ORA19/app/oracle/rman/ORACLE19_06vlrm0e_1_1_20210129.bk
channel ORA_DISK_1: piece handle=/ORA19/app/oracle/rman/ORACLE19_06vlrm0e_1_1_20210129.bk tag=TAG20210129T133926
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2021-01-29 14:06:36
 
Starting recover at 2021-01-29 14:06:36
using channel ORA_DISK_1
 
starting media recovery
 
archived log for thread 1 with sequence 15 is already on disk as file /ORA19/app/oracle/arch/1_15_1062864404.arc
archived log for thread 1 with sequence 1 is already on disk as file /ORA19/app/oracle/arch/1_1_1063115125.arc
archived log for thread 1 with sequence 2 is already on disk as file /ORA19/app/oracle/arch/1_2_1063115125.arc
archived log for thread 1 with sequence 3 is already on disk as file /ORA19/app/oracle/arch/1_3_1063115125.arc
archived log for thread 1 with sequence 4 is already on disk as file /ORA19/app/oracle/arch/1_4_1063115125.arc
archived log for thread 1 with sequence 5 is already on disk as file /ORA19/app/oracle/arch/1_5_1063115125.arc
archived log for thread 1 with sequence 6 is already on disk as file /ORA19/app/oracle/arch/1_6_1063115125.arc
archived log file name=/ORA19/app/oracle/arch/1_15_1062864404.arc thread=1 sequence=15
archived log file name=/ORA19/app/oracle/arch/1_1_1063115125.arc thread=1 sequence=1
archived log file name=/ORA19/app/oracle/arch/1_2_1063115125.arc thread=1 sequence=2
archived log file name=/ORA19/app/oracle/arch/1_3_1063115125.arc thread=1 sequence=3
archived log file name=/ORA19/app/oracle/arch/1_4_1063115125.arc thread=1 sequence=4
archived log file name=/ORA19/app/oracle/arch/1_5_1063115125.arc thread=1 sequence=5
archived log file name=/ORA19/app/oracle/arch/1_6_1063115125.arc thread=1 sequence=6
unable to find archived log
archived log thread=1 sequence=7
RMAN-00571===========================================================
RMAN-00569=============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571===========================================================
RMAN-03002: failure of recover command at 01/29/2021 14:06:37
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 7 and starting SCN of 1039410

restore database 명령까지는 제대로 실행되지만

recover database 명령 도중 에러가 발생함

sequence=7에 대한 아카이브 로그파일을 찾고있음

 

 

sqlplus 에서 recover 재실행

1
2
3
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

using backup controlfile 구문을 사용해야함

 

 

recover 재실행

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SQL> recover database using backup controlfile; 
ORA-00279change 1039410 generated at 01/29/2021 13:50:20 needed for thread 1
ORA-00289: suggestion : /ORA19/app/oracle/arch/1_7_1063115125.arc
ORA-00280change 1039410 for thread 1 is in sequence #7
 
 
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto  <-- [auto 입력]
ORA-00308: cannot open archived log '/ORA19/app/oracle/arch/1_7_1063115125.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
 
 
ORA-00308: cannot open archived log '/ORA19/app/oracle/arch/1_7_1063115125.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7

sequence #7에 대한 아카이브로그파일을 찾고있음

 

 

redo 확인

1
2
3
4
5
6
7
8
9
10
11
12
13
SQL> 
set lines 200 pages 1000
col member for a70
select l.group#, member, archived, sequence#
from v$log l, v$logfile f
where f.group# = l.group#
order by 1;
 
    GROUP# MEMBER                                  ARC  SEQUENCE#
---------- ---------------------------------------------------------------------- --- ----------
     1 /ORA19/app/oracle/oradata/ORACLE19/redo01.log              NO           1
     2 /ORA19/app/oracle/oradata/ORACLE19/redo02.log              YES           0
     3 /ORA19/app/oracle/oradata/ORACLE19/redo03.log              YES           0

redo 에는 해당 sequence가 없음

 

 

이전 테스트결과(이 내용은 무시해도됨)

이전 테스트결과

 

 

until cancel 로 recover

1
2
3
4
5
6
7
8
9
SQL> recover database using backup controlfile until cancel;
ORA-00279change 1039410 generated at 01/29/2021 13:50:20 needed for thread 1
ORA-00289: suggestion : /ORA19/app/oracle/arch/1_7_1063115125.arc
ORA-00280change 1039410 for thread 1 is in sequence #7
 
 
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel  <-- [cancel 입력]
Media recovery cancelled.

 

 

db resetlogs 로 open

1
2
3
SQL> alter database open resetlogs;
 
Database altered.

 

 

데이터 확인

1
2
3
4
5
6
7
8
9
10
11
SQL> select count(*from newimsi; 
 
  COUNT(*)
----------
     22960
 
SQL> select count(*from newimsi2;
 
  COUNT(*)
----------
      4620

일부 아카이브로그는 적용하지 못했지만 정상적으로 newimsi2 데이터가 복구됨

 

 

현재 incarnation 확인

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ rman target / catalog catuser/catuser@catdb
RMAN> list incarnation;
 
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       PARENT  988348     2021-01-26 16:06:44
1       207     ORACLE19 3209222764       PARENT  1038289    2021-01-29 13:45:25
1       285     ORACLE19 3209222764       ORPHAN  1038289    2021-01-29 13:54:20
1       368     ORACLE19 3209222764       CURRENT 1039411    2021-01-29 14:12:44

resetlogs로 open 했기 때문에 새로운 incarnation 368로 시작됨

원하는 시점으로 복구하지 못했지만 incarnation 207 으로 갔기때문에 incarnation 207이 PARENT로 표시됨

그리고 incarnation 285는 ORPHAN 이 됨

 

 

v$database_incarnation 뷰 확인

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
SQL>
set lines 200 pages 1000           
col path for a40
alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS';
select 
INCARNATION#, 
PRIOR_INCARNATION#, 
RESETLOGS_CHANGE#, 
RESETLOGS_TIME, 
STATUS, 
SYS_CONNECT_BY_PATH(INCARNATION#, ' -> ') Path 
FROM v$database_incarnation 
WHERE LEVEL >=1 START WITH INCARNATION# = '1' 
CONNECT BY PRIOR INCARNATION# = PRIOR_INCARNATION# 
ORDER BY LEVEL, Path, RESETLOGS_TIME;
 
INCARNATION# PRIOR_INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME      STATUS  PATH
------------ ------------------ ----------------- ------------------- ------- ----------------------------------------
       1              0        988348 2021-01-26 16:06:44 PARENT   -> 1
       2              1       1038289 2021-01-29 13:45:25 PARENT   -> 1 -> 2
       3              2       1039411 2021-01-29 14:12:44 CURRENT  -> 1 -> 2 -> 3

rman 의 list incarnation 에나오는 ORPHAN 정보는 안나오지만

rman 의 list incarnation의 Reset SCN 과 v$database_incarnation 뷰의 resetlogs_change# 를 같이 비교해서 보면됨

PATH 컬럼에는 incarnation 간의 부모자식 관계가 화살표(->)로 표시됨

 

 

작업간 생성된 아카이브 로그 확인

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ cd /ORA19/app/oracle/arch/
$ ls -ltr
total 23404
-rw-r----- 1 oracle oinstall   75264 Jan 29 13:33 1_9_1062864404.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:33 1_10_1062864404.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:33 1_11_1062864404.arc
-rw-r----- 1 oracle oinstall 3320832 Jan 29 13:34 1_12_1062864404.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:45 1_13_1062864404.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:45 1_14_1062864404.arc
-rw-r----- 1 oracle oinstall   21504 Jan 29 13:45 1_15_1062864404.arc
-rw-r----- 1 oracle oinstall 9802240 Jan 29 13:48 1_1_1063115125.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:48 1_2_1063115125.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:48 1_3_1063115125.arc
-rw-r----- 1 oracle oinstall  849920 Jan 29 13:50 1_4_1063115125.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:50 1_5_1063115125.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:50 1_6_1063115125.arc
-rw-r----- 1 oracle oinstall 9840640 Jan 29 13:57 1_1_1063115660.arc
-rw-r----- 1 oracle oinstall    1024 Jan 29 13:57 1_2_1063115660.arc
-rw-r----- 1 oracle oinstall    1536 Jan 29 13:57 1_3_1063115660.arc

현재 아카이브 로그 포맷은 %t_%s_%r.arc임 %r 부분이 resetlogs ID 임

 

 

incarnation 삭제

카탈로그db 삭제(연결해제)(원본 db)

1
2
3
4
5
6
7
8
9
$ rman target / catalog catuser/catuser@catdb
RMAN> drop catalog;  <-- [drop catalog 입력]
 
recovery catalog owner is CATUSER
enter DROP CATALOG command again to confirm catalog removal
 
RMAN> drop catalog;  <-- [drop catalog 재입력]
 
recovery catalog dropped

처음 1번 입력 후 한번더 입력해야 정상적으로 drop 됨

 

 

catuser 테이블 확인 및 recyclebin 삭제(카탈로그 db)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SQL> conn catuser/catuser
Connected.
SQL> select * from tab;
 
TNAME                                                                 TABTYPE    CLUSTERID
------------------------------------------------------------------------------------------
BIN$uchSWhvUChDgUzOJqMAjBw==$0                                                     TABLE
BIN$uchmORDrCj7gUzOJqMBLsw==$0                                                     TABLE
 
SQL> purge recyclebin;
 
Recyclebin purged.
 
SQL> select * from tab;
 
no rows selected

recyclebin의 테이블까지 정상적으로 모두 삭제됨

 

 

컨트롤파일 백업

1
2
3
4
5
6
7
SQL> alter database backup controlfile to trace as '/home/oracle/rrecon.sql';
 
Database altered.
 
SQL> alter database backup controlfile to '/home/oracle/contro01.ctl';
 
Database altered.

 

 

rrecon.sql 수정(REUSE NORESETLOGS  ARCHIVELOG 구문만 남기기)

$ cat rrecon.sql
CREATE CONTROLFILE REUSE DATABASE "ORACLE19" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/ORA19/app/oracle/oradata/ORACLE19/redo01.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 2 '/ORA19/app/oracle/oradata/ORACLE19/redo02.log'  SIZE 200M BLOCKSIZE 512,
  GROUP 3 '/ORA19/app/oracle/oradata/ORACLE19/redo03.log'  SIZE 200M BLOCKSIZE 512
DATAFILE
  '/ORA19/app/oracle/oradata/ORACLE19/system01.dbf',
  '/ORA19/app/oracle/oradata/ORACLE19/sysaux01.dbf',
  '/ORA19/app/oracle/oradata/ORACLE19/undotbs01.dbf',
  '/ORA19/app/oracle/oradata/ORACLE19/users01.dbf'
CHARACTER SET KO16MSWIN949
;
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CHANNEL','DEVICE TYPE DISK FORMAT   ''/ORA19/app/oracle/rman/%d_%U_%T.bk''');
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE','DISK TO ''/ORA19/app/oracle/rman/db_ctl_%F''');

 

 

db 종료 및 nomount 기동

1
2
3
4
5
6
7
8
9
10
11
12
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
 
Total System Global Area 1073737800 bytes
Fixed Size            8904776 bytes
Variable Size          666894336 bytes
Database Buffers      394264576 bytes
Redo Buffers            3674112 bytes

 

 

컨트롤파일 생성 sql 실행

1
2
3
4
5
6
7
8
9
SQL> @rrecon
 
Control file created.
 
 
PL/SQL procedure successfully completed.
 
 
PL/SQL procedure successfully completed.

 

 

recover 시도

1
2
3
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required

recover 가 필요없다고 나옴

 

 

db open

1
2
3
SQL> alter database open;
 
Database altered.

 

 

카탈로그 db 재설정

오라클 19c rman catalog 설명 및 catalog db 생성 https://positivemh.tistory.com/693

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ rman target / catalog catuser/catuser@catdb
RMAN> create catalog tablespace cattbs;
 
recovery catalog created
 
RMAN> register database;
 
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
 
RMAN> list incarnation;
 
List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       2       ORACLE19 3209222764       CURRENT 988348     26-JAN-21

incarnation 이 정상적으로 초기화됨

 

출처 : 오라클 19c rman incarnation 설명 및 복구 시나리오 :: 내맘대로긍정 (tistory.com)

반응형

'오라클 > 참고' 카테고리의 다른 글

오라클 19c rman catalog db 이용 백업, 복구  (0) 2023.01.10
오라클 19c rman catalog 및 catalog db 생성  (0) 2023.01.10
오라클 19c ADG 설치3  (0) 2023.01.05
오라클 19c ADG 설치2  (0) 2023.01.05
오라클 19c ADG 설치1  (0) 2023.01.05