본문 바로가기
oracle/[Recovery] 기타

[Clone DB] clone db와 exp/imp를 이용한 drop table복구

by #moonyz 2014. 11. 10.



[전제 조건]

백업파일경로 : /data/backup/close

운영 DB SID : testdb

clone DB SID : clonedb

clone DB 파일경로 : /data/clone/



1. archive mode에서 작업하기 



2. 전체 close backup 수행 : DB shutdown -> 백업 -> startup




3. 테이블 생성 + 데이터 입력 + 데이터 존재하는 시간 확인



4. 생성한 테스트용 테이블을 drop table하여 장애 발생시킴



5. 스위치 발생시켜 현재 redo log file을 archive log file로 만들기



6. 현재 parameter file을 복사하여 clone DB의 parameter file을 만들어줌



7. 복사하여 만들어준 parameter file을 열어 clone DB에 맞게 내용 수정

> control file 경로 수정

> db_name 수정

> memory_target 주석처리 (11g부터)



8. control file을 생성하기 전에 백업해두었던 data file을 clone DB 경로로 복사



9. 현재 운영중인 DB(testdb)에서 control file 생성 스크립트를 만들어줌



10. control file 생성 스크립트를 vi로 열어 수정

RESETLOGS로 control file을 만들 스크립트만 남겨두고 전부 삭제

> log file과 data file의 경로를 수정

> 2번째 줄을 create controlfile set database "clonedb" resetlogs archivelog로 수정



11. 수정이 완료된 control file 생성 스크립트를 확인후 저장 



12. clonedb로 접속하여 control file 생성 스크립트를 실행 -> control file 생성 



13. 만들어진 control file을 확인 후 recover -> open resetlogs;

> recover database until time '복구시간' using backup controlfile;

> alter database open resetlogs;



14. 복제 DB에서 데이터가 복구되었는지 확인 -> 복구 완료



15. 현재 운영중이었던 testdb에서는 복구작업이 일어나지 않았으므로 데이터 여전히 존재하지 않음 



16. clonedb에서 복구할 테이블 export 

$ export ORACLE_SID=clonedb

$ exp scott/tiger file=tt11.dmp tables=tt11;



17. 현재 운영중인 테이블에 접속하여 import 작업 진행

$ export ORACLE_SID=testdb

$ imp scott/tiger file=tt11.dmp ignore=y;



18. 현재 운영중인 DB에 import작업이 끝나면 데이터가 복구 되었는지 확인



19. 복구가 완료되면 복제했던 clonedb는 바로 종료시킴




댓글