결론부터 말씀드리면 저번주처럼 또 테스트 완료를 못했습니다.
테스트 db가 다른 문제로 올라오질 않아 테스트완료가 되지 못하였으나 작업한 곳까지 올리고 그 후에 하려고 했던 작업을 쓰는걸로 해야할것 같습니다.
1. 일단 테스트를 위해 테이블스페이스생성, 테이블생성, 데이터입력
여기서 테이블스페이스의 경우 ASM이어서 아래와 같은 문장만으로도 생성이 됩니다.
SQL> create tablespace TS_BACKUP_TEST datafile size 10m; SQL> create table system.BACKUP_TEST_1 (no number, name varchar2(10)) tablespace TS_BACKUP_TEST; SQL> insert into system.BACKUP_TEST_1 values (1,'AAA'); SQL> commit;
2. RMAN에 접속하여 백업수행하고 컨트롤파일백업만 다시 확인해봅니다.
왜냐하면 drop된 테이블스페이스복구의 key point가 바로 controlfile이기 때문이지요~
RMAN> backup database plus archivelog; RMAN> list backup of controlfile; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 71 Full 17.33M DISK 00:00:01 15-JUL-16 BP Key: 71 Status: AVAILABLE Compressed: NO Tag: TAG20160715T190200 Piece Name: /backup/ARC/ORCL12/autobackup/2016_07_15/o1_mf_s_917290920_crkf4s8d_.bkp Control File Included: Ckp SCN: 4735515 Ckp time: 15-JUL-16
3. 그리고 삭제될 테이블스페이스가 백업이 잘 되어있나도 확인해봅니다.
RMAN> list backup of tablespace TS_BACKUP_TEST; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 68 Full 1.70G DISK 00:00:12 15-JUL-16 BP Key: 68 Status: AVAILABLE Compressed: NO Tag: TAG20160715T190137 Piece Name: /backup/ARC/ORCL12/backupset/2016_07_15/o1_mf_nnndf_TAG20160715T190137_crkf41dl_.bkp List of Datafiles in backup set 68 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 11 Full 4735494 15-JUL-16 +DATA/ORCL12/DATAFILE/ts_backup_test.385.917290659
4. 그리고 이제 테이블스페이스를 삭제합니다.
우리는 항상 자나깨나 drop문은 다시 봐야합니다. 이거 백업이 있다고 해도 drop은 항상 손떨리죠.
SQL> drop tablespace TS_BACKUP_TEST including contents and datafiles; Tablespace dropped. SQL> select * from system.backup_test_1; select * from system.backup_test_1 * ERROR at line 1: ORA-00942: table or view does not exist
5. 이제 RMAN에 가서 테이블스페이스가 잘 백업이 되어있는지 다시 확인해봅니다.
RMAN> list backup of tablespace TS_BACKUP_TEST; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of list command at 07/15/2016 19:05:53 RMAN-20202: Tablespace not found in the recovery catalog RMAN-06019: could not translate tablespace name "TS_BACKUP_TEST"
아니 아까 분명히 있었는데 없데요. 이상하네요. 그냥 restore를 수행해봅니다. 역시 없다네요.
그런 테이블스페이스는 알수가 없다는 에러를 뿌립니다.
RMAN> restore tablespace TS_BACKUP_TEST; Starting restore at 15-JUL-16 using channel ORA_DISK_1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 07/15/2016 19:06:34 RMAN-20202: Tablespace not found in the recovery catalog RMAN-06019: could not translate tablespace name "TS_BACKUP_TEST"
원인은 우리가 사용하는 catalog가 바로 control file이기 때문입니다.
현재의 control file에는 이미 TS_BACKUP_TEST라는 정보는 지워졌어요. 그래서 아까 백업본을 확인했던 그 컨트롤파일로 다시 DB를 올려볼꺼에요.
==> 그런데 여기까지 하고 DB를 내렸으나 내려가지도 올라오지도 않아 테스트를 못하였습니다.
이 이후에 진행할 내용은 아래와 같습니다.
DB의 문제로 아래 결과를 올리지는 못했지만 확인이 되는데로 아래 부분을 수정하도록 하겠습니다.
2016/07/20 : 테스트DB 기동으로 아래 테스트를 완료하였습니다. 아래 내용 참고부탁드립니다.
RMAN> shutdown immediate; RMAN> startup nomount; RMAN> restore controlfile from '/backup/ARC/ORCL12/autobackup/2016_07_15/o1_mf_s_917290920_crkf4s8d_.bkp'; Starting restore at 20-JUL-16 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=16 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 output file name=+DATA/ORCL12/CONTROLFILE/current.272.912335235 output file name=/backup/ARC/ORCL12/controlfile/o1_mf_cmwszmbm_.ctl Finished restore at 20-JUL-16 RMAN> alter database mount; Statement processed released channel: ORA_DISK_1 RMAN> list backup of tablespace TS_BACKUP_TEST; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 68 Full 1.70G DISK 00:00:12 15-JUL-16 BP Key: 68 Status: AVAILABLE Compressed: NO Tag: TAG20160715T190137 Piece Name: /backup/ARC/ORCL12/backupset/2016_07_15/o1_mf_nnndf_TAG20160715T190137_crkf41dl_.bkp List of Datafiles in backup set 68 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 11 Full 4735494 15-JUL-16 +DATA/ORCL12/DATAFILE/ts_backup_test.385.917290659 RMAN> RUN { set until scn 4735494; restore database; } RMAN> RUN { set until scn 4735494; recover database; } executing command: SET until clause Starting recover at 20-JUL-16 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 20-JUL-16 RMAN> alter database open resetlogs; SQL> select segment_name from dba_segments where tablespace_name='TS_BACKUP_TEST'; SEGMENT_NAME -------------------------------------------------------------------------------- BACKUP_TEST_1 SQL> select * from system.BACKUP_TEST_1; NO NAME ---------- ---------- 1 AAA 2 BBB