아카이브 완전 백업
사용자테이블 스페이스를 구성하는 데이터파일이 유실되었때 – 디비를 내리지 않고
recovery
단계 1 정상적인 업부 수행
[oracle@localhost ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 8 05:58:35 2007 Copyright (c) 1982, 2005, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Database opened.
SQL> ed
1 create table hr.jino 2 tablespace users 3 as
4* select * from scott.emp 5 /
Table created.
SQL> select 2 count(*) 3 from hr.jino 4 ;
COUNT(*) --- 14 SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
단계 2 에러 발생 유저 시스템 스페이스가 날라갔디………..
SQL> host
[oracle@localhost ~]$ rm -rf /u01/app/oracle/oradata/orcl/users01.dbf [oracle@localhost ~]$ exit
exit
몇 번을 강조해도 모자란다. 램에 있는걸 읽기 때문에 개졌는지 모른다.
SQL> select 2 count(*) 3 from hr.jino 4 ;
COUNT(*) --- 14
단계 3 유실된 파일이 어느 테이블 스페이스에 있는지 확인
SQL> set linesize 132
SQL> col file_name format a40 SQL> select
2 file#
3 ,status 4 ,enabled
5 ,checkpoint_change#
6 ,name
7 from v$datafile 8 ;
oracle/oradata/ora9200/system01.dbf
2 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/cwmlite01.dbf
4 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/drsys01.dbf
5 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/example01.dbf
6 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/indx01.dbf
7 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/odm01.dbf
8 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/tools01.dbf
9 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/users01.dbf
10 ONLINE READ WRITE 293319 /u01/app/oracle/oradata/orcl/xdb01.dbf
11 ONLINE READ ONLY 235052 /u01/app/oracle/oradata/orcl/query01.dbf
11 rows selected.
단계 3 유실된 파일이 있는 테이블 스페이스를 off 라인 시킴 나머지는 정상임
SQL> alter database datafile '/u01/app/oracle/oradata/orcl/users01.dbf' offline;
Database altered.
단계 4 복구가 필요하지 않아보는 퀴리 날림
SQL> select
2 d.file#
3 ,d.name 4 ,d.status 5 ,h.status
6 from v$datafile d, v$datafile_header h 7 where d.file#= h.file#
8 ;
9
/u01/app/oracle/oradata/orcl/users01.dbf RECOVER OFFLINE
11 rows selected.
단계 5 복구 수행 명심 할 것은 지금은 디비는 정상 작동 중이고 유저번 까진 상태
물리적 복구 즉 파일을 갈아치운다.
SQL> host
[oracle@localhost ~]$ cp /oracle/oradata/onbackup/users01.dbf /u01/app/oracle/oradata/orcl/
[oracle@localhost ~]$ exit exit
단계 6 논리적 복구 복원이란 표현이 낳다. 아카이브 파일을 요구한다.
SQL> recover tablespace users;
ORA-00279: change 239781 generated at 08/08/2007 04:07:09 needed for thread 1 ORA-00289: suggestion : /oracle/oradata/archive/arch_4.arc
ORA-00280: change 239781 for thread 1 is in sequence #4
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 240025 generated at 08/08/2007 04:08:42 needed for thread 1 ORA-00289: suggestion : /oracle/oradata/archive/arch_5.arc
ORA-00280: change 240025 for thread 1 is in sequence #5
ORA-00278: log file '/oracle/oradata/archive/arch_4.arc' no longer needed for this recovery
ORA-00279: change 241925 generated at 08/08/2007 04:19:49 needed for thread 1 ORA-00289: suggestion : /oracle/oradata/archive/arch_6.arc
ORA-00280: change 241925 for thread 1 is in sequence #6
ORA-00278: log file '/oracle/oradata/archive/arch_5.arc' no longer needed for this recovery
Log applied.
Media recovery complete. 다 끝났다는 이야기이다.
SQL>
단계 7 더 복구할 파일이 있는지 상태 확인
SQL> select 2 *
3 from v$recover_file;
no rows selected
단계 8 파일 및 현재 상태 확인
SQL>
SQL> r 1 select 2 file#
3 ,status 4 ,enabled
5 ,checkpoint_change#
6 ,name
7* from v$datafile
9 OFFLINE READ WRITE 294000 /u01/app/oracle/oradata/orcl/users01.dbf
11 rows selected.
SQL> ed
Wrote file afiedt.buf 1 select
2 d.file#
3 ,d.name 4 ,d.status 5 ,h.status
6 from v$datafile d, v$datafile_header h 7* where d.file#= h.file#
8 /
9
/u01/app/oracle/oradata/orcl/users01.dbf OFFLINE OFFLINE
단계 9 테이블 스페이스를 온라인 시킴
SQL> alter database datafile '/u01/app/oracle/oradata/orcl/users01.dbf' online;
Database altered.
단계 10 값 확인
SQL> select 2 count(*) 3 from hr.jino 4 ;
COUNT(*) --- 14