■ RMAN 백업 유형
1) FULL 백업은 상용된 모든 데이터 파일 블록을 포함된다.
2) 레벨이 0인 incremental 백업은 레벨 0으로 표시된 FULL 백업과 동일하다.
- cumulative 레벨 1 incremental 백업은 마지막 레벨 0 incremental 백업 이후 수정한 블록만 포한(=: differential 레벨 1을 묶음)
- differential 레벨 1 incremental 백업은 마지막 incremental 백업 이후 수정한 블록만 포함(=: 변경된 파일만 백업)
일 | 월 | 화 | 수 | 목 | 금 | 토 | 일 |
full(0) | d(1) | d(1) | c(1) | d(1) | d(1) | d(1) | full(0) |
- full(0) : 레벨 0 에서 incremental backup(full backup)
RMAN> backup incremental level 0 database;
- d(1) : differential incremental backup(incremental backup 이후에 변경된 블록만 받자)
RMAN> backup incremental level 1 database;
=> 변경된 블록은 어떻게 아나? scn 번호로 확인
- c(1) : cumulative incremental backup(incremental backup(0) 이후에 변경한 모든 블록들 받자)
RMAN> backup incremental level 1 cumulative database;
=> rowid; 블록 변경된 주소 기록
◆ block change tracking(10g)
- 변경사항 추적 파일에서 변경된 블록 기록한다.
- CTWR : 변경된 블록을 추척하고 기록하는 프로세스
- 활성화된 경우, RMAN 에 의해 자동으로 사용된다.
#) 바이럴 형식으로 만들어진다. / 활성화 기능
alter database enable block change tracking using file '/home/oracle1/backup/rman/block_tracking.txt';
####
Tue Jan 30 14:56:21 2024
CTWR started with pid=28, OS id=24532
Block change tracking service is active.
Completed: alter database enable block change tracking using file '/home/oracle1/backup/rman/block_tracking.txt'
####
#) 용량 확인
! ls -l /home/oracle1/backup/rman/block_tracking.txt
- 백업 중에 전체 데이터 파일을 스캔하지 않도록 incremental 백업을 최적화 한다.
- i/o 성능은 놓게 한다.
#) db_create_file_dest 확인
show parameter db_create_file_dest
- db_create_file_dest: 파라미터를 설정한 경우 블록 변경 사항 추적 파일를 설정할 필요 없다.
- OMF(Oracle Managed File)으로 생성된다.
#) 설정 방법
# 활성화
alter database enable block change tracking;
# 비활성화
alter database disable block change tracking;
#) block change tracking 확인
select * from v$block_change_tracking;
#) ctwr 확인하기
! ps -ef | grep ctwr
oracle1 24532 1 0 14:56 ? 00:00:00 ora_ctwr_ora11g
oracle1 24735 20505 0 15:03 pts/2 00:00:00 /bin/bash -c ps -ef | grep ctwr
oracle1 24737 24735 0 15:03 pts/2 00:00:00 grep ctwr
<rman session>
#) 기존에 있는 backup 삭제
RMAN> delete backup;
#) 레벨 0 backup 받기
RMAN> backup incremental level 0 database;
Starting backup at 30-JAN-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ora11g/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ora11g/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ora11g/example01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/ora11g/undo01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 30-JAN-24
channel ORA_DISK_1: finished piece 1 at 30-JAN-24
piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_30/o1_mf_nnnd0_TAG20240130T150504_lvk4dk6d_.bkp tag=TAG20240130T150504 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 30-JAN-24
Starting Control File and SPFILE Autobackup at 30-JAN-24
piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/autobackup/2024_01_30/o1_mf_s_1159628769_lvk4gkpt_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-JAN-24
#) 기존 backup 과 비교해보기
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Incr 0 1.17G DISK 00:01:04 30-JAN-24
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20240130T150504
Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_30/o1_mf_nnnd0_TAG20240130T150504_lvk4dk6d_.bkp
List of Datafiles in backup set 7
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/system01.dbf
2 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/sysaux01.dbf
4 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/users01.dbf
5 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/example01.dbf
9 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/undo01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8 Full 9.67M DISK 00:00:00 30-JAN-24
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20240130T150609
Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/autobackup/2024_01_30/o1_mf_s_1159628769_lvk4gkpt_.bkp
SPFILE Included: Modification time: 30-JAN-24
SPFILE db_unique_name: ORA11G
Control File Included: Ckp SCN: 2396145 Ckp time: 30-JAN-24
#) redo log 확인
SELECT a.group#, b.sequence#, a.member, b.bytes/1024/1024 MB, b.archived, b.status, b.first_time, b.first_change#, b.next_change#
FROM v$logfile a, v$log b
WHERE a.group# = b.group#
ORDER BY 1;
GROUP# SEQUENCE# MEMBER MB ARC STATUS FIRST_TIM
------ --------- -------------------------------------------------- -------- --- -------- ---------
FIRST_CHANGE# NEXT_CHANGE#
------------- ------------
7 1 /u01/app/oracle/oradata/ora11g/redo07.log 100.000 YES INACTIVE 29-JAN-24
2379262 2381851
8 2 /u01/app/oracle/oradata/ora11g/redo08.log 100.000 NO CURRENT 29-JAN-24
2381851 2.8147E+14
9 0 /u01/app/oracle/oradata/ora11g/redo09.log 100.000 YES UNUSED
0 0
#) block change tracking 확인
select status, filename, bytes/1024/1024 mb from v$block_change_tracking;
#) update문 + commit;
update hr.employees set salary = salary* 1.1 where department_id = 20;
commit;
#) table 생성 후 확인
create table hr.inc_emp as select * from hr.employees;
select count(*) from hr.inc_emp;
COUNT(*)
----------
107
#) delete문 + commit
delete from hr.inc_emp where department_id =50;
commit;
#) 로그 스위치 발생
alter system switch logfile;
#) redo 정보 확인
SELECT a.group#, b.sequence#, a.member, b.bytes/1024/1024 MB, b.archived, b.status, b.first_time, b.first_change#, b.next_change#
FROM v$logfile a, v$log b
WHERE a.group# = b.group#
ORDER BY 1;
GROUP# SEQUENCE# MEMBER MB ARC STATUS FIRST_TIM
------ --------- -------------------------------------------------- -------- --- -------- ---------
FIRST_CHANGE# NEXT_CHANGE#
------------- ------------
7 1 /u01/app/oracle/oradata/ora11g/redo07.log 100.000 YES INACTIVE 29-JAN-24
2379262 2381851
8 2 /u01/app/oracle/oradata/ora11g/redo08.log 100.000 YES ACTIVE 29-JAN-24
2381851 2396484
9 3 /u01/app/oracle/oradata/ora11g/redo09.log 100.000 NO CURRENT 30-JAN-24
2396484 2.8147E+14
#) block_change_tracking 확인
select status, filename, bytes/1024/1024 mb from v$block_change_tracking;
<rman session>
#) level 1 backup 받기
=> 변경된 파일에 대해서만 bakcup 받기
RMAN> backup incremental level 1 database;
Starting backup at 30-JAN-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ora11g/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ora11g/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ora11g/example01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/ora11g/undo01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 30-JAN-24
channel ORA_DISK_1: finished piece 1 at 30-JAN-24
piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_30/o1_mf_nnnd1_TAG20240130T151513_lvk4zl6m_.bkp tag=TAG20240130T151513 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-JAN-24
Starting Control File and SPFILE Autobackup at 30-JAN-24
piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/autobackup/2024_01_30/o1_mf_s_1159629316_lvk4zo28_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-JAN-24
#) 백업 확인
RMAN> list backup;
List of Backup Sets
===================
=> 레벨 0 받은 부분
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Incr 0 1.17G DISK 00:01:04 30-JAN-24
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20240130T150504
Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_30/o1_mf_nnnd0_TAG20240130T150504_lvk4dk6d_.bkp
List of Datafiles in backup set 7
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/system01.dbf
2 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/sysaux01.dbf
4 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/users01.dbf
5 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/example01.dbf
9 0 Incr 2396107 30-JAN-24 /u01/app/oracle/oradata/ora11g/undo01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8 Full 9.67M DISK 00:00:00 30-JAN-24
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20240130T150609
Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/autobackup/2024_01_30/o1_mf_s_1159628769_lvk4gkpt_.bkp
SPFILE Included: Modification time: 30-JAN-24
SPFILE db_unique_name: ORA11G
Control File Included: Ckp SCN: 2396145 Ckp time: 30-JAN-24
=> 레벨 1 에 백업 확인
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9 Incr 1 1.46M DISK 00:00:02 30-JAN-24
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20240130T151513
Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_30/o1_mf_nnnd1_TAG20240130T151513_lvk4zl6m_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 1 Incr 2396527 30-JAN-24 /u01/app/oracle/oradata/ora11g/system01.dbf
2 1 Incr 2396527 30-JAN-24 /u01/app/oracle/oradata/ora11g/sysaux01.dbf
4 1 Incr 2396527 30-JAN-24 /u01/app/oracle/oradata/ora11g/users01.dbf
5 1 Incr 2396527 30-JAN-24 /u01/app/oracle/oradata/ora11g/example01.dbf
9 1 Incr 2396527 30-JAN-24 /u01/app/oracle/oradata/ora11g/undo01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 9.67M DISK 00:00:01 30-JAN-24
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20240130T151516
Piece Name: /u01/app/oracle/fast_recovery_area/ORA11G/autobackup/2024_01_30/o1_mf_s_1159629316_lvk4zo28_.bkp
SPFILE Included: Modification time: 30-JAN-24
SPFILE db_unique_name: ORA11G
Control File Included: Ckp SCN: 2396535 Ckp time: 30-JAN-24
#) inc_emp 확인
select f.tablespace_name, f.file_name, count(*)
from dba_extents e, dba_data_files f
where f.file_id = e.file_id
and e.segment_name = 'INC_EMP'
and e.owner = 'HR'
group by f.tablespace_name, f.file_name;
#) 장애 발생
! rm /u01/app/oracle/oradata/ora11g/users01.dbf
! ls /u01/app/oracle/oradata/ora11g/users01.dbf
#) DB 내리기
shutdown immediate
#) DB 올리기
=> 오류발생
startup
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/ora11g/users01.dbf'
<rman session>
#) 재접속
RMAN> exit
[oracle1@oracle ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Jan 30 15:20:04 2024
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11G (DBID=256734894, not open)
#) 장애 확인
RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
82 HIGH OPEN 30-JAN-24 One or more non-system datafiles are missing
22 HIGH OPEN 17-DEC-23 One or more non-system datafiles are offline
RMAN> list failure 82 detail;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
82 HIGH OPEN 30-JAN-24 One or more non-system datafiles are missing
Impact: See impact for individual child failures
List of child failures for parent failure ID 82
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
5333 HIGH OPEN 30-JAN-24 Datafile 4: '/u01/app/oracle/oradata/ora11g/users01.dbf' is missing
Impact: Some objects in tablespace USERS might be unavailable
#) rman에게 DB에서 발생한 실패사항에 대한 자동 복구 계획 생성
RMAN> advise failure;
#) rman에게 DB에서 발생한 실패사항에 대한 복구 작업을 미리 확인하기
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora11g/ora11g/hm/reco_427944948.hm
contents of repair script:
# restore and recover datafile
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';
#) rman에게 DB에서 발생한 실패사항에 대한 복구 작업을 수행
RMAN> repair failure;
#) DB open 하기
RMAN> alter database open;
<oracle session>
#) DB 상태 확인 및 테이블 확인
select status from v$instance;
select count(*) from hr.inc_emp;
COUNT(*)
----------
62
☆ tip) 오라클 버전 ☆
8i, 9i에서의 i의 의미 | internet을 의미 |
10g, 11g에서의 g의 의미 | 그리드(grid) 그리드란? Oracle Grid Computing 아키텍처를 나타냄. 자원 통합 및 자동화, 자동화된 관리, 확장성의 특징을 통해 성능 + 가용성 + 확장성을 갖는 데이터베이스 시스템을 구축하고 운영할 수 있도록 도와주는 개념 |
9c, 12c에서의 c의 의미 | 클라우드(clond) 클라우드란? 인터넷을 통해 컴퓨팅 리소스와 서비스를 제공하는 개념. |
'Backup > RMAN' 카테고리의 다른 글
incarnation 하는 방법 (0) | 2024.01.31 |
---|---|
모든 파일이 손상되었을 경우, 다른 위치로 복구 해야 한다. (1) | 2024.01.31 |
data file가 장애 났을 경우, image copy backup 복구 하는 방식 (0) | 2024.01.29 |
maxsetsize, maxpiecesize, image copy backup (0) | 2024.01.29 |
RMAN의 장애 복구 방법(advise failure) (0) | 2024.01.29 |