'ORA-01207'에 해당되는 글 2건

  1. 2014.11.04 컨트롤 파일복구 3-1
  2. 2014.11.04 컨트롤 파일 복구 3
2014. 11. 4. 20:42

redo log file까지 손상이 있을 경우 resetlogs 모드로 재생성

SYS>startup

ORACLE instance started.


Total System Global Area  422670336 bytes

Fixed Size                  1344616 bytes

Variable Size             293604248 bytes

Database Buffers          121634816 bytes

Redo Buffers                6086656 bytes

Database mounted.

ORA-01122: database file 1 failed verification check

ORA-01110: data file 1: '/data/temp7/system01.dbf'

ORA-01207: file is more recent than control file - old control file



SYS>alter database backup controlfile to trace as '/app/oracle/back.sql';


Database altered.


SYS>shut immediate

ORA-01109: database not open



Database dismounted.

ORACLE instance shut down.

'DB > oralce' 카테고리의 다른 글

리두로그 장애1  (0) 2014.11.05
리두로그마이너 - 정리 덜됨...엉망임;;  (0) 2014.11.05
컨트롤 파일 복구 3  (0) 2014.11.04
컨트롤 파일복구 2  (0) 2014.11.04
컨트롤 파일 복구1  (0) 2014.11.04
Posted by 성장하는yw
2014. 11. 4. 19:01

정상적인 DB 에서 old control file error 에러 발생시키기


SYS>startup

ORACLE instance started.


Total System Global Area  422670336 bytes

Fixed Size                  1344616 bytes

Variable Size             293604248 bytes

Database Buffers          121634816 bytes

Redo Buffers                6086656 bytes

Database mounted.

Database opened.


SYS>alter system switch logfile;


System altered.


SYS>alter system checkpoint;


System altered.


SYS>shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SYS>startup

ORACLE instance started.


Total System Global Area  422670336 bytes

Fixed Size                  1344616 bytes

Variable Size             293604248 bytes

Database Buffers          121634816 bytes

Redo Buffers                6086656 bytes

Database mounted.

ORA-01122: database file 1 failed verification check

ORA-01110: data file 1: '/app/oracle/oradata/testdb/system01.dbf'

ORA-01207: file is more recent than control file - old control file


에러의 원인

- 컨트롤 파일 정보가 저장된 시점이 데이터파일의 정보저장 시점보다 예전 내용이기 때문


문제 해결 방법

1. 백업 데이터파일과 아카이브 리두로그파일을 사용 using backup controlfile 옵션으로 recovery 하는 방법

2. 1의 방법이 되지 않으면 컨트롤파일을 재생성 해야 함

     - 현재 리두로그 파일에 손상이 없을 경우 : noresetlogs 모드로 재생성

     - 현재 리두고르 파일에 손상이 있을 경우 : resetlogs 모드로 재생성



나의 경우는 리두로그 파일에 손상이 없을 경우임


nomount 상태에서 컨트롤 파일을 재생성하는 명령어를 입력하면 됨, 

but 그 명령어가 너무 길어서 외우기가 힘듬

현재 운영 중인 서버에서 재생성용 스크립트를 만들어 생성하는 방법으로 실습할 예정임 


컨트롤 파일을 재생성하는 스크립트는 현재 올드 컨트롤 파일로부터 trace 해서 만들게 됨

이 방법은 현재 컨트롤 파일의 정보를 사용해서 재생성하는 것이므로 mount상태에서 수행해야 함


현재 상태 확인

SYS>select status from v$instance;


STATUS

------------

MOUNTED


컨트롤 파일 재생성 스크립트 만들기
SYS>alter database backup controlfile to trace as '/app/oracle/re11.sql';

Database altered.

SYS>shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.

SYS>!
[oracle@localhost ~]$ vi /app/oracle/re11.sql
-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="testdb"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?/dbs/arch
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
-- LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM EXPEDITE NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE

--
-- Below are two sets of SQL statements, each of which creates a new
-- control file and uses it to open the database. The first set opens
-- the database with the NORESETLOGS option and should be used only if
-- the current versions of all online logs are available. The second
-- set opens the database with the RESETLOGS option and should be used
-- if online logs are unavailable.
-- The appropriate set of statements can be copied from the trace into
-- a script file, edited as necessary, and executed when there is a
-- need to re-create the control file.
--
--     Set #1. NORESETLOGS case 
--  
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.

-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "TESTDB" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 (
    '/app/oracle/oradata/testdb/redo01_a.log',
    '/app/oracle/oradata/testdb/redo01_b.log'
  ) SIZE 5M BLOCKSIZE 512,
  GROUP 2 (
    '/app/oracle/oradata/testdb/redo02_a.log',
    '/app/oracle/oradata/testdb/redo02_b.log'
  ) SIZE 5M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/app/oracle/oradata/testdb/system01.dbf',
  '/app/oracle/oradata/testdb/sysaux01.dbf',
  '/app/oracle/oradata/testdb/undotbs01.dbf',
  '/app/oracle/oradata/testdb/users01.dbf',
  '/app/oracle/oradata/testdb/example01.dbf'
