case 1. offline되는 데이터파일이 삭제된 경우 - DB 종료 없이 복구
1. 테스트용 tablespace 생성
2. RMAN으로 full backup 수행
3. data file이 삭제되어 장애발생!
4. 해당 tablespace offline
5. 복구할 tablespace data file 복원(restore) restore tablespace
6. tablespace 복구(recover) recover tablespace
7. 해당 tablespace online
1. 테스트용 테이블 스페이스 생성
2. RMAN으로 전체 백업 수행
3. 데이터 파일 위치 확인
4. 테스트용으로 생성한 테이블스페이스의 데이터파일 삭제
5. RMAN으로 복구 (독립형 명령어 사용)
복구할 tablespace OFFLINE -> restore tablespace -> recover tablespace -> 복구완료된 tablespace ONLINE
※ RMAN으로 복구 (작업형 명령어 사용)
case 2. offline이 안되는 데이터파일이 삭제되는 경우 - DB 종료 후 복구
1. offline이 안되는 tablespace의 data file 삭제
2. DB 재시작 (shudown immediate) - 정상종료되지 않을경우 강제종료 : RMAN > shutdown abort;
3. 복구할 tablespace data file 복원(restore) restore tablespace
4. tablespace 복구(recover) recover tablespace - DB를 강제종료했을경우 DB 전체 복구 : RMAN > recover database;
5. DB Open
1. 데이터 파일 위치 확인
2. offline 되지 않는 tablespace의 datafile 삭제
3. DB 재시작 -> 삭제된 데이터 파일 때문에 open되지 않음
4. RMAN으로 복구할 테이블 스페이스 복원
RMAN > restore tablespace 테이블스페이스명;
5. 해당 tablespace를 복구 -> DB open
RMAN > recover tablespace 테이블스페이스명
RMAN > alter database open;
case 3. 임시경로에서 복구하기
1. data file 삭제
2. 장애가 발생한 tablespace OFFLINE
3. 복구할 파일 새로운 경로 지정
4. 복구할 tablespace data file 복원(restore)
5. 변경파일의 위치를 control file에 반영
6. tablespace 복구(recover)
7. 해당 tablespace ONLINE
case 4. 임시경로에 필요한 데이터 파일만 복원 후 복구하기
1. 전체 full backup
2. 테스트에 사용할 tablespace 와 table 생성 및 데이터 입력
3. data file을 삭제하여 장애 발생!
4. 해당 tablespace 재시작 -> data file이 삭제되어 재시작되지 않음
5. 복구할 임시경로 생성
6. 현재 사용하고 있는 control file과 redo log file을 복구할 임시경로에 복사
7. DB 종료후 parameter file을 vi로 열어서 control file의 위치를 복구경로로 변경
8. 마운트 상태에서 작업 startup mount
9. RMAN으로 redo log file위치를 변경 alter database rename file '기존경로' to '변경할경로'
10. 필요한 data file만 위치를 변경시키고, 필요없는 data file은 drop offline set newnamdatafile
12. 백업이 안된 파일은 신규로 재생성 (테스트용으로 생성한 tablespace) alter database create datafile
12. 필요한 tablespace 복원 (system, sysaux, undotbs1, 복구할 tablespace) restore
13. 파일위치 변경내용(redo log file, data file)을 control file에 반영 switch datafile all
14. 필요한 tablespace만 복구 recover
15. DB open alter database open
16. 해당 tablespace ONLINE alter tablespace 테이블스페이스명 online
RMAN > report schema; ## 데이터파일 위치 확인
RMAN > backup as compressed backupset database format '/data/backup/rman/%U_%T'; ## DB full bakcup
Tablespace 생성 + Table 생성 + 데이터입력
data file 삭제
삭제된 data file의 tablespace 재시작 -> 재시작되지 않음
복구할 임시디렉토리 생성 $mkdir /data/temp4
현재 사용하고 있는 log file과 control file을 복구경로에 복사
parameter file을 vi로 열어서 control file위치 변경 (복구경로로)
작업형 명령어를 사용하여 복구순서대로 작업
## DB mount -> log file 경로변경 -> data file 경로변경 -> 백업없는파일신규생성 -> 복원 -> switch -> 복구 -> DB open
run{
## DB mount 상태까지 오픈
startup mount;
##redo log file 위치 변경
sql "alter database rename file ''/app/oracle/oradata/testdb/redo01_a.log'' to ''/data/temp4/redo01_a.log''";
sql "alter database rename file ''/app/oracle/oradata/testdb/redo01_b.log'' to ''/data/temp4/redo01_b.log''";
sql "alter database rename file ''/app/oracle/oradata/testdb/redo02_a.log'' to ''/data/temp4/redo02_a.log''";
sql "alter database rename file ''/app/oracle/oradata/testdb/redo02_b.log'' to ''/data/temp4/redo02_b.log''";
sql "alter database rename file ''/app/oracle/oradata/testdb/redo03_a.log'' to ''/data/temp4/redo03_a.log''";
sql "alter database rename file ''/app/oracle/oradata/testdb/redo03_b.log'' to ''/data/temp4/redo03_b.log''";
## 필요한 data file만 경로를 임시경로로 변경
set newname for datafile 1 to '/data/temp/system01.dbf';
set newname for datafile 2 to '/data/temp/sysaux01.dbf';
set newname for datafile 3 to '/data/temp/undotbs01.dbf';
## 필요하지않은 data file은 offline drop처리
sql "alter database datafile ''/app/oracle/oradata/testdb/users01.dbf'' offline drop";
sql "alter database datafile ''/app/oracle/oradata/testdb/example01.dbf'' offline drop";
## 백업이 없는 파일을 신규로 생성
sql "alter database create datafile ''/app/oracle/oradata/testdb/rtest02.dbf'' as ''/data/temp4/rtest02.dbf''";
## 필요한 테이블스페이스만 복원
restore tablespace system;
restore tablespace sysaux;
restore tablespace undotbs1;
## 파일위치 변경내용을 control file에 반영
switch datafile all;
## 필요한 테이블스페이스만 복구
recover tablespace system;
recover tablespace sysaux;
recover tablespace undotbs1;
recover tablespace rtest2;
## DB open
alter database open;
## offline되어있는 테이블스페이스 online
sql "alter tablespace rtest2 online";
}
댓글