기본적인 복구 방법과 절차가 같음 다만 명령어가 생긴것이 다를뿐 원리가중요함
※작업형 명령어의 경우 중간에 실패하면 중간 실패됨
완전복구
실습 예제
□ OFFLINE 되는 데이터 파일 삭제된 상황
① datafile 을 offline 으로 바꿈
② 복원 (restore)
③ datafile 복구 (recovery)
④ datafile online;
[상황 만들기]
SQL> create tablespace rtest
2 datafile '/app/oracle/oradata/testdb/rtest01.dbf' size 10M
3 autoextend on;
[RMAN 전체 백업 받기]
RMAN> backup as compressed backupset database
2> format '/data/backup/open/rman/%T_full_%U';
[삭제하기]
[oracle@server113 ~]$ rm -f /app/oracle/oradata/testdb/rtest01.dbf
[oracle@server113 ~]$ ls /app/oracle/oradata/testdb/rtest01.dbf
ls: /app/oracle/oradata/testdb/rtest01.dbf: 그런 파일이나 디렉토리가 없음
[oracle@server113 ~]$
[복구하기]
RMAN> sql 'alter tablespace rtest offline immediate';
sql statement: alter tablespace rtest offline immediate
RMAN> restore tablespace rtest;
Starting restore at 07-APR-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00008 to /app/oracle/oradata/testdb/rtest01.dbf
channel ORA_DISK_1: reading from backup piece /data/backup/open/rman/20150407_full_18q3pift_1_1
channel ORA_DISK_1: piece handle=/data/backup/open/rman/20150407_full_18q3pift_1_1 tag=TAG20150407T121141
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 07-APR-15
RMAN> recover tablespace rtest;
Starting recover at 07-APR-15
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 07-APR-15
RMAN> sql 'alter tablespace rtest online';
sql statement: alter tablespace rtest online
※ 작업형 명령어
run {
sql 'alter tablespace rtest offline immediate';
restore tablespace rtest;
recover tablespace rtest;
sql 'alter tablespace rtest online';
}
□ OFFLINE 안되는 데이터 파일 삭제된 상황
① DB 종료
② 복원 (restore)
③ 데이터베이스 복구 (recovery)
④ 데이터 베이스 open
[상황설정]
[oracle@server113 ~]$ rm -f /app/oracle/oradata/testdb/system01.dbf
[oracle@server113 ~]$ ls /app/oracle/oradata/testdb/system01.dbf
ls: /app/oracle/oradata/testdb/system01.dbf: 그런 파일이나 디렉토리가 없음
[oracle@server113 ~]$ rman target sys/oracle
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Apr 7 12:38:28 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup
Oracle instance started
database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 04/07/2015 12:38:53
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/app/oracle/oradata/testdb/system01.dbf'
RMAN> restore tablespace system;
Starting restore at 07-APR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /app/oracle/oradata/testdb/system01.dbf
channel ORA_DISK_1: reading from backup piece /data/backup/open/rman/20150407_full_18q3pift_1_1
channel ORA_DISK_1: piece handle=/data/backup/open/rman/20150407_full_18q3pift_1_1 tag=TAG20150407T121141
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:19
Finished restore at 07-APR-15
RMAN> recover database;
Starting recover at 07-APR-15
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 07-APR-15
RMAN> alter database open;
□ 임시 경로 에서 datafile 복구하기
① datafile 을 offline 으로 바꿈
② datafile을 임시 경로로 바꿔주기
③ 복원 (restore)
④ control 파일의 경로를 바꾸어 주고
⑤ datafile 복구 (recovery)
⑥ datafile online;
[상황설정]
[oracle@server113 ~]$ rm -f /app/oracle/oradata/testdb/rtest01.dbf
[oracle@server113 ~]$ ls /app/oracle/oradata/testdb/rtest01.dbf
ls: /app/oracle/oradata/testdb/rtest01.dbf: 그런 파일이나 디렉토리가 없음
[]
RMAN> report schema;
Report of database schema for database with db_unique_name TESTDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 740 SYSTEM *** /app/oracle/oradata/testdb/system01.dbf
2 560 SYSAUX *** /app/oracle/oradata/testdb/sysaux01.dbf
3 350 UNDOTBS1 *** /app/oracle/oradata/testdb/undotbs01.dbf
4 15 USERS *** /app/oracle/oradata/testdb/users01.dbf
5 100 EXAMPLE *** /app/oracle/oradata/testdb/example01.dbf
6 10 TEST4 *** /app/oracle/oradata/testdb/test04.dbf
7 10 TEST *** /app/oracle/oradata/testdb/test001.dbf
8 10 RTEST *** /app/oracle/oradata/testdb/rtest01.dbf
[상태]
TABLESPACE MB FILE_NAME
---------- ---------- --------------------------------------------------
EXAMPLE 100 /app/oracle/oradata/testdb/example01.dbf
USERS 15 /app/oracle/oradata/testdb/users01.dbf
UNDOTBS1 350 /app/oracle/oradata/testdb/undotbs01.dbf
SYSAUX 560 /app/oracle/oradata/testdb/sysaux01.dbf
SYSTEM 740 /app/oracle/oradata/testdb/system01.dbf
TEST4 10 /app/oracle/oradata/testdb/test04.dbf
TEST 10 /app/oracle/oradata/testdb/test001.dbf
RTEST 10 /app/oracle/oradata/testdb/rtest01.dbf
[복구]
run {
sql 'alter tablespace rtest offline immediate';
set newname for datafile ' /app/oracle/oradata/testdb/rtest01.dbf'
to '/data2/temp/rtest01.dbf';
restore tablesapce rtest;
switch datafile 8
recover tablespace rtest;
sql 'alter tablespace rtest online';
}
□ 임시경로에서 필요한 Datafile만 복구 + 백업이 없는 Datafile 상황
① DB 종료
② control , redolog 를 임시경로로 복사하기
③ parameter에 control읠 경로를 임시 경로로 해줌 DB
④ mount 상태로
⑤ OPEN시 필요한datafile(system,sysaux,undotbs, 해당 datafile), redolog 의 경로를 임시경로로 바꾸어줌
⑥ 복구에 필요없는 datafile은 offline 한뒤에
⑦ ---만일 백업이 없는 경우 생성해주기
⑧ 필요한 datafile(system,sysaux,undotbs, 해당 datafile) 복원 (restore)
⑨ 파일 변경 위치를 control 파일에 반영하기
⑩ datafile 복구 (recovery)
⑪ DB open
⑫ 해당 table space online 해주고
⑬
⑭
불완전복구