CHARACTER SET KO16MSWIN949
;

-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';
-- 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 '/app/oracle/oradata/testdb/temp01.dbf' REUSE;
-- End of tempfile additions.
--
--     Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.

-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "TESTDB" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 (
    '/app/oracle/oradata/testdb/redo01_a.log',
    '/app/oracle/oradata/testdb/redo01_b.log'
  ) SIZE 5M BLOCKSIZE 512,
  GROUP 2 (
    '/app/oracle/oradata/testdb/redo02_a.log',
    '/app/oracle/oradata/testdb/redo02_b.log'
  ) SIZE 5M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/app/oracle/oradata/testdb/system01.dbf',
  '/app/oracle/oradata/testdb/sysaux01.dbf',
  '/app/oracle/oradata/testdb/undotbs01.dbf',
  '/app/oracle/oradata/testdb/users01.dbf',
  '/app/oracle/oradata/testdb/example01.dbf'
CHARACTER SET KO16MSWIN949
;

-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';
-- ALTER DATABASE REGISTER LOGFILE '/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/testdb/temp01.dbf' REUSE;
-- End of tempfile additions.
--

이 파일 사용 -- 부분은 주석이므로 모두 지우고, 
노리셋모드는 :set nu 해서 59-87줄만 남기고 다 지울 것.
리셋모드는 112-154줄 안에 주석은 삭제하기 

각 파일의 경로는 상황에 맞게 수정해서 스크립트를 돌림

각 경로의 정보는 컨트롤 파일에서 가져오는 정보임! 

[oracle@localhost ~]$ vi /app/oracle/re11.sql
  1 STARTUP NOMOUNT
  2 CREATE CONTROLFILE REUSE DATABASE "TESTDB" NORESETLOGS  ARCHIVELOG
  3     MAXLOGFILES 16
  4     MAXLOGMEMBERS 3
  5     MAXDATAFILES 100
  6     MAXINSTANCES 8
  7     MAXLOGHISTORY 292
  8 LOGFILE
  9   GROUP 1 (
 10     '/data/temp7/redo01_a.log',
 11     '/data/temp7/redo01_b.log'
 12   ) SIZE 5M BLOCKSIZE 512,
 13   GROUP 2 (
 14     '/data/temp7/redo02_a.log',
 15     '/data/temp7/redo02_b.log'
 16   ) SIZE 5M BLOCKSIZE 512
 17 -- STANDBY LOGFILE
 18 DATAFILE
 19   '/data/temp7/system01.dbf',
 20   '/data/temp7/sysaux01.dbf',
 21   '/data/temp7/undotbs01.dbf',
 22   '/data/temp7/users01.dbf',
 23   '/data/temp7/example01.dbf'
 24 CHARACTER SET KO16MSWIN949
 25 ;
~
~
~
:wq!

컨트롤 파일을 재생성하기 위해 데이터베이스를 shutdown 상태로 해놓고 스크립트를 실행함
SYS>shutdown
ORA-01012: not logged on

파라미터파일의 컨트롤 파일의 경로에 생김
SYS>@/app/oracle/re11.sql
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1344616 bytes
Variable Size             293604248 bytes
Database Buffers          121634816 bytes
Redo Buffers                6086656 bytes

Control file created.

SYS>alter database open;
Database altered.

SYS>select name from v$controlfile;

NAME
--------------------------------------------------
/data/temp7/control01.ctl
/data/temp7/control02.ctl
/data/temp7/control03.ctl



스크립트 모드로 컨트롤 파일을 재생성할 때의 주의 사항
1. DB가 resetlogs mode 로 open 되는지 
    noresetlogs mode로 open 되는지 정확히 구분할 것

2. 스크립트 안에 공백이 있으면 생성도중 에러생김
    (10g 경우에 공백이 있으니 주의할 것)

3. noresetlogs 모드 일 경우 스크립트 내부의 redo log file이 전부 해당 경로에 있어야만 함

4. resetlogs 모드 일 때 스크립트 내부의 redo log file 은 실제 파일이 없어도 resetlog로 open될 때 재생성 됨

5. 두 모드 공통적으로 데이터 파일은 반드시 스크립트 내부의 경로에 실제 존재 해야함

6. control file의 생성 위치는 파라미터 파일에 지정된 경로 


'DB > oralce' 카테고리의 다른 글

리두로그마이너 - 정리 덜됨...엉망임;;  (0) 2014.11.05
컨트롤 파일복구 3-1  (0) 2014.11.04
컨트롤 파일복구 2  (0) 2014.11.04
컨트롤 파일 복구1  (0) 2014.11.04
시점복구시 주의할 사항  (0) 2014.11.04
Posted by 성장하는yw