접속
$ rman target / catalog rcuser/rcuser@rcserver
1. Crosscheck
: target 서버와 recovery catalog 간의 정보를 동기화 시켜주는 역할
① 전체 backupset과 target 서버 비교하기
RMAN> crosscheck backupset;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE' ← 정상
backup piece handle=/app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_nnndf_TAG20120221T171609_7n6npc44_.bkp RECID=1 STAMP=775847771
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_ncnnf_TAG20120221T171609_7n6nt235_.bkp RECID=2 STAMP=775848284
Crosschecked 2 objects
② 백업된 파일 OS 명령으로 지우고 crosscheck 수행
$ rm -f /app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_ncnnf_TAG20120221T171609_7n6nt235_.bkp
RMAN> crosscheck backupset;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_nnndf_TAG20120221T171609_7n6npc44_.bkp RECID=1 STAMP=775847771
crosschecked backup piece: found to be 'EXPIRED' ← 비정상
backup piece handle=/app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_ncnnf_TAG20120221T171609_7n6nt235_.bkp RECID=2 STAMP=775848284
Crosschecked 2 objects
→ EXPIRED - 실제 백업파일이 삭제되어 없는데 backupset 목록에는 있는 상태
③ 조치 : backupset에서 EXPIRED 된 목록 삭제해 주기
RMAN> delete expired backupset;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
124 105 1 1 EXPIRED DISK /app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_ncnnf_TAG20120221T171609_7n6nt235_.bkp
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_ncnnf_TAG20120221T171609_7n6nt235_.bkp RECID=2 STAMP=775848284
Deleted 1 EXPIRED objects
RMAN> crosscheck backupset;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_nnndf_TAG20120221T171609_7n6npc44_.bkp RECID=1 STAMP=775847771
Crosschecked 1 objects
▶ 정상적인 백업 파일 정보만 남아있게 되었다.
2. Delete
: backupset 을 삭제하려면 target 서버와 recovery catalog 와의 동기화를 위해 RMAN에서 이 명령어로 삭제해야 한다.
① 현재 backupset 목록 확인
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
104 Full 1.03G DISK 00:01:55 21-FEB-12
BP Key: 106 Status: AVAILABLE Compressed: NO Tag: TAG20120221T171609
Piece Name: /app/oracle/fast_recovery_area/TESTDB/backupset/2012_02_21/o1_mf_nnndf_TAG20120221T171609_7n6npc44_.bkp
List of Datafiles in backup set 104
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 927309 21-FEB-12 /app/oracle/oradata/testdb/system01.dbf
2 Full 927309 21-FEB-12 /app/oracle/oradata/testdb/sysaux01.dbf
3 Full 927309 21-FEB-12 /app/oracle/oradata/testdb/undotbs01.dbf
4 Full 927309 21-FEB-12 /app/oracle/oradata/testdb/users01.dbf
5 Full 927309 21-FEB-12 /app/oracle/oradata/testdb/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
903 Full 9.45M DISK 00:00:01 22-FEB-12
BP Key: 904 Status: AVAILABLE Compressed: NO Tag: TAG20120222T153402
Piece Name: /data/backup/rman/04n3ve7b_1_1_20120222
List of Datafiles in backup set 903
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
4 Full 933932 22-FEB-12 /app/oracle/oradata/testdb/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
945 Full 381.52M DISK 00:00:39 22-FEB-12
BP Key: 947 Status: AVAILABLE Compressed: NO Tag: TAG20120222T153428
Piece Name: /data/backup/rman/05n3ve85_1_1_20120222
List of Datafiles in backup set 945
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 933973 22-FEB-12 /app/oracle/oradata/testdb/sysaux01.dbf
- OS상에서 현재 파일상황
$ ll
total 400772
-rw-r----- 1 oracle oinstall 9912320 Feb 22 15:34 04n3ve7b_1_1_20120222
-rw-r----- 1 oracle oinstall 400064512 Feb 22 15:35 05n3ve85_1_1_20120222
② RMAN에서 삭제
: Backupset number인 BS Key 부분의 숫자를 지정해주면 된다.
RMAN> delete backupset 945;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
947 945 1 1 AVAILABLE DISK /data/backup/rman/05n3ve85_1_1_20120222
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/data/backup/rman/05n3ve85_1_1_20120222 RECID=4 STAMP=775928069
Deleted 1 objects
- RMAN에서 삭제 후 OS상에서 현재 파일상황
$ ll
total 9696
-rw-r----- 1 oracle oinstall 9912320 Feb 22 15:34 04n3ve7b_1_1_20120222
3. Catalog
: 관리자가 수동으로 백업 받은 파일을 RMAN에 추가해서 관리하기
① 수동으로 begin backup 받은 파일 만들기
SQL> select name from v$datafile;
NAME
---------------------------------------------
/app/oracle/oradata/testdb/system01.dbf
/app/oracle/oradata/testdb/sysaux01.dbf
/app/oracle/oradata/testdb/undotbs01.dbf
/app/oracle/oradata/testdb/users01.dbf
/app/oracle/oradata/testdb/example01.dbf
SQL> alter tablespace example begin backup;
Tablespace altered.
SQL> !cp /app/oracle/oradata/testdb/example01.dbf /data/backup/open/
SQL> alter tablespace example end backup;
Tablespace altered.
② begin backup 받은 내용 RMAN에 있는지 확인
$ rman target / catalog rcuser/rcuser@rcserver
RMAN> list copy;
specification does not match any datafile copy in the repository ← 백업내역에 없음
specification does not match any control file copy in the repository
List of Archived Log Copies for database with db_unique_name TESTDB
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
32 1 7 A 17-FEB-12
Name: /data/arc1/7_1_771259931.arc
33 1 7 A 17-FEB-12
Name: /data/arc2/7_1_771259931.arc
...이하생략
▶ RMAN에는 begin backup 으로 받은 내용은 기록되어 있지 않다.
③ Catalog 명령어로 recovery catalog 에 추가하기
RMAN> catalog datafilecopy '/data/backup/open/example01.dbf';
cataloged datafile copy
datafile copy file name=/data/backup/open/example01.dbf RECID=2 STAMP=775928837
RMAN> list copy;
specification does not match any control file copy in the repository
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - --------------- ---------- ---------------
1019 5 A 22-FEB-12 934219 22-FEB-12
Name: /data/backup/open/example01.dbf
▶ RMAN에 begin backup 으로 받은 내용이 기록되었다.
List of Archived Log Copies for database with db_unique_name TESTDB
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
32 1 7 A 17-FEB-12
Name: /data/arc1/7_1_771259931.arc
33 1 7 A 17-FEB-12
Name: /data/arc2/7_1_771259931.arc
...이하생략
④ change 와 uncatalog 명령 (삭제 하고 싶을 때)
RMAN> change datafilecopy '/data/backup/open/example01.dbf' uncatalog;
uncataloged datafile copy
datafile copy file name=/data/backup/open/example01.dbf RECID=2 STAMP=775928837
Uncataloged 1 objects
RMAN> list copy;
specification does not match any datafile copy in the repository ← 삭제됨
specification does not match any control file copy in the repository
List of Archived Log Copies for database with db_unique_name TESTDB
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
32 1 7 A 17-FEB-12
Name: /data/arc1/7_1_771259931.arc
33 1 7 A 17-FEB-12
Name: /data/arc2/7_1_771259931.arc
...이하생략
⑤ 정리
: 백업셋을 삭제 하고자 할 때는 RMAN에서 delete 명령을 써서 삭제해야 한다.
DB에서 redo log group을 삭제할때 해당 데이터 파일을 지우는 것이 아니라,
alter database drop logfile group 번호; 한것과 같은 원리.
'Oracle > Oracle - 백업&복구' 카테고리의 다른 글
백업 & 복구 29 - RMAN : RMAN 백업 1 (0) | 2012.02.23 |
---|---|
백업 & 복구 28 - RMAN : Channel 할당하기 (0) | 2012.02.22 |
백업 & 복구 26 - RMAN : Catalog server구성 및 복구 간단 테스트 (6) | 2012.02.21 |
백업&복구 25 - Flashback Data Archive (FBDA) (0) | 2012.02.20 |
백업&복구 24 - Flashback : Database Level (2) | 2012.02.20 |