'oracle'에 해당되는 글 4건
- 2008/11/06 신입사원 직무역량 강화 08년11월6일 - Oracle 장애복구
- 2007/05/31 JSP를 이용해서 오라클 BLOB 다루기 (1)
- 2006/09/16 64bit 데비안 리눅스에서 오라클을 설치하면서...
- 2006/06/16 오라클에서 온 소포... (1)
- 신입사원 직무역량 강화 08년11월6일 - Oracle 장애복구
- CS&E/Database
- 2008/11/06 21:53
- oracle, 데이터백업, 오라클, 장애복구, 직무역량강화
- Posted by eternalbleu
more..
사용자 백업 복구
백업 및 복구 문제
MTBFMeanTimeBetweenFailures : 장애 사이의 간격
MTTRMeanTimeBetweenRecover : 장애 복구 시간
데이터베이스 장애 유형
문장오류
권한 불충분, 공간 불충분, 응용 프로그램 오류, 잘못된 데이터 입력, 할당량 부족
-> 권한의 문제는 DBA가 직접 수행하지만 그 밖의 문제는 DBA가 할 수 없다.
사용자 실수
중요 테이블 DROP,
▶ 오라클 9i이전에는 휴지통의 개념이 없다.
사용자 프로세스 오류
인스턴스장애
오라클 서버 전원 OFF, 소프트웨어적인 문제 발생
▶ DBA가 할 수 있는 내용은 인스턴스를 재 시작하는 것뿐
Media 장애
물리적 디스크 에러
ALERT_SID.LOG 파일
데이터베이스 사용시 문제가 발생한 경우 로그가 기록되는 파일. (장애가 난 경우에 가장 먼저 보아야 하는 파일)
sartup, shutdown 정보
데이터베이스, 테이블 스페이스 생성변경삭제 작업 내역
recovery 관계 작업
logswitch 등의 DB 이벤트
DB 오류에 관한 오라클 에러 코드 및 메시지
온라인 백업의 순서
일반적으로 온라인 백업을 한다는 말은 CKPT에 의해서 controlfile, datafile 에서 유지되고 있는 시점정보가 모두 일치시켜야 한다는 것을 의미한다. 따라서 온라인 백업을 위해서는 ckpt가 일시적으로 시점정보를 유지하기 위한 마킹 작업을 막아야 함을 의미한다.
alter tablespace tablespacename begin backup;
이렇게 일시적으로 시점 일치화 작업을 중지시킨 후 DBA는 해당 DB 파일을 수동으로 복사해야 한다.
※ begin backup 이 복사 작업을 행하지 않는다는 사실에 유의. 설사 시점정보 기록작업을 멈추더라도 DBMS의 경우 DML작업은 메모리 상에서 행하기 때문에 사실상 작업은 모두 가능함.
READ ONLY 테이블 스페이스 백업
alter tablespace tablespacename read only;
Read only 가 해당 테이블스페이스에 지정된 이후로는 시점 정보의 갱신이 이루어 지지 않기 때문에 해당 테이블 스페이스의 저장 공간은 단순히 복사만 하더라도 백업이 가능하다. Read only 테이블의 장애가난 경우라면 controlfile 내에 등록된 read-only 시점과 파일내의 read-only 시점이 같은 경우라면 agree.
(컨트롤 파일에 read-only 시점에 대한 정보가 입력되며, 운영 중에 ckpt 작업을 중지하지 않더라도 바로 백업이 가능하다)
1. 데이터 베이스 접속 및 사전 작업
dba25@sun02-zone:/oracle/dba/dba25/dbs] sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Nov 6 08:56:18 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> col tablespace_name format a20
SQL> col file_name format a50
SQL> select tablespace_name, file_name, file_id from dba_data_files;
TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
FILE_ID
----------
SYSTEM /oracle/dba/dba25/dbs/system01.dbf
1
UNDOTBS /oracle/dba/dba25/dbs/undotbs.dbf
2
USERS /oracle/dba/dba25/dbs/users01.dbf
3
TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
FILE_ID
----------
INDX /oracle/dba/dba25/dbs/indx01.dbf
4
SAMPLE /oracle/dba/dba25/dbs/sample01.dbf
5
QUERY_DATA /oracle/dba/dba25/dbs/querydata01.dbf
6
6 rows selected.
SQL>
2. 온라인 백업 실시
SQL> alter tablespace sample begin backup;
Tablespace altered.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 ACTIVE 276874 06-NOV-08
6 NOT ACTIVE 0
6 rows selected.
SQL> !cp $HOME/dbs/sample01.dbf $HOME/DEMO/.
SQL> alter tablespace sample end backup;
Tablespace altered.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 276874 06-NOV-08
6 NOT ACTIVE 0
6 rows selected.
SQL>
3. 데이터 입력 및 로그 스위치
SQL> insert into scott.dept select * from scott.dept;
8 rows created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
16
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL>
4. 장애 상황 유도
SQL> !rm $HOME/dbs/sample01.dbf
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
5. 데이터 베이스 재시작
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/oracle/dba/dba25/dbs/sample01.dbf'
6. 백업 시점에 따른 roll-forward 적용 숫자에 대한 논의
SQL> !cp $HOME/BACKUP/sample01.dbf $HOME/dbs/.
SQL> select * from v$recovery_log;
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 105 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_105.arc
1 106 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_106.arc
1 107 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_107.arc
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 108 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_108.arc
1 109 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_109.arc
1 110 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_110.arc
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 111 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_111.arc
1 112 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_112.arc
1 113 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_113.arc
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 114 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_114.arc
1 115 06-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_115.arc
11 rows selected.
SQL> select count(*) from v$recovery_log;
COUNT(*)
----------
11
SQL> !cp $HOME/DEMO/sample01.dbf $HOME/dbs/.
SQL> select count(*) from v$recovery_log;
COUNT(*)
----------
11
SQL> !cp $HOME/DEMO/sample01.dbf $HOME/dbs/.
SQL> select count(*) from v$recovery_log;
COUNT(*)
----------
2
7. 데이터 베이스 복구 시나리오.
SQL> recover automatic database;
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
16
SQL>
특정한 datafile을 지울 경우의 시나리오.
db startup > 컨트롤 파일을 읽고 MOUNT 상태로 전이 > 컨트롤 파일의 내용을 바탕으로 datafile 의 존재 유무와 시점 정보를 확인 (한 개의 파일만 조사하는게 아니라 전체 파일을 조사함) > 검출된 에러 파일 중 한 개의 파일을 에러 메시지로 출력하고, 검출된 복구 필요 파일을 v$recovery_log 에 저장한다.
DBA에 의해서 복구를 실시하는 경우의 시나리오
recovery 명령어 > 현재 online redo logfile 에 복원에 필요한 내용이 존재하는지를 조사 > 존재하지 않는 logseq의 내용은 아카이브 로그에서 얻을 수 있는지를 확인하여 메시지로 출력 (온라인 로그에 존재하는 내용은 출력되지 않는다)
※ 장애가 발생한 시점에서는 어떤 로그 파일이 복구에 필요한지는 알 수 없다. 해당 파일의 logseq를 확인할 수 있는 시점은 기본적인 restore를 실시한 이후에만 가능하다.
컨트롤 파일의 백업
a) alter database backup controlfile to ‘/BACKUP/ctrl01.bak’;
b) alter database backup controlfile to trace;
컨트롤 파일 역시도 데이터 파일과 마찬가지로 시점정보의 기록을 중지시켜서 안정적인 헤더 정보를 가진채로 행해야 하기 때문에 위의 명령어를 써야함. a) 명령어의 경우 헤더 정보를 고정시킨채로 복사한다는 점을 제외하면 cp 명령어로 해당 파일을 복사하는 것과 유사하고, b) 명령어의 경우 user_dump_dest 에 *.trc 파일로 생성한다는 점이 다르다.
트레이스 파일의 형태
dumpfile ...
create controlfile ~~
…
파일의 크기는 컨트롤 파일을 직접 백업하는 것이 트레이스 파일을 유지하는 것보다 크다는 사실에 유의
1. 컨트롤 파일 백업 수행 (직접 파일 복사) – 절대로 cp를 이용한 백업을 해서는 시점정보를 유지할 수 없다.
SQL> alter database backup controlfile to '$HOME/DEMO/c.bak';
Database altered.
SQL> !ls -al $HOME/dbs/*.ctl
-rwxrwx--- 1 dba25 dba 1011712 Nov 6 09:51 /oracle/dba/dba25/dbs/ctrl01.ctl
-rwxr-x--- 1 dba25 dba 1011712 Nov 6 09:51 /oracle/dba/dba25/dbs/ctrl02.ctl
SQL> !ls -al $HOME/DEMO/*.bak
-rw-r----- 1 dba25 dba 1011712 Nov 6 09:50 /oracle/dba/dba25/DEMO/c.bak
2. 컨트롤 파일 백업 수행 (트레이스 파일 생성)
SQL> show parameter user_dump_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
user_dump_dest string $ORACLE_HOME/ADMIN/UDUMP
SQL> alter database backup controlfile to trace;
Database altered.
SQL> !rm $HOME/ADMIN/UDUMP/*
SQL> alter database backup controlfile to trace;
Database altered.
SQL> !ls -al $HOME/ADMIN/UDUMP/
total 18
drwxrwxr-x 2 dba25 dba 1536 Nov 6 09:55 .
drwxrwxr-x 7 dba25 dba 512 Aug 31 2003 ..
-rw-r----- 1 dba25 dba 5435 Nov 6 09:55 dba25_ora_12157.trc
SQL> !vi $ORACLE_HOME/ADMIN/UDUMP/*.trc
…
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBA25" NORESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 32
MAXLOGMEMBERS 3
MAXDATAFILES 40
MAXINSTANCES 1
MAXLOGHISTORY 113
…
데이터베이스 백업본의 검증
dbv : 데이터베이스의 백업본의 손상여부를 검증. 백업 파일 및 운영중인 online 파일의 검증에도 이용가능함.
1. 현재 운영중인 온라인 파일에 대한 dbv 작업 (start, end 옵션이 없는 경우라면 전체 블록에 대한 검증 실시)
dba25@sun02-zone:/oracle/dba/dba25/dbs] dbv file=./sample01.dbf blocksize=4096
DBVERIFY: Release 9.2.0.1.0 - Production on Thu Nov 6 10:00:52 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
DBVERIFY - Verification starting : FILE = ./sample01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 2560
Total Pages Processed (Data) : 4
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 21
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 2535
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
2. 백업 본에 대한 dbv 작업
dba25@sun02-zone:/oracle/dba/dba25/dbs] dbv file=../BACKUP/system01.dbf blocksize=4096
DBVERIFY: Release 9.2.0.1.0 - Production on Thu Nov 6 10:02:27 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
DBVERIFY - Verification starting : FILE = ../BACKUP/system01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 25600
Total Pages Processed (Data) : 15576
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 3505
Total Pages Failing (Index): 0
Total Pages Processed (Other): 1313
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 5206
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
dba25@sun02-zone:/oracle/dba/dba25/dbs]
dbv는 데이터 파일의 내부적인 블록을 하나씩 순회하면서 검증하는 유틸리티임. start, end 옵션을 이용하면 검증할 블록의 영역을 지정해서 하는 것이 가능하다.
복구 작업 수행시 동기화
데이터베이스를 열기 위해서는 모든 데이터파일을 동기화 해야한다.
동기화는 체크 포인트 번호를 기반으로 한다.
(특정 파일을 오프라인으로 만들면 동기화에서 열외시켜서 오픈 가능함)
복구 정보를 제공하는 VIEW
v$recover_file : 장애 발생 파일 확인
v$recovery_log : 복구에 사용할 아카이브 로그 파일 정보 확인
v$archived_log : 생성된 아카이브 로그파일 정보 확인
백업본이 없는 상태에서의 복구
파일 생성 시간 이후 모든 아카이브 로그 파일이 있다면 복구 가능하지만, 그렇지 않다면 복구는 불가능하다.
alter database create datafile ‘/DISK1/c.dbf’;
; 우선 해당 명령어를 수행하면 DBMS는 해당 데이터베이스의 컨트롤 파일을 조사하여, 해당 파일을 일단 디스크상에 생성한다.
※ 문제는 이 방식으로 복구할 경우 생성 시점이 오래된 DB의 경우라면 복구에 걸리는 시간이 상상을 초월하기 때문에 가능하면 백업 파일을 기반으로 복구하는 방식을 취하는 것이 좋다.
1. 테스트용 테이블 스페이스 확인
SQL> create tablespace dtbs datafile '$HOME/dbs/d.dbf' size 5m;
Tablespace created.
2. 각 파일의 생성 시간 확인
SQL> alter session set nls_date_format='yy-mm-dd hh24:mi:ss';
Session altered.
SQL> select name, creation_time from v$datafile;
NAME
--------------------------------------------------------------------------------
CREATION_TIME
-----------------
/oracle/dba/dba25/dbs/system01.dbf
03-08-31 16:03:53
/oracle/dba/dba25/dbs/undotbs.dbf
03-08-31 16:04:17
/oracle/dba/dba25/dbs/users01.dbf
03-08-31 16:04:31
NAME
--------------------------------------------------------------------------------
CREATION_TIME
-----------------
/oracle/dba/dba25/dbs/indx01.dbf
03-08-31 16:04:32
/oracle/dba/dba25/dbs/sample01.dbf
03-08-31 16:04:32
/oracle/dba/dba25/dbs/querydata01.dbf
03-08-31 16:04:33
NAME
--------------------------------------------------------------------------------
CREATION_TIME
-----------------
/oracle/dba/dba25/dbs/d.dbf
08-11-06 10:33:50
7 rows selected.
3. 임시 테이블 생성
SQL> create table d1 tablespace dtbs as select * from scott.dept;
Table created.
SQL> select count(*) from d1;
COUNT(*)
----------
16
4. 해당 테이블 스페이스 공간의 데이터 작업 실시
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
5. 장애 만들어서 복구하기
SQL> !rm $HOME/dbs/d.dbf
SQL> shutdown abort;
ORACLE instance shut down.
6. 디비 기동 및 에러 확인 및 에러 파일 offline 상태 전환
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/dba/dba25/dbs/d.dbf'
SQL> alter database datafile '$HOME/dbs/d.dbf' offline;
Database altered.
SQL> alter database open;
Database altered.
7. 해당 테이블 스페이스 내 데이터 조회
SQL> select * from d1;
select * from d1
*
ERROR at line 1:
ORA-00376: file 7 cannot be read at this time
ORA-01110: data file 7: '/oracle/dba/dba25/dbs/d.dbf'
8. 백업본이 없는 경우의 데이터 파일 새로 생성하기
SQL> !ls $HOME/dbs/d.dbf
/oracle/dba/dba25/dbs/d.dbf: No such file or directory
SQL> alter database create datafile '$HOME/dbs/d.dbf';
Database altered.
SQL> !ls $HOME/dbs/d.dbf
/oracle/dba/dba25/dbs/d.dbf
SQL>
9. 해당 테이블 스페이스 online 전환 및 복구
SQL> alter database datafile '$HOME/dbs/d.dbf' online;
alter database datafile '$HOME/dbs/d.dbf' online
*
ERROR at line 1:
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '/oracle/dba/dba25/dbs/d.dbf'
SQL> recover automatic tablespace dtbs;
Media recovery complete.
SQL> alter database datafile '$HOME/dbs/d.dbf' online;
Database altered.
SQL> select count(*) from d1;
COUNT(*)
----------
16
10. 리커버 필요 파일 조사 및 아카이브 로그 삭제 (실습 환경에 디스크가 모자라서;;)
SQL> select * from v$recover_file;
no rows selected
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !rm $HOME/ORADATA/ARCHIVE1/*.*
SQL> !rm $HOME/ORADATA/ARCHIVE2/*.*
SQL>
특정 시점으로 DB를 변경
※ 실재 가동계에서 이렇게 불완전 복구를 행하는 경우는 없다.
a) 모든 datafile restore를 해야 가능함.
b) recover database until time ‘XXXX’
c) alter database open resetlogs;
불안정 복구인지 확인. 데이터 파일의 시점이 모두 동일한지 확인.
alter database open : control, data, rdo log 등 모든 데이터베이스 파일의 시점정보가 같아야지만 오픈이 가능함.
아카이브 로그 모드의 불완전 복구는 과거 특정 시점으로 DB를 복구하는 것을 말한다.
불완전 복구 결정시 한 개의 데이터 파일만 복구되는 것이 아니라 모든 데이터 파일을 과거의 시점으로 돌리는 것
만약 모든 데이터 베이스 파일을 복사한 경우라면 특정 시점으로 roll-forward는 불가.
불완전 복구는 모든 파일에 대한 적용을 원칙으로 하기 때문에 MOUNT단계에서만 가능함.
recover database until time ‘yyyy-mm-dd:hh:mmi:ss’;
recover database until cancel;
recover database until change scn#;
1. 데이터 베이스 내용 변경 및 사전 작업
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
Database opened.
SQL> insert into scott.dept select * from scott.dept;
16 rows created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> !date
Thu Nov 6 11:13:25 KST 2008
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
2. 테이블 드랍 사전작업
SQL> drop table scott.dept;
Table dropped.
SQL> alter system switch logfile;
System altered.
3. 잘못된 방법으로 복원 시작 (불완전 복구시에는 한 개의 dbf파일만으로는 DB를 열수 없다)
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
SQL> !cp $HOME/BACKUP/sample01.dbf $HOME/dbs/.
SQL> recover database until time '2008-11-06:11:14:23';
ORA-00279: change 319154 generated at 11/06/2008 10:47:02 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_123.arc
ORA-00280: change 319154 for thread 1 is in sequence #123
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/oracle/dba/dba25/dbs/system01.dbf'
ORA-01112: media recovery not started
4. 정상적인 불완전 복구 수행
SQL> !cp $HOME/BACKUP/*.dbf $HOME/dbs/.
SQL> recover database until time '2008-11-06:11:13:25';
ORA-00279: change 319154 generated at 11/06/2008 10:47:02 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_123.arc
ORA-00280: change 319154 for thread 1 is in sequence #123
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
Log applied.
Media recovery complete.
SQL>
5. 데이터베이스 시작 및 복구 결과 확인
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE # BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 0 5242880 2 YES UNUSED
0
2 1 1 5242880 2 NO CURRENT
319341 06-NOV-08
3 1 0 256000 2 YES UNUSED
0
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL>
불완전 복구를 수행하고 데이터베이스를 열었을 경우에는 반드시 데이터베이스를 백업 받아야한다.
북완전 복구 시점의 시점 정보 상태
CTRL, RDO : LOGSEQ 70
DATA : LOGSEQ 65
alter database open resetlogs 이후의 시점 정보 상태
CTRL, DATA : LOGSEQ 1
RDO : 한 개의 그룹에만 1을 부여하고, 나머지에는 모두 0으로 부여
CTRL, DATA 파일의 헤더에는 리셋을 한 시점에 대한 정보가 들어있다.
문제는 이후에 해당 DB가 장애가 나서 복구를 한 경우라면 리셋후에 백업을 하지 않았을 경우에는
컨트롤 파일과 LOGSEQ가 다른 백업본으로 복구를 해야하는데, 이때 리셋 시간이 맞지 않으면 DB가 열리지 않는다.
1. 파일 헤더에 저장된 리셋 시간 정보
SQL> select file#, resetlogs_time from v$datafile_header;
FILE# RESETLOGS
---------- ---------
1 06-NOV-08
2 06-NOV-08
3 06-NOV-08
4 06-NOV-08
5 06-NOV-08
6 06-NOV-08
7 06-NOV-08
7 rows selected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !cp $HOME/dbs/*.* $HOME/BACKUP/.
1. RDO 로그 파일 장애
2. A) CURRENT 아닌 그룹 장애
3. 현재 로그 그룹 중 가장 LOGSEQ가 큰 그룹을 current 로그라고 생각하면 된다.
4. 로그 그룹이 다중 멤버를 사용해서 이중화시킬 경우 한 개의 파일에 문제가 생기더라도 문제가 발생하지는 않음
5.
6. 해결안: DROP and RECREATE
7. drop logfile group #; add logfile group #
8. alter database clear logfile group #;
9.
10. 문제는 현재 drop 하려고 하는 로그 파일이 아카이빙 안된 경우에는 에러를 발생
11. alter database clear unarchived logfile group #
12. (이런 경우 아카이브 로그의 로그 번호 중간이 비기 때문에 반드시 전체 백업을 수행해야한다.)
1. 로그 파일 생성 및 사전 처리
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> select member from v$logfile where group# in (select group# from v$log where status='INACTIVE');
MEMBER
--------------------------------------------------------------------------------
/oracle/dba/dba25/dbs/log01a.rdo
/oracle/dba/dba25/dbs/log1b.rdo
/oracle/dba/dba25/dbs/log02a.rdo
/oracle/dba/dba25/dbs/log2b.rdo
SQL> !rm /oracle/dba/dba25/dbs/log01a.rdo
SQL> !rm /oracle/dba/dba25/dbs/log1b.rdo
SQL> !rm /oracle/dba/dba25/dbs/log02a.rdo
SQL> !rm /oracle/dba/dba25/dbs/log2b.rdo
SQL> shutdown abort;
ORACLE instance shut down.
2. non-current 데이터베이스 장애 복구
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/oracle/dba/dba25/dbs/log01a.rdo'
ORA-00312: online log 1 thread 1: '/oracle/dba/dba25/dbs/log1b.rdo'
SQL> alter database clear logfile group 1;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log02a.rdo'
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log2b.rdo'
SQL> alter database clear logfile group 2;
Database altered.
SQL> alter database open;
Database altered.
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
13.
B) CURRENT 그룹 장애 (105P~107P)
1. 데이터 입력 및 사전 작업
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL> alter system switch logfile;
System altered.
SQL> insert into scott.dept select * from scott.dept;
32 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
64
2. 장애 발생
SQL> select member from v$logfile where group# in (select group# from v$log where status='CURRENT');
MEMBER
--------------------------------------------------------------------------------
/oracle/dba/dba25/dbs/log02a.rdo
/oracle/dba/dba25/dbs/log2b.rdo
SQL> !rm /oracle/dba/dba25/dbs/log02a.rdo
SQL> !rm /oracle/dba/dba25/dbs/log2b.rdo
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log2b.rdo'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log02a.rdo'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
SQL> alter database clear logfile group 2;
alter database clear logfile group 2
*
ERROR at line 1:
ORA-01624: log 2 needed for crash recovery of thread 1
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log02a.rdo'
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log2b.rdo'
불완전 복구 이용해서 datafile 시점 일치시키도록 유도
(커런트 파일의 장애가 난 경우라면 특정 데이터는 커밋이 된 상태이기도 하고, 아닌 것도 잇을 수 있기 때문에 시점을 일치시키는 작업이 필요하다)
SQL> !cp $HOME/BACKUP/*.dbf $HOME/dbs/.
SQL> recover database until cancel;
ORA-00279: change 319976 generated at 11/06/2008 11:48:56 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_1.arc
ORA-00280: change 319976 for thread 1 is in sequence #1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 320081 generated at 11/06/2008 13:21:43 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc
ORA-00280: change 320081 for thread 1 is in sequence #2
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_1.arc' no longer
needed for this recovery
ORA-00279: change 320099 generated at 11/06/2008 13:22:37 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc
ORA-00280: change 320099 for thread 1 is in sequence #3
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc' no longer
needed for this recovery
ORA-00279: change 320106 generated at 11/06/2008 13:22:53 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc
ORA-00280: change 320106 for thread 1 is in sequence #4
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc' no longer
needed for this recovery
ORA-00279: change 320108 generated at 11/06/2008 13:22:53 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc
ORA-00280: change 320108 for thread 1 is in sequence #5
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc' no longer
needed for this recovery
ORA-00279: change 320110 generated at 11/06/2008 13:22:58 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 320110 for thread 1 is in sequence #6
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc' no longer
needed for this recovery
ORA-00279: change 340112 generated at 11/06/2008 13:26:19 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc
ORA-00280: change 340112 for thread 1 is in sequence #7
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc' no longer
needed for this recovery
ORA-00279: change 340287 generated at 11/06/2008 13:29:52 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc
ORA-00280: change 340287 for thread 1 is in sequence #8
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc' no longer
needed for this recovery
ORA-00308: cannot open archived log
'/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
SQL> !ls -lrt /oracle/dba/dba25/ORADATA/ARCHIVE2
total 468
-rw-r----- 1 dba25 dba 86528 Nov 6 11:12 arch_123.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 11:13 arch_124.arc
-rw-r----- 1 dba25 dba 12288 Nov 6 11:15 arch_125.arc
-rw-r----- 1 dba25 dba 91648 Nov 6 13:21 arch_1.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:22 arch_2.arc
-rw-r----- 1 dba25 dba 2048 Nov 6 13:22 arch_3.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:22 arch_4.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:22 arch_5.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:26 arch_6.arc
-rw-r----- 1 dba25 dba 40448 Nov 6 13:29 arch_7.arc
SQL> !ls $HOME/dbs/*.rdo
/oracle/dba/dba25/dbs/log01a.rdo /oracle/dba/dba25/dbs/log3a.rdo
/oracle/dba/dba25/dbs/log1b.rdo /oracle/dba/dba25/dbs/log3b.rdo
SQL> alter database open resetlogs;
Database altered.
SQL> !ls $HOME/dbs/*.rdo
/oracle/dba/dba25/dbs/log01a.rdo /oracle/dba/dba25/dbs/log1b.rdo /oracle/dba/dba25/dbs/log3a.rdo
/oracle/dba/dba25/dbs/log02a.rdo /oracle/dba/dba25/dbs/log2b.rdo /oracle/dba/dba25/dbs/log3b.rdo
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !cp $HOME/dbs/*.* $HOME/BACKUP/.
SQL>
컨트롤 파일 장애 (110P ~ 111P)
A) 여러 개중 일부만 장애
유효한 파일을 복사만 해주면 완료
B) 모든 CTRL 파일 장애 (그 외 데이터 파일 및 리두 파일 정상)
create control file 명령으로 생성 가능
모든 데이터 파일 및 리두 로그 파일의 이름을 알고 있어야 사용 가능함.
to trace 받은 백업 파일을 이용하는게 좋다.
C) 모든 CTRL 파일 및 데이터, 리두 파일 손상
백업 파일 restore 후 복구 수행
+ control file 시점 동기화 필요 : recover database using backup controlfile
(아카이브 rdo 로그를 읽어서 컨트롤 파일의 정보도 갱신하는 옵션)
※ 문제는 이 옵션으로 복구를 할 경우 복구 툴이 자동으로 리두 로그를 인식하지 못하기 때문에 DBA에 의해서 수동으로 로그를 지정하면서 작업을 진행해야함. (아카이브 이름, 위치 이름, currnet 리두 파일의 위치 및 이름 입력)
1. 컨트롤 파일 트레이스 백업본 작성
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
Database opened.
SQL> alter system set user_dump_dest='$HOME/DEMO';
System altered.
SQL> alter database backup controlfile to trace;
Database altered.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 – Production
2. 복구용 트레이스 파일 추출
dba25@sun02-zone:/oracle/dba/dba25/dbs] cd $HOME/DEMO
dba25@sun02-zone:/oracle/dba/dba25/DEMO] ls
c.bak dba25_ora_15999.trc sample01.dbf
dba25@sun02-zone:/oracle/dba/dba25/DEMO] cat *.trc
…
# Set #1. NORESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# Data used by the recovery manager will be lost. Additional logs may
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBA25" NORESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 32
MAXLOGMEMBERS 3
MAXDATAFILES 40
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 (
'/oracle/dba/dba25/dbs/log01a.rdo',
'/oracle/dba/dba25/dbs/log1b.rdo'
) SIZE 5M,
GROUP 2 (
'/oracle/dba/dba25/dbs/log02a.rdo',
'/oracle/dba/dba25/dbs/log2b.rdo'
) SIZE 5M,
GROUP 3 (
'/oracle/dba/dba25/dbs/log3a.rdo',
'/oracle/dba/dba25/dbs/log3b.rdo'
) SIZE 250K
-- STANDBY LOGFILE
DATAFILE
'/oracle/dba/dba25/dbs/system01.dbf',
'/oracle/dba/dba25/dbs/undotbs.dbf',
'/oracle/dba/dba25/dbs/users01.dbf',
'/oracle/dba/dba25/dbs/indx01.dbf',
'/oracle/dba/dba25/dbs/sample01.dbf',
'/oracle/dba/dba25/dbs/querydata01.dbf',
'/oracle/dba/dba25/dbs/d.dbf'
CHARACTER SET US7ASCII
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# Database can now be opened normally.
ALTER DATABASE OPEN;
# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/user4/dba25/dbs/temp01.dbf' REUSE;
# End of tempfile additions.
#
# Set #2. RESETLOGS case
…
상기의 내용만을 추출해서 c.sql로 저장
3. 장애 발생
dba25@sun02-zone:/oracle/dba/dba25/DEMO] sqlplus '/as sysdba'
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Nov 6 14:44:14 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> alter system switch logfile;
System altered.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/oracle/dba/dba25/dbs/ctrl01.ctl
/oracle/dba/dba25/dbs/ctrl02.ctl
SQL> !rm $HOME/dbs/*.ctl
4. 데이터베이스 셧다운 및 재실행
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
ORA-00205: error in identifying controlfile, check alert log for more info
SQL> select status from v$instance;
STATUS
------------
STARTED
5. 컨트롤 파일 새로 생성 복구 수행
SQL> shutdown abort;
ORACLE instance shut down.
SQL> @ $HOME/DEMO/c.sql;
SP2-0158: unknown SET option "#1."
SP2-0734: unknown command beginning "The follow..." - rest of line ignored.
SP2-0734: unknown command beginning "to open th..." - rest of line ignored.
SP2-0734: unknown command beginning "Data used ..." - rest of line ignored.
SP2-0734: unknown command beginning "be require..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "only if th..." - rest of line ignored.
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Control file created.
SP2-0734: unknown command beginning "Recovery i..." - rest of line ignored.
SP2-0734: unknown command beginning "or if the ..." - rest of line ignored.
Media recovery complete.
SP2-0734: unknown command beginning "All logs n..." - rest of line ignored.
System altered.
SP2-0734: unknown command beginning "Database c..." - rest of line ignored.
Database altered.
SP2-0734: unknown command beginning "Commands t..." - rest of line ignored.
SP2-0734: unknown command beginning "Online tem..." - rest of line ignored.
SP2-0734: unknown command beginning "Other temp..." - rest of line ignored.
ALTER TABLESPACE TEMP ADD TEMPFILE '/user4/dba25/dbs/temp01.dbf' REUSE
*
ERROR at line 1:
ORA-01119: error in creating database file '/user4/dba25/dbs/temp01.dbf'
ORA-17610: file '/user4/dba25/dbs/temp01.dbf' does not exist and no size
specified
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
실습 환경이 다른 서버에서 복사 해온 경우라서 디렉토리가 다르다.
SP2-0734: unknown command beginning "End of tem..." - rest of line ignored.
SQL> alter tablespace temp add tempfile '$HOME/dbs/temp02.dbf' size 10m;
Tablespace altered.
SQL> !ls $HOME/dbs/*.ctl
/oracle/dba/dba25/dbs/ctrl01.ctl /oracle/dba/dba25/dbs/ctrl02.ctl
컨트롤 파일 생성 확인
6. 경고파일의 내용 확인하기
SQL> !rm $HOME/ADMIN/BDUMP/*.*;
파일의 내용이 너무 많기 때문에 현재의 로그 내용을 없앤다.
SQL> alter system switch logfile;
System altered.
SQL> !vi $HOME/ADMIN/BDUMP/*.log
Thu Nov 6 14:52:35 2008
Thread 1 advanced to log sequence 6
Thu Nov 6 14:52:35 2008
Current log# 3 seq# 6 mem# 0: /oracle/dba/dba25/dbs/log3a.rdo
Thu Nov 6 14:52:35 2008
ARC0: Evaluating archive log 1 thread 1 sequence 5
Current log# 3 seq# 6 mem# 1: /oracle/dba/dba25/dbs/log3b.rdo
Thu Nov 6 14:52:35 2008
ARC0: Beginning to archive log 1 thread 1 sequence 5
Creating archive destination LOG_ARCHIVE_DEST_2: '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc'
Creating archive destination LOG_ARCHIVE_DEST_1: '/oracle/dba/dba25/ORADATA/ARCHIVE1/arch_5.arc'
ARC0: Completed archiving log 1 thread 1 sequence 5
7. controlfile 장애 만들기
SQL> !rm $HOME/dbs/*.ctl
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
ORA-00205: error in identifying controlfile, check alert log for more info
8. 컨트롤 파일 복구하기
SQL> alter database mount;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/oracle/dba/dba25/dbs/system01.dbf'
ORA-01207: file is more recent than controlfile - old controlfile
컨트롤 파일의 시점 데이터가 데이터 파일의 그것 보다 더 빠르기 때문에…
9. 컨트롤 파일 시점 변경
SQL> recover database using backup controlfile;
ORA-00279: change 340776 generated at 11/06/2008 14:11:26 needed for thread 1
컨트롤 파일의 정보가 불충분하기 때문에 suggest 가 비정상적으로 동작함.
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00266: name of archived log file needed
SQL> !ls -ltr $HOME/ORADATA/ARCHIVE1
total 548
-rw-r----- 1 dba25 dba 86528 Nov 6 11:12 arch_123.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 11:13 arch_124.arc
-rw-r----- 1 dba25 dba 12288 Nov 6 11:15 arch_125.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:26 arch_6.arc
-rw-r----- 1 dba25 dba 40448 Nov 6 13:29 arch_7.arc
-rw-r----- 1 dba25 dba 90112 Nov 6 14:44 arch_1.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 14:47 arch_2.arc
-rw-r----- 1 dba25 dba 2048 Nov 6 14:47 arch_3.arc
-rw-r----- 1 dba25 dba 2560 Nov 6 14:47 arch_4.arc
-rw-r----- 1 dba25 dba 41984 Nov 6 14:52 arch_5.arc
SQL> recover database using backup controlfile;
ORA-00279: change 340776 generated at 11/06/2008 14:11:26 needed for thread 1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
$HOME/ORADATA/ARCHIVE1/arch_1.arc
ORA-00279: change 341101 generated at 11/06/2008 14:44:20 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc
ORA-00280: change 341101 for thread 1 is in sequence #2
ORA-00278: log file '$HOME/ORADATA/ARCHIVE1/arch_1.arc' no longer needed for
this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 341107 generated at 11/06/2008 14:44:36 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc
ORA-00280: change 341107 for thread 1 is in sequence #3
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 341110 generated at 11/06/2008 14:44:38 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc
ORA-00280: change 341110 for thread 1 is in sequence #4
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 361115 generated at 11/06/2008 14:47:57 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc
ORA-00280: change 361115 for thread 1 is in sequence #5
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 361370 generated at 11/06/2008 14:52:35 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 361370 for thread 1 is in sequence #6
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00328: archived log ends at change 340111, need later change 361370
ORA-00334: archived log: '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc'
이 이후는 아카이브 로그로 만들어진 내용이 아니기 때문에 적용이 불가능.
SQL> recover database using backup controlfile;
ORA-00279: change 361370 generated at 11/06/2008 14:52:35 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 361370 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
$HOME/dbs/log3.ardo
ORA-00308: cannot open archived log '$HOME/dbs/log3.ardo'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
$HOME/dbs/log3a.rdo
alert_SID.log 의 내용을 가지고 파악해서 복구한다.
Log applied.
Media recovery complete.
SQL>
컨트롤파일, 데이터파일, 로그파일 모두 장애 발생시
a) 우선 MOUNT 시점으로 올려야하기 때문에 컨트롤 파일 올려야함.
b) 데이터 파일 백업본을 복사한다. (리두 로그의 경우 복사를 할 경우 정상상태로 인식하기 때문에 복사해서는 안됀다. )
c) recover database using backup controlfile until cancel
d) alter database open resetlog; 를 이용해서 장애난 redo logfile 을 재생성
1. 사전 작업
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> create table t7 as select * from scott.dept;
Table created.
SQL> insert into t7 select * from t7;
32 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from t7;
COUNT(*)
----------
64
SQL> alter system switch logfile;
SQL> /
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 5 5242880 2 NO CURRENT
361693 06-NOV-08
2 1 4 5242880 2 YES INACTIVE
361691 06-NOV-08
3 1 3 256000 2 YES INACTIVE
361667 06-NOV-08
SQL>
2. 장애 생성하기
SQL> !rm $HOME/dbs/*.ctl
SQL> !rm $HOME/dbs/*.rdo
SQL> !rm $HOME/dbs/*.dbf
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
내가 풀이했던 장애 복구 시나리오.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
ORA-00205: error in identifying controlfile, check alert log for more info
SQL> !cp $HOME/BACKUP/*.ctl $HOME/dbs/.
SQL> alter database mount;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/oracle/dba/dba25/dbs/system01.dbf'
SQL> !cp $HOME/BACKUP/*.dbf $HOME/dbs/.
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required
SQL> recover database using backup controlfile until cancel;
만약 이때 특정한 한 개의 파일이 복구가 안돼는 경우라면 최초 백업이 온라인 상태에서 행해진 것이 아닌지 의심해본다.
ORA-00279: change 402511 generated at 11/06/2008 18:51:47 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 402511 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 402610 generated at 11/06/2008 18:52:22 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc
ORA-00280: change 402610 for thread 1 is in sequence #7
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc' no longer
needed for this recovery
ORA-00279: change 402612 generated at 11/06/2008 18:52:23 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc
ORA-00280: change 402612 for thread 1 is in sequence #8
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc' no longer
needed for this recovery
ORA-00279: change 402636 generated at 11/06/2008 18:52:43 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_9.arc
ORA-00280: change 402636 for thread 1 is in sequence #9
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc' no longer
needed for this recovery
ORA-00279: change 402638 generated at 11/06/2008 18:52:47 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_10.arc
ORA-00280: change 402638 for thread 1 is in sequence #10
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_9.arc' no longer
needed for this recovery
ORA-00308: cannot open archived log
'/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_10.arc'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
SQL> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
컨트롤 파
백업 및 복구 문제
MTBFMeanTimeBetweenFailures : 장애 사이의 간격
MTTRMeanTimeBetweenRecover : 장애 복구 시간
데이터베이스 장애 유형
문장오류
권한 불충분, 공간 불충분, 응용 프로그램 오류, 잘못된 데이터 입력, 할당량 부족
-> 권한의 문제는 DBA가 직접 수행하지만 그 밖의 문제는 DBA가 할 수 없다.
사용자 실수
중요 테이블 DROP,
▶ 오라클 9i이전에는 휴지통의 개념이 없다.
사용자 프로세스 오류
인스턴스장애
오라클 서버 전원 OFF, 소프트웨어적인 문제 발생
▶ DBA가 할 수 있는 내용은 인스턴스를 재 시작하는 것뿐
Media 장애
물리적 디스크 에러
ALERT_SID.LOG 파일
데이터베이스 사용시 문제가 발생한 경우 로그가 기록되는 파일. (장애가 난 경우에 가장 먼저 보아야 하는 파일)
sartup, shutdown 정보
데이터베이스, 테이블 스페이스 생성변경삭제 작업 내역
recovery 관계 작업
logswitch 등의 DB 이벤트
DB 오류에 관한 오라클 에러 코드 및 메시지
온라인 백업의 순서
일반적으로 온라인 백업을 한다는 말은 CKPT에 의해서 controlfile, datafile 에서 유지되고 있는 시점정보가 모두 일치시켜야 한다는 것을 의미한다. 따라서 온라인 백업을 위해서는 ckpt가 일시적으로 시점정보를 유지하기 위한 마킹 작업을 막아야 함을 의미한다.
alter tablespace tablespacename begin backup;
이렇게 일시적으로 시점 일치화 작업을 중지시킨 후 DBA는 해당 DB 파일을 수동으로 복사해야 한다.
※ begin backup 이 복사 작업을 행하지 않는다는 사실에 유의. 설사 시점정보 기록작업을 멈추더라도 DBMS의 경우 DML작업은 메모리 상에서 행하기 때문에 사실상 작업은 모두 가능함.
READ ONLY 테이블 스페이스 백업
alter tablespace tablespacename read only;
Read only 가 해당 테이블스페이스에 지정된 이후로는 시점 정보의 갱신이 이루어 지지 않기 때문에 해당 테이블 스페이스의 저장 공간은 단순히 복사만 하더라도 백업이 가능하다. Read only 테이블의 장애가난 경우라면 controlfile 내에 등록된 read-only 시점과 파일내의 read-only 시점이 같은 경우라면 agree.
(컨트롤 파일에 read-only 시점에 대한 정보가 입력되며, 운영 중에 ckpt 작업을 중지하지 않더라도 바로 백업이 가능하다)
1. 데이터 베이스 접속 및 사전 작업
dba25@sun02-zone:/oracle/dba/dba25/dbs] sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Nov 6 08:56:18 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> col tablespace_name format a20
SQL> col file_name format a50
SQL> select tablespace_name, file_name, file_id from dba_data_files;
TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
FILE_ID
----------
SYSTEM /oracle/dba/dba25/dbs/system01.dbf
1
UNDOTBS /oracle/dba/dba25/dbs/undotbs.dbf
2
USERS /oracle/dba/dba25/dbs/users01.dbf
3
TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
FILE_ID
----------
INDX /oracle/dba/dba25/dbs/indx01.dbf
4
SAMPLE /oracle/dba/dba25/dbs/sample01.dbf
5
QUERY_DATA /oracle/dba/dba25/dbs/querydata01.dbf
6
6 rows selected.
SQL>
2. 온라인 백업 실시
SQL> alter tablespace sample begin backup;
Tablespace altered.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 ACTIVE 276874 06-NOV-08
6 NOT ACTIVE 0
6 rows selected.
SQL> !cp $HOME/dbs/sample01.dbf $HOME/DEMO/.
SQL> alter tablespace sample end backup;
Tablespace altered.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 276874 06-NOV-08
6 NOT ACTIVE 0
6 rows selected.
SQL>
3. 데이터 입력 및 로그 스위치
SQL> insert into scott.dept select * from scott.dept;
8 rows created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
16
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL>
4. 장애 상황 유도
SQL> !rm $HOME/dbs/sample01.dbf
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
5. 데이터 베이스 재시작
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/oracle/dba/dba25/dbs/sample01.dbf'
6. 백업 시점에 따른 roll-forward 적용 숫자에 대한 논의
SQL> !cp $HOME/BACKUP/sample01.dbf $HOME/dbs/.
SQL> select * from v$recovery_log;
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 105 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_105.arc
1 106 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_106.arc
1 107 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_107.arc
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 108 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_108.arc
1 109 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_109.arc
1 110 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_110.arc
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 111 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_111.arc
1 112 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_112.arc
1 113 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_113.arc
THREAD# SEQUENCE# TIME
---------- ---------- ---------
ARCHIVE_NAME
--------------------------------------------------------------------------------
1 114 05-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_114.arc
1 115 06-NOV-08
/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_115.arc
11 rows selected.
SQL> select count(*) from v$recovery_log;
COUNT(*)
----------
11
SQL> !cp $HOME/DEMO/sample01.dbf $HOME/dbs/.
SQL> select count(*) from v$recovery_log;
COUNT(*)
----------
11
SQL> !cp $HOME/DEMO/sample01.dbf $HOME/dbs/.
SQL> select count(*) from v$recovery_log;
COUNT(*)
----------
2
7. 데이터 베이스 복구 시나리오.
SQL> recover automatic database;
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
16
SQL>
특정한 datafile을 지울 경우의 시나리오.
db startup > 컨트롤 파일을 읽고 MOUNT 상태로 전이 > 컨트롤 파일의 내용을 바탕으로 datafile 의 존재 유무와 시점 정보를 확인 (한 개의 파일만 조사하는게 아니라 전체 파일을 조사함) > 검출된 에러 파일 중 한 개의 파일을 에러 메시지로 출력하고, 검출된 복구 필요 파일을 v$recovery_log 에 저장한다.
DBA에 의해서 복구를 실시하는 경우의 시나리오
recovery 명령어 > 현재 online redo logfile 에 복원에 필요한 내용이 존재하는지를 조사 > 존재하지 않는 logseq의 내용은 아카이브 로그에서 얻을 수 있는지를 확인하여 메시지로 출력 (온라인 로그에 존재하는 내용은 출력되지 않는다)
※ 장애가 발생한 시점에서는 어떤 로그 파일이 복구에 필요한지는 알 수 없다. 해당 파일의 logseq를 확인할 수 있는 시점은 기본적인 restore를 실시한 이후에만 가능하다.
컨트롤 파일의 백업
a) alter database backup controlfile to ‘/BACKUP/ctrl01.bak’;
b) alter database backup controlfile to trace;
컨트롤 파일 역시도 데이터 파일과 마찬가지로 시점정보의 기록을 중지시켜서 안정적인 헤더 정보를 가진채로 행해야 하기 때문에 위의 명령어를 써야함. a) 명령어의 경우 헤더 정보를 고정시킨채로 복사한다는 점을 제외하면 cp 명령어로 해당 파일을 복사하는 것과 유사하고, b) 명령어의 경우 user_dump_dest 에 *.trc 파일로 생성한다는 점이 다르다.
트레이스 파일의 형태
dumpfile ...
create controlfile ~~
…
파일의 크기는 컨트롤 파일을 직접 백업하는 것이 트레이스 파일을 유지하는 것보다 크다는 사실에 유의
1. 컨트롤 파일 백업 수행 (직접 파일 복사) – 절대로 cp를 이용한 백업을 해서는 시점정보를 유지할 수 없다.
SQL> alter database backup controlfile to '$HOME/DEMO/c.bak';
Database altered.
SQL> !ls -al $HOME/dbs/*.ctl
-rwxrwx--- 1 dba25 dba 1011712 Nov 6 09:51 /oracle/dba/dba25/dbs/ctrl01.ctl
-rwxr-x--- 1 dba25 dba 1011712 Nov 6 09:51 /oracle/dba/dba25/dbs/ctrl02.ctl
SQL> !ls -al $HOME/DEMO/*.bak
-rw-r----- 1 dba25 dba 1011712 Nov 6 09:50 /oracle/dba/dba25/DEMO/c.bak
2. 컨트롤 파일 백업 수행 (트레이스 파일 생성)
SQL> show parameter user_dump_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
user_dump_dest string $ORACLE_HOME/ADMIN/UDUMP
SQL> alter database backup controlfile to trace;
Database altered.
SQL> !rm $HOME/ADMIN/UDUMP/*
SQL> alter database backup controlfile to trace;
Database altered.
SQL> !ls -al $HOME/ADMIN/UDUMP/
total 18
drwxrwxr-x 2 dba25 dba 1536 Nov 6 09:55 .
drwxrwxr-x 7 dba25 dba 512 Aug 31 2003 ..
-rw-r----- 1 dba25 dba 5435 Nov 6 09:55 dba25_ora_12157.trc
SQL> !vi $ORACLE_HOME/ADMIN/UDUMP/*.trc
…
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBA25" NORESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 32
MAXLOGMEMBERS 3
MAXDATAFILES 40
MAXINSTANCES 1
MAXLOGHISTORY 113
…
데이터베이스 백업본의 검증
dbv : 데이터베이스의 백업본의 손상여부를 검증. 백업 파일 및 운영중인 online 파일의 검증에도 이용가능함.
1. 현재 운영중인 온라인 파일에 대한 dbv 작업 (start, end 옵션이 없는 경우라면 전체 블록에 대한 검증 실시)
dba25@sun02-zone:/oracle/dba/dba25/dbs] dbv file=./sample01.dbf blocksize=4096
DBVERIFY: Release 9.2.0.1.0 - Production on Thu Nov 6 10:00:52 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
DBVERIFY - Verification starting : FILE = ./sample01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 2560
Total Pages Processed (Data) : 4
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 21
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 2535
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
2. 백업 본에 대한 dbv 작업
dba25@sun02-zone:/oracle/dba/dba25/dbs] dbv file=../BACKUP/system01.dbf blocksize=4096
DBVERIFY: Release 9.2.0.1.0 - Production on Thu Nov 6 10:02:27 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
DBVERIFY - Verification starting : FILE = ../BACKUP/system01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 25600
Total Pages Processed (Data) : 15576
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 3505
Total Pages Failing (Index): 0
Total Pages Processed (Other): 1313
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 5206
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
dba25@sun02-zone:/oracle/dba/dba25/dbs]
dbv는 데이터 파일의 내부적인 블록을 하나씩 순회하면서 검증하는 유틸리티임. start, end 옵션을 이용하면 검증할 블록의 영역을 지정해서 하는 것이 가능하다.
복구 작업 수행시 동기화
데이터베이스를 열기 위해서는 모든 데이터파일을 동기화 해야한다.
동기화는 체크 포인트 번호를 기반으로 한다.
(특정 파일을 오프라인으로 만들면 동기화에서 열외시켜서 오픈 가능함)
복구 정보를 제공하는 VIEW
v$recover_file : 장애 발생 파일 확인
v$recovery_log : 복구에 사용할 아카이브 로그 파일 정보 확인
v$archived_log : 생성된 아카이브 로그파일 정보 확인
백업본이 없는 상태에서의 복구
파일 생성 시간 이후 모든 아카이브 로그 파일이 있다면 복구 가능하지만, 그렇지 않다면 복구는 불가능하다.
alter database create datafile ‘/DISK1/c.dbf’;
; 우선 해당 명령어를 수행하면 DBMS는 해당 데이터베이스의 컨트롤 파일을 조사하여, 해당 파일을 일단 디스크상에 생성한다.
※ 문제는 이 방식으로 복구할 경우 생성 시점이 오래된 DB의 경우라면 복구에 걸리는 시간이 상상을 초월하기 때문에 가능하면 백업 파일을 기반으로 복구하는 방식을 취하는 것이 좋다.
1. 테스트용 테이블 스페이스 확인
SQL> create tablespace dtbs datafile '$HOME/dbs/d.dbf' size 5m;
Tablespace created.
2. 각 파일의 생성 시간 확인
SQL> alter session set nls_date_format='yy-mm-dd hh24:mi:ss';
Session altered.
SQL> select name, creation_time from v$datafile;
NAME
--------------------------------------------------------------------------------
CREATION_TIME
-----------------
/oracle/dba/dba25/dbs/system01.dbf
03-08-31 16:03:53
/oracle/dba/dba25/dbs/undotbs.dbf
03-08-31 16:04:17
/oracle/dba/dba25/dbs/users01.dbf
03-08-31 16:04:31
NAME
--------------------------------------------------------------------------------
CREATION_TIME
-----------------
/oracle/dba/dba25/dbs/indx01.dbf
03-08-31 16:04:32
/oracle/dba/dba25/dbs/sample01.dbf
03-08-31 16:04:32
/oracle/dba/dba25/dbs/querydata01.dbf
03-08-31 16:04:33
NAME
--------------------------------------------------------------------------------
CREATION_TIME
-----------------
/oracle/dba/dba25/dbs/d.dbf
08-11-06 10:33:50
7 rows selected.
3. 임시 테이블 생성
SQL> create table d1 tablespace dtbs as select * from scott.dept;
Table created.
SQL> select count(*) from d1;
COUNT(*)
----------
16
4. 해당 테이블 스페이스 공간의 데이터 작업 실시
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
5. 장애 만들어서 복구하기
SQL> !rm $HOME/dbs/d.dbf
SQL> shutdown abort;
ORACLE instance shut down.
6. 디비 기동 및 에러 확인 및 에러 파일 offline 상태 전환
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/dba/dba25/dbs/d.dbf'
SQL> alter database datafile '$HOME/dbs/d.dbf' offline;
Database altered.
SQL> alter database open;
Database altered.
7. 해당 테이블 스페이스 내 데이터 조회
SQL> select * from d1;
select * from d1
*
ERROR at line 1:
ORA-00376: file 7 cannot be read at this time
ORA-01110: data file 7: '/oracle/dba/dba25/dbs/d.dbf'
8. 백업본이 없는 경우의 데이터 파일 새로 생성하기
SQL> !ls $HOME/dbs/d.dbf
/oracle/dba/dba25/dbs/d.dbf: No such file or directory
SQL> alter database create datafile '$HOME/dbs/d.dbf';
Database altered.
SQL> !ls $HOME/dbs/d.dbf
/oracle/dba/dba25/dbs/d.dbf
SQL>
9. 해당 테이블 스페이스 online 전환 및 복구
SQL> alter database datafile '$HOME/dbs/d.dbf' online;
alter database datafile '$HOME/dbs/d.dbf' online
*
ERROR at line 1:
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '/oracle/dba/dba25/dbs/d.dbf'
SQL> recover automatic tablespace dtbs;
Media recovery complete.
SQL> alter database datafile '$HOME/dbs/d.dbf' online;
Database altered.
SQL> select count(*) from d1;
COUNT(*)
----------
16
10. 리커버 필요 파일 조사 및 아카이브 로그 삭제 (실습 환경에 디스크가 모자라서;;)
SQL> select * from v$recover_file;
no rows selected
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !rm $HOME/ORADATA/ARCHIVE1/*.*
SQL> !rm $HOME/ORADATA/ARCHIVE2/*.*
SQL>
특정 시점으로 DB를 변경
※ 실재 가동계에서 이렇게 불완전 복구를 행하는 경우는 없다.
a) 모든 datafile restore를 해야 가능함.
b) recover database until time ‘XXXX’
c) alter database open resetlogs;
불안정 복구인지 확인. 데이터 파일의 시점이 모두 동일한지 확인.
alter database open : control, data, rdo log 등 모든 데이터베이스 파일의 시점정보가 같아야지만 오픈이 가능함.
아카이브 로그 모드의 불완전 복구는 과거 특정 시점으로 DB를 복구하는 것을 말한다.
불완전 복구 결정시 한 개의 데이터 파일만 복구되는 것이 아니라 모든 데이터 파일을 과거의 시점으로 돌리는 것
만약 모든 데이터 베이스 파일을 복사한 경우라면 특정 시점으로 roll-forward는 불가.
불완전 복구는 모든 파일에 대한 적용을 원칙으로 하기 때문에 MOUNT단계에서만 가능함.
recover database until time ‘yyyy-mm-dd:hh:mmi:ss’;
recover database until cancel;
recover database until change scn#;
1. 데이터 베이스 내용 변경 및 사전 작업
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
Database opened.
SQL> insert into scott.dept select * from scott.dept;
16 rows created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> !date
Thu Nov 6 11:13:25 KST 2008
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
2. 테이블 드랍 사전작업
SQL> drop table scott.dept;
Table dropped.
SQL> alter system switch logfile;
System altered.
3. 잘못된 방법으로 복원 시작 (불완전 복구시에는 한 개의 dbf파일만으로는 DB를 열수 없다)
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
SQL> !cp $HOME/BACKUP/sample01.dbf $HOME/dbs/.
SQL> recover database until time '2008-11-06:11:14:23';
ORA-00279: change 319154 generated at 11/06/2008 10:47:02 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_123.arc
ORA-00280: change 319154 for thread 1 is in sequence #123
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/oracle/dba/dba25/dbs/system01.dbf'
ORA-01112: media recovery not started
4. 정상적인 불완전 복구 수행
SQL> !cp $HOME/BACKUP/*.dbf $HOME/dbs/.
SQL> recover database until time '2008-11-06:11:13:25';
ORA-00279: change 319154 generated at 11/06/2008 10:47:02 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_123.arc
ORA-00280: change 319154 for thread 1 is in sequence #123
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
Log applied.
Media recovery complete.
SQL>
5. 데이터베이스 시작 및 복구 결과 확인
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE # BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 0 5242880 2 YES UNUSED
0
2 1 1 5242880 2 NO CURRENT
319341 06-NOV-08
3 1 0 256000 2 YES UNUSED
0
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL>
불완전 복구를 수행하고 데이터베이스를 열었을 경우에는 반드시 데이터베이스를 백업 받아야한다.
북완전 복구 시점의 시점 정보 상태
CTRL, RDO : LOGSEQ 70
DATA : LOGSEQ 65
alter database open resetlogs 이후의 시점 정보 상태
CTRL, DATA : LOGSEQ 1
RDO : 한 개의 그룹에만 1을 부여하고, 나머지에는 모두 0으로 부여
CTRL, DATA 파일의 헤더에는 리셋을 한 시점에 대한 정보가 들어있다.
문제는 이후에 해당 DB가 장애가 나서 복구를 한 경우라면 리셋후에 백업을 하지 않았을 경우에는
컨트롤 파일과 LOGSEQ가 다른 백업본으로 복구를 해야하는데, 이때 리셋 시간이 맞지 않으면 DB가 열리지 않는다.
1. 파일 헤더에 저장된 리셋 시간 정보
SQL> select file#, resetlogs_time from v$datafile_header;
FILE# RESETLOGS
---------- ---------
1 06-NOV-08
2 06-NOV-08
3 06-NOV-08
4 06-NOV-08
5 06-NOV-08
6 06-NOV-08
7 06-NOV-08
7 rows selected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !cp $HOME/dbs/*.* $HOME/BACKUP/.
1. RDO 로그 파일 장애
2. A) CURRENT 아닌 그룹 장애
3. 현재 로그 그룹 중 가장 LOGSEQ가 큰 그룹을 current 로그라고 생각하면 된다.
4. 로그 그룹이 다중 멤버를 사용해서 이중화시킬 경우 한 개의 파일에 문제가 생기더라도 문제가 발생하지는 않음
5.
6. 해결안: DROP and RECREATE
7. drop logfile group #; add logfile group #
8. alter database clear logfile group #;
9.
10. 문제는 현재 drop 하려고 하는 로그 파일이 아카이빙 안된 경우에는 에러를 발생
11. alter database clear unarchived logfile group #
12. (이런 경우 아카이브 로그의 로그 번호 중간이 비기 때문에 반드시 전체 백업을 수행해야한다.)
1. 로그 파일 생성 및 사전 처리
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> select member from v$logfile where group# in (select group# from v$log where status='INACTIVE');
MEMBER
--------------------------------------------------------------------------------
/oracle/dba/dba25/dbs/log01a.rdo
/oracle/dba/dba25/dbs/log1b.rdo
/oracle/dba/dba25/dbs/log02a.rdo
/oracle/dba/dba25/dbs/log2b.rdo
SQL> !rm /oracle/dba/dba25/dbs/log01a.rdo
SQL> !rm /oracle/dba/dba25/dbs/log1b.rdo
SQL> !rm /oracle/dba/dba25/dbs/log02a.rdo
SQL> !rm /oracle/dba/dba25/dbs/log2b.rdo
SQL> shutdown abort;
ORACLE instance shut down.
2. non-current 데이터베이스 장애 복구
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/oracle/dba/dba25/dbs/log01a.rdo'
ORA-00312: online log 1 thread 1: '/oracle/dba/dba25/dbs/log1b.rdo'
SQL> alter database clear logfile group 1;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log02a.rdo'
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log2b.rdo'
SQL> alter database clear logfile group 2;
Database altered.
SQL> alter database open;
Database altered.
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
13.
B) CURRENT 그룹 장애 (105P~107P)
1. 데이터 입력 및 사전 작업
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL> alter system switch logfile;
System altered.
SQL> insert into scott.dept select * from scott.dept;
32 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
64
2. 장애 발생
SQL> select member from v$logfile where group# in (select group# from v$log where status='CURRENT');
MEMBER
--------------------------------------------------------------------------------
/oracle/dba/dba25/dbs/log02a.rdo
/oracle/dba/dba25/dbs/log2b.rdo
SQL> !rm /oracle/dba/dba25/dbs/log02a.rdo
SQL> !rm /oracle/dba/dba25/dbs/log2b.rdo
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log2b.rdo'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log02a.rdo'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
SQL> alter database clear logfile group 2;
alter database clear logfile group 2
*
ERROR at line 1:
ORA-01624: log 2 needed for crash recovery of thread 1
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log02a.rdo'
ORA-00312: online log 2 thread 1: '/oracle/dba/dba25/dbs/log2b.rdo'
불완전 복구 이용해서 datafile 시점 일치시키도록 유도
(커런트 파일의 장애가 난 경우라면 특정 데이터는 커밋이 된 상태이기도 하고, 아닌 것도 잇을 수 있기 때문에 시점을 일치시키는 작업이 필요하다)
SQL> !cp $HOME/BACKUP/*.dbf $HOME/dbs/.
SQL> recover database until cancel;
ORA-00279: change 319976 generated at 11/06/2008 11:48:56 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_1.arc
ORA-00280: change 319976 for thread 1 is in sequence #1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 320081 generated at 11/06/2008 13:21:43 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc
ORA-00280: change 320081 for thread 1 is in sequence #2
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_1.arc' no longer
needed for this recovery
ORA-00279: change 320099 generated at 11/06/2008 13:22:37 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc
ORA-00280: change 320099 for thread 1 is in sequence #3
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc' no longer
needed for this recovery
ORA-00279: change 320106 generated at 11/06/2008 13:22:53 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc
ORA-00280: change 320106 for thread 1 is in sequence #4
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc' no longer
needed for this recovery
ORA-00279: change 320108 generated at 11/06/2008 13:22:53 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc
ORA-00280: change 320108 for thread 1 is in sequence #5
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc' no longer
needed for this recovery
ORA-00279: change 320110 generated at 11/06/2008 13:22:58 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 320110 for thread 1 is in sequence #6
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc' no longer
needed for this recovery
ORA-00279: change 340112 generated at 11/06/2008 13:26:19 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc
ORA-00280: change 340112 for thread 1 is in sequence #7
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc' no longer
needed for this recovery
ORA-00279: change 340287 generated at 11/06/2008 13:29:52 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc
ORA-00280: change 340287 for thread 1 is in sequence #8
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc' no longer
needed for this recovery
ORA-00308: cannot open archived log
'/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
SQL> !ls -lrt /oracle/dba/dba25/ORADATA/ARCHIVE2
total 468
-rw-r----- 1 dba25 dba 86528 Nov 6 11:12 arch_123.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 11:13 arch_124.arc
-rw-r----- 1 dba25 dba 12288 Nov 6 11:15 arch_125.arc
-rw-r----- 1 dba25 dba 91648 Nov 6 13:21 arch_1.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:22 arch_2.arc
-rw-r----- 1 dba25 dba 2048 Nov 6 13:22 arch_3.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:22 arch_4.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:22 arch_5.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:26 arch_6.arc
-rw-r----- 1 dba25 dba 40448 Nov 6 13:29 arch_7.arc
SQL> !ls $HOME/dbs/*.rdo
/oracle/dba/dba25/dbs/log01a.rdo /oracle/dba/dba25/dbs/log3a.rdo
/oracle/dba/dba25/dbs/log1b.rdo /oracle/dba/dba25/dbs/log3b.rdo
SQL> alter database open resetlogs;
Database altered.
SQL> !ls $HOME/dbs/*.rdo
/oracle/dba/dba25/dbs/log01a.rdo /oracle/dba/dba25/dbs/log1b.rdo /oracle/dba/dba25/dbs/log3a.rdo
/oracle/dba/dba25/dbs/log02a.rdo /oracle/dba/dba25/dbs/log2b.rdo /oracle/dba/dba25/dbs/log3b.rdo
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !cp $HOME/dbs/*.* $HOME/BACKUP/.
SQL>
컨트롤 파일 장애 (110P ~ 111P)
A) 여러 개중 일부만 장애
유효한 파일을 복사만 해주면 완료
B) 모든 CTRL 파일 장애 (그 외 데이터 파일 및 리두 파일 정상)
create control file 명령으로 생성 가능
모든 데이터 파일 및 리두 로그 파일의 이름을 알고 있어야 사용 가능함.
to trace 받은 백업 파일을 이용하는게 좋다.
C) 모든 CTRL 파일 및 데이터, 리두 파일 손상
백업 파일 restore 후 복구 수행
+ control file 시점 동기화 필요 : recover database using backup controlfile
(아카이브 rdo 로그를 읽어서 컨트롤 파일의 정보도 갱신하는 옵션)
※ 문제는 이 옵션으로 복구를 할 경우 복구 툴이 자동으로 리두 로그를 인식하지 못하기 때문에 DBA에 의해서 수동으로 로그를 지정하면서 작업을 진행해야함. (아카이브 이름, 위치 이름, currnet 리두 파일의 위치 및 이름 입력)
1. 컨트롤 파일 트레이스 백업본 작성
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Database mounted.
Database opened.
SQL> alter system set user_dump_dest='$HOME/DEMO';
System altered.
SQL> alter database backup controlfile to trace;
Database altered.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 – Production
2. 복구용 트레이스 파일 추출
dba25@sun02-zone:/oracle/dba/dba25/dbs] cd $HOME/DEMO
dba25@sun02-zone:/oracle/dba/dba25/DEMO] ls
c.bak dba25_ora_15999.trc sample01.dbf
dba25@sun02-zone:/oracle/dba/dba25/DEMO] cat *.trc
…
# Set #1. NORESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# Data used by the recovery manager will be lost. Additional logs may
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "DBA25" NORESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 32
MAXLOGMEMBERS 3
MAXDATAFILES 40
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 (
'/oracle/dba/dba25/dbs/log01a.rdo',
'/oracle/dba/dba25/dbs/log1b.rdo'
) SIZE 5M,
GROUP 2 (
'/oracle/dba/dba25/dbs/log02a.rdo',
'/oracle/dba/dba25/dbs/log2b.rdo'
) SIZE 5M,
GROUP 3 (
'/oracle/dba/dba25/dbs/log3a.rdo',
'/oracle/dba/dba25/dbs/log3b.rdo'
) SIZE 250K
-- STANDBY LOGFILE
DATAFILE
'/oracle/dba/dba25/dbs/system01.dbf',
'/oracle/dba/dba25/dbs/undotbs.dbf',
'/oracle/dba/dba25/dbs/users01.dbf',
'/oracle/dba/dba25/dbs/indx01.dbf',
'/oracle/dba/dba25/dbs/sample01.dbf',
'/oracle/dba/dba25/dbs/querydata01.dbf',
'/oracle/dba/dba25/dbs/d.dbf'
CHARACTER SET US7ASCII
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# Database can now be opened normally.
ALTER DATABASE OPEN;
# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/user4/dba25/dbs/temp01.dbf' REUSE;
# End of tempfile additions.
#
# Set #2. RESETLOGS case
…
상기의 내용만을 추출해서 c.sql로 저장
3. 장애 발생
dba25@sun02-zone:/oracle/dba/dba25/DEMO] sqlplus '/as sysdba'
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Nov 6 14:44:14 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> alter system switch logfile;
System altered.
SQL> select count(*) from scott.dept;
COUNT(*)
----------
32
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/oracle/dba/dba25/dbs/ctrl01.ctl
/oracle/dba/dba25/dbs/ctrl02.ctl
SQL> !rm $HOME/dbs/*.ctl
4. 데이터베이스 셧다운 및 재실행
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
ORA-00205: error in identifying controlfile, check alert log for more info
SQL> select status from v$instance;
STATUS
------------
STARTED
5. 컨트롤 파일 새로 생성 복구 수행
SQL> shutdown abort;
ORACLE instance shut down.
SQL> @ $HOME/DEMO/c.sql;
SP2-0158: unknown SET option "#1."
SP2-0734: unknown command beginning "The follow..." - rest of line ignored.
SP2-0734: unknown command beginning "to open th..." - rest of line ignored.
SP2-0734: unknown command beginning "Data used ..." - rest of line ignored.
SP2-0734: unknown command beginning "be require..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "only if th..." - rest of line ignored.
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
Control file created.
SP2-0734: unknown command beginning "Recovery i..." - rest of line ignored.
SP2-0734: unknown command beginning "or if the ..." - rest of line ignored.
Media recovery complete.
SP2-0734: unknown command beginning "All logs n..." - rest of line ignored.
System altered.
SP2-0734: unknown command beginning "Database c..." - rest of line ignored.
Database altered.
SP2-0734: unknown command beginning "Commands t..." - rest of line ignored.
SP2-0734: unknown command beginning "Online tem..." - rest of line ignored.
SP2-0734: unknown command beginning "Other temp..." - rest of line ignored.
ALTER TABLESPACE TEMP ADD TEMPFILE '/user4/dba25/dbs/temp01.dbf' REUSE
*
ERROR at line 1:
ORA-01119: error in creating database file '/user4/dba25/dbs/temp01.dbf'
ORA-17610: file '/user4/dba25/dbs/temp01.dbf' does not exist and no size
specified
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
실습 환경이 다른 서버에서 복사 해온 경우라서 디렉토리가 다르다.
SP2-0734: unknown command beginning "End of tem..." - rest of line ignored.
SQL> alter tablespace temp add tempfile '$HOME/dbs/temp02.dbf' size 10m;
Tablespace altered.
SQL> !ls $HOME/dbs/*.ctl
/oracle/dba/dba25/dbs/ctrl01.ctl /oracle/dba/dba25/dbs/ctrl02.ctl
컨트롤 파일 생성 확인
6. 경고파일의 내용 확인하기
SQL> !rm $HOME/ADMIN/BDUMP/*.*;
파일의 내용이 너무 많기 때문에 현재의 로그 내용을 없앤다.
SQL> alter system switch logfile;
System altered.
SQL> !vi $HOME/ADMIN/BDUMP/*.log
Thu Nov 6 14:52:35 2008
Thread 1 advanced to log sequence 6
Thu Nov 6 14:52:35 2008
Current log# 3 seq# 6 mem# 0: /oracle/dba/dba25/dbs/log3a.rdo
Thu Nov 6 14:52:35 2008
ARC0: Evaluating archive log 1 thread 1 sequence 5
Current log# 3 seq# 6 mem# 1: /oracle/dba/dba25/dbs/log3b.rdo
Thu Nov 6 14:52:35 2008
ARC0: Beginning to archive log 1 thread 1 sequence 5
Creating archive destination LOG_ARCHIVE_DEST_2: '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc'
Creating archive destination LOG_ARCHIVE_DEST_1: '/oracle/dba/dba25/ORADATA/ARCHIVE1/arch_5.arc'
ARC0: Completed archiving log 1 thread 1 sequence 5
7. controlfile 장애 만들기
SQL> !rm $HOME/dbs/*.ctl
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
ORA-00205: error in identifying controlfile, check alert log for more info
8. 컨트롤 파일 복구하기
SQL> alter database mount;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/oracle/dba/dba25/dbs/system01.dbf'
ORA-01207: file is more recent than controlfile - old controlfile
컨트롤 파일의 시점 데이터가 데이터 파일의 그것 보다 더 빠르기 때문에…
9. 컨트롤 파일 시점 변경
SQL> recover database using backup controlfile;
ORA-00279: change 340776 generated at 11/06/2008 14:11:26 needed for thread 1
컨트롤 파일의 정보가 불충분하기 때문에 suggest 가 비정상적으로 동작함.
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00266: name of archived log file needed
SQL> !ls -ltr $HOME/ORADATA/ARCHIVE1
total 548
-rw-r----- 1 dba25 dba 86528 Nov 6 11:12 arch_123.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 11:13 arch_124.arc
-rw-r----- 1 dba25 dba 12288 Nov 6 11:15 arch_125.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 13:26 arch_6.arc
-rw-r----- 1 dba25 dba 40448 Nov 6 13:29 arch_7.arc
-rw-r----- 1 dba25 dba 90112 Nov 6 14:44 arch_1.arc
-rw-r----- 1 dba25 dba 1024 Nov 6 14:47 arch_2.arc
-rw-r----- 1 dba25 dba 2048 Nov 6 14:47 arch_3.arc
-rw-r----- 1 dba25 dba 2560 Nov 6 14:47 arch_4.arc
-rw-r----- 1 dba25 dba 41984 Nov 6 14:52 arch_5.arc
SQL> recover database using backup controlfile;
ORA-00279: change 340776 generated at 11/06/2008 14:11:26 needed for thread 1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
$HOME/ORADATA/ARCHIVE1/arch_1.arc
ORA-00279: change 341101 generated at 11/06/2008 14:44:20 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc
ORA-00280: change 341101 for thread 1 is in sequence #2
ORA-00278: log file '$HOME/ORADATA/ARCHIVE1/arch_1.arc' no longer needed for
this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 341107 generated at 11/06/2008 14:44:36 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc
ORA-00280: change 341107 for thread 1 is in sequence #3
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_2.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 341110 generated at 11/06/2008 14:44:38 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc
ORA-00280: change 341110 for thread 1 is in sequence #4
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_3.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 361115 generated at 11/06/2008 14:47:57 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc
ORA-00280: change 361115 for thread 1 is in sequence #5
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_4.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00279: change 361370 generated at 11/06/2008 14:52:35 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 361370 for thread 1 is in sequence #6
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_5.arc' no longer
needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00328: archived log ends at change 340111, need later change 361370
ORA-00334: archived log: '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc'
이 이후는 아카이브 로그로 만들어진 내용이 아니기 때문에 적용이 불가능.
SQL> recover database using backup controlfile;
ORA-00279: change 361370 generated at 11/06/2008 14:52:35 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 361370 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
$HOME/dbs/log3.ardo
ORA-00308: cannot open archived log '$HOME/dbs/log3.ardo'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
$HOME/dbs/log3a.rdo
alert_SID.log 의 내용을 가지고 파악해서 복구한다.
Log applied.
Media recovery complete.
SQL>
컨트롤파일, 데이터파일, 로그파일 모두 장애 발생시
a) 우선 MOUNT 시점으로 올려야하기 때문에 컨트롤 파일 올려야함.
b) 데이터 파일 백업본을 복사한다. (리두 로그의 경우 복사를 할 경우 정상상태로 인식하기 때문에 복사해서는 안됀다. )
c) recover database using backup controlfile until cancel
d) alter database open resetlog; 를 이용해서 장애난 redo logfile 을 재생성
1. 사전 작업
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> create table t7 as select * from scott.dept;
Table created.
SQL> insert into t7 select * from t7;
32 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from t7;
COUNT(*)
----------
64
SQL> alter system switch logfile;
SQL> /
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 5 5242880 2 NO CURRENT
361693 06-NOV-08
2 1 4 5242880 2 YES INACTIVE
361691 06-NOV-08
3 1 3 256000 2 YES INACTIVE
361667 06-NOV-08
SQL>
2. 장애 생성하기
SQL> !rm $HOME/dbs/*.ctl
SQL> !rm $HOME/dbs/*.rdo
SQL> !rm $HOME/dbs/*.dbf
SQL> shutdown abort;
ORACLE instance shut down.
SQL>
내가 풀이했던 장애 복구 시나리오.
SQL> startup
ORACLE instance started.
Total System Global Area 22630360 bytes
Fixed Size 454616 bytes
Variable Size 16777216 bytes
Database Buffers 4194304 bytes
Redo Buffers 1204224 bytes
ORA-00205: error in identifying controlfile, check alert log for more info
SQL> !cp $HOME/BACKUP/*.ctl $HOME/dbs/.
SQL> alter database mount;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/oracle/dba/dba25/dbs/system01.dbf'
SQL> !cp $HOME/BACKUP/*.dbf $HOME/dbs/.
SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required
SQL> recover database using backup controlfile until cancel;
만약 이때 특정한 한 개의 파일이 복구가 안돼는 경우라면 최초 백업이 온라인 상태에서 행해진 것이 아닌지 의심해본다.
ORA-00279: change 402511 generated at 11/06/2008 18:51:47 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc
ORA-00280: change 402511 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 402610 generated at 11/06/2008 18:52:22 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc
ORA-00280: change 402610 for thread 1 is in sequence #7
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_6.arc' no longer
needed for this recovery
ORA-00279: change 402612 generated at 11/06/2008 18:52:23 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc
ORA-00280: change 402612 for thread 1 is in sequence #8
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_7.arc' no longer
needed for this recovery
ORA-00279: change 402636 generated at 11/06/2008 18:52:43 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_9.arc
ORA-00280: change 402636 for thread 1 is in sequence #9
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_8.arc' no longer
needed for this recovery
ORA-00279: change 402638 generated at 11/06/2008 18:52:47 needed for thread 1
ORA-00289: suggestion : /oracle/dba/dba25/ORADATA/ARCHIVE2/arch_10.arc
ORA-00280: change 402638 for thread 1 is in sequence #10
ORA-00278: log file '/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_9.arc' no longer
needed for this recovery
ORA-00308: cannot open archived log
'/oracle/dba/dba25/ORADATA/ARCHIVE2/arch_10.arc'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
SQL> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
컨트롤 파


2008년11월06일-Oracle장애복구.pdf
Recent comment