data file가 장애 났을 경우, image copy backup 복구 하는 방식
(point) image copy 로 되는지 확인
#) oracle 내리기
shutdown immediate
#) 장애 유발
! rm /u01/app/oracle/oradata/ora11g/*.dbf
#) startup 하기
=> 오류발생
startup
<rman session>
#) 재접속
RMAN> exit
[oracle1@oracle ~]$ rman target /
#) data file 복구하기
RMAN> restore database;
#) recover 하기
RMAN> recover database;
#) 완전 복구 가능
RMAN> alter database open;
<oracle session>
#) 재접속 후 테이블 확인
conn / as sysdba
select count(*) from hr.employees;
<rman session>
#) 스키마 확인
RMAN> report schema;
#) tablespace 확인
SELECT a.file#, a.name AS file_name, b.name AS tbs_name, a.status, a.checkpoint_change#
FROM v$datafile a, v$tablespace b
WHERE a.ts# = b.ts#;
#) tablespace 생성 + 테이블 생성
create tablespace insa_tbs datafile '/home/oracle1/insa_tbs01.dbf' size 10m;
create table hr.emp_insa tablespace insa_tbs as select * from hr.employees;
#) tablespace 확인
SELECT a.file#, a.name AS file_name, b.name AS tbs_name, a.status, a.checkpoint_change#
FROM v$datafile a, v$tablespace b
WHERE a.ts# = b.ts#;
#) 스키마 확인
RMAN> report schema;
#) backup 받을 게 있는지 확인
=> 새로 생성된 tablespace backup 받기
RMAN> report need backup;
#) backup 하기
RMAN> backup as copy datafile 3 format '/u01/app/oracle/oradata/ora11g/insa_tbs01.dbf';
=> backup을 지정한 위치에 backup 받겠다!
#) data file + control file 같이 확인
RMAN> list copy;
#) datafile 만 확인
RMAN> list datafilecopy all;
#) 장애 유발
=> 실제 data file 위치 :/home/oracle1/insa_tbs01.dbf
! rm /home/oracle1/insa_tbs01.dbf
! ls /home/oracle1/insa_tbs01.dbf
#) DB 내리기
shutdown immediate
=> 채널 끊김
#) 재접속 후 DB 올리기
conn / as sysdba
startup
=> 오류 발생
#) 장애난 tablespace offline모드로 변경
alter database datafile 3 offline;
#) DB 열기
alter database open;
#) tablespace 상태 확인
SELECT a.file#, a.name AS file_name, b.name AS tbs_name, a.status, a.checkpoint_change#
FROM v$datafile a, v$tablespace b
WHERE a.ts# = b.ts#;
<rman session>
#) 재접속
RMAN> exit
[oracle1@oracle ~]$ rman target /
#) backup 확인
RMAN> list datafilecopy all;
#) 스위치로 변경 (=: restore 하기)
RMAN> switch datafile 3 to copy;
=> control file에 적용
#) recover 하기
=> redo+아카이브 적용
RMAN> recover datafile 3;
#) online 모드 변경
RMAN> sql 'alter database datafile 3 online';
#) 스키마로 위치 변경 된 것 확인
RMAN> report schema;
<oracle session>
SELECT a.file#, a.name AS file_name, b.name AS tbs_name, a.status, a.checkpoint_change#
FROM v$datafile a, v$tablespace b
WHERE a.ts# = b.ts#;
#) 테이블 복구 완료 되었는지 확인
select count(*) from hr.emp_insa;
#) tablespace 삭제
drop tablespace insa_tbs including contents and datafiles;
<rman session>
RMAN> list copy;
RMAN> delete copy;
RMAN> delete backup;
RMAN> list backup;
RMAN> backup as compressed backupset database;
RMAN> list backup;