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
2014. 11. 4. 17:36

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

ORA-00214: control file '/data/temp7/control01.ctl' version 1782 inconsistent with file '/data/temp7/control02.ctl' version 1767


모든 컨트롤 파일끼리는 정보가 동일해야하는데 

컨트롤 파일끼리 정보가 달라서 생기는 version error임


SYS>!

[oracle@localhost ~]$ cp /data/temp7/control01.ctl /data/temp7/control02.ctl

[oracle@localhost ~]$ cp /data/temp7/control01.ctl /data/temp7/control03.ctl

[oracle@localhost ~]$ exit


SYS>alter database mount;

Database altered.


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


해결방법

- 버전이 높은 것(최신으로) 복사해서 컨트롤파일2, 3을 동일하게 복사함

   만일 낮은 버전으로 복사하게 되면 old controlfile error 발생함

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

컨트롤 파일복구 3-1  (0) 2014.11.04
컨트롤 파일 복구 3  (0) 2014.11.04
컨트롤 파일 복구1  (0) 2014.11.04
시점복구시 주의할 사항  (0) 2014.11.04
ora-01190  (0) 2014.11.04
Posted by 성장하는yw
2014. 11. 4. 17:22

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

ORA-00205: error in identifying control file, check alert log for more info


에러 뜨는 이유 컨트롤 파일의 경로와 실제 컨트롤 파일이 서로 맞지 않을 때,

경로는 있지만, 파일이 없는 경우 위와 같은 에러가 생김

그러면 경로를 수정해주거나, 파일을 추가 혹은 삭제해서 같도록 만들어주면 startup 이 정상적으로 됨


나와 같은 경우


실제 경로

파일명 : $ORACLE_HOME/dbs/inittestdb.ora (파라미터파일, pfile) 

...생략

*.control_files='/data/temp7/control01.ctl','/data/temp7/control02.ctl','/data/temp7/control03'

...생략



실제 컨트롤 파일 조회

SYS>select name from v$controlfile;


NAME

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

/data/temp7/control01.ctl


os 실제 경로에 파일 확인


[oracle@localhost temp7]$ ls

control01.ctl  redo01_b.log  sysaux01.dbf  undotbs01.dbf

example01.dbf  redo02_a.log  system01.dbf  users01.dbf

redo01_a.log   redo02_b.log  temp01.dbf


[oracle@localhost ~]$ cp /data/temp7/control01.ctl /data/temp7/control02.ctl
[oracle@localhost ~]$ cp /data/temp7/control01.ctl /data/temp7/control03.ctl 


해결방법 :

1. 경로에서 사용하지 않는 경로를 삭제

2. 실제(사용중인) 컨트롤 파일을 경로처럼 다중화(복사)를 해줌

3. 경로에 오타가 있거나 파일 이름에 오타가 있어도 이러한 에러가 뜸!!!!!!!!!!!!



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

컨트롤 파일 복구 3  (0) 2014.11.04
컨트롤 파일복구 2  (0) 2014.11.04
시점복구시 주의할 사항  (0) 2014.11.04
ora-01190  (0) 2014.11.04
archive log mode 아카이브 로그 모드 장애 복구  (0) 2014.11.03
Posted by 성장하는yw
2014. 11. 4. 11:43

- 내가 한 실수

시점복구를 할 때, 

오라클의 날짜와 시간을 보고 

시점복구를 해야한다. 


윈도우의 시간과 오라클의 시간이 다르기 때문에

특히 주의를 해야한다. !!


윈도우 시간으로 복구하려고 했다가

시점 복구할 때 그래서 삽질함 


- 시점복구 명령어

recover until time '2014-11-01:07:17:55';


- 현재 시간보는 쿼리문

SQL> select to_char(sysdate,'yyyy-mm-dd:hh24:mi:ss') from dual;


TO_CHAR(SYSDATE,'YY

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

2014-11-01:07:17:56



- alert_testdb.log의 시간 형태

/app/oracle/diag/rdbms/testdb/testdb/trace/alert_testdb.log 


Sat Nov 01 06:53:25 2014

SMCO started with pid=28, OS id=22285

Sat Nov 01 06:55:24 2014

drop tablespace  ts_new including contents and datafiles



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

컨트롤 파일복구 2  (0) 2014.11.04
컨트롤 파일 복구1  (0) 2014.11.04
ora-01190  (0) 2014.11.04
archive log mode 아카이브 로그 모드 장애 복구  (0) 2014.11.03
recovery 이론 및 dump파일 내용  (0) 2014.11.01
Posted by 성장하는yw
2014. 11. 4. 11:21

백업 복구시 에러 생김 ㅠ


Database dismounted.

ORACLE instance shut down.


SQL> startup mount;

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.

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01190: control file or data file 1 is from before the last RESETLOGS

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



SQL> recover tablespace system;

ORA-00283: recovery session canceled due to errors

ORA-19909: datafile 1 belongs to an orphan incarnation

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



SQL> recover database;

ORA-00283: recovery session canceled due to errors

ORA-19909: datafile 1 belongs to an orphan incarnation

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



컨트롤 파일과 데이터 파일이 

리셋로그즈의 시점이 다른 파일을 가지고 와서 

복구 명령어로 실행하고

오픈 하려고 하면 이런 에러가 생긴다. 


리셋로그즈의 여부에 따라 하나는 아마 리셋로그즈전, 하나는 후 


리셋로그즈의 시점이 맞지 않는 컨트롤, 데이터 파일을 가지고 오면 복구 명령어도 먹지 않는다.


결국 close 백업으로 받아놓았던 파일로 모두 덮어쓰고 다시 DB 생성해서 복원해주었다.


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

컨트롤 파일 복구1  (0) 2014.11.04
시점복구시 주의할 사항  (0) 2014.11.04
archive log mode 아카이브 로그 모드 장애 복구  (0) 2014.11.03
recovery 이론 및 dump파일 내용  (0) 2014.11.01
오라클이 시작되는 원리  (0) 2014.10.31
Posted by 성장하는yw
2014. 11. 3. 16:18

1. DB를 archive log mode로 시작


startup mount;


alter database archivelog;


alter database open;


create tablespace test2 

datafile '/app/oracle/oradata/testdb/test02.dbf' size 5M;


2. 정상 종료 후 백업 수행

(모드 변경 후에는 항상 전체 백업을 할 것)


select name from v$datafile;


select name from v$controlfile;


select member from v$logfile;


shutdown immediate;


!cp /app/oracle/oradata/testdb/* /data/backup/close/


startup


3. 장애를 발생시키고 복구 진행


create table scott.tt750 (no number) tablespace test2;


insert into scott.tt750 values (1);


commit;


select * from scott.tt750;


4. 장애 발생 확인


!rm -rf /app/oracle/oradata/testdb/test02.dbf


!ls /app/oracle/oradata/testdb/test02.dbf


alter tablespace test2 offline;


alter tablespacae test2 online;

에러발생


 5. 백업으로부터 삭제 된 데이터 파일 복원 후 복구 


!cp /data/backup/close/test02.dbf /app/oracle/oradata/testdb/


alter database test2 online;

에러발생


recover tablespace test2;


alter tablespace test2 onlie;


select * from scott.tt750;


db 정지 후 복구(offline 안되는 tablespace)

1 system tablespace 에 연습용 테이블 생성


create table scott.tt800(no number) tablespace system;


insert into scott.tt800 values (1);


commit;


select * from scott.tt800;


2. system tablespace 삭제 후 db 종료


!rm /app/oracle/oradata/testdb/system01.dbf


alter tablespace system offline;

에러


shutdown immediate;


startup;

에러


3. 백업 파일에서 system01.dbf를 복원 한 후 복구


!cp /data/backup/close/system01.dbf /app/oracle/oradata/testdb/


recover tablespace system;


alter database open;


select * from scott.tt800;


백업 파일이 없는 상태에서의 복구


이 방법으로 생성되지 않는 파일들이 있으므로 주의해야 함! 평소에 백업을 잘 시켜놓을 것 


1. 장애발생


!vi dd.sql

conn / as sysdba


set line 200

col tablespace_name for a10

col file_name for a50

col mb for 999

select tablespace_name, byres/1024/1024/ MB, file_name

from dba_data_files

/

:wq!


@dd


!rm -f /app/oracle/oradata/testdb/test02.dbf


!ls /app/oracle/oradata/testdb/test02.dbf

그런파일이나 디렉토리 없음


2. 테스트용 테이블을 생성 후 데이터를 입력

create table scott.tt810 (no number) tablespace test2;


insert into scott.tt810 values(1);


commit;


select * from scott.tt810;


alter teblespace test2 offline;


alter tablespace test2 online;

에러


select * from scott.tt810;

에러


3. 파일을 생성해서 복구 수행


@dd


alter database create datafile

'/app/oracle/oradata/testdb/test02.dbf'

as '/home/oracle/test01.dbf';


recover tablespace test2;


alter tablespace test2 online;


select * from scott.tt810;



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

시점복구시 주의할 사항  (0) 2014.11.04
ora-01190  (0) 2014.11.04
recovery 이론 및 dump파일 내용  (0) 2014.11.01
오라클이 시작되는 원리  (0) 2014.10.31
오라클 실습시 용량부족으로 디스크 붙이는 방법  (0) 2014.10.31
Posted by 성장하는yw
2014. 11. 1. 01:58

dump file이 저장될 장소를 확인하는 명령어


SYS>show parameter user_dump_dest;


NAME                                 TYPE        VALUE

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

user_dump_dest                       string      /app/oracle/diag/rdbms/testdb/testdb/trace



위 trace 경로에는 많은 파일이 있어서 생성되어도 찾기가 어려움

그래서 구분하기 쉽게 identifier을 추가한 후 dump를 수행함


SYS>alter session set tracefile_identifier='AAA';

Session altered.


SYS>oradebug setmypid;

Statement processed.


SYS>oradebug dump controlf 3;

Statement processed.



SYS>!

[oracle@localhost ~]$ cd /app/oracle/diag/rdbms/testdb/testdb/trace/

[oracle@localhost trace]$ ls -lSh *AAA*

-rw-r----- 1 oracle oinstall 44K Nov  1 00:33 testdb_ora_4412_AAA.trc

-rw-r----- 1 oracle oinstall 169 Nov  1 00:33 testdb_ora_4412_AAA.trm


컨트롤 파일 dump가 완성됨

968줄이나 됨.

복구와 관련된 내용만 살펴보자.



[oracle@localhost trace]$ vi testdb_ora_4412_AAA.trc

Trace file /app/oracle/diag/rdbms/testdb/testdb/trace/testdb_ora_4412_AAA.trc

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production

With the Partitioning option

ORACLE_HOME = /app/oracle/product/11g

System name:    Linux

Node name:      localhost.localdomain

Release:        2.6.18-238.el5

Version:        #1 SMP Tue Jan 4 15:24:05 EST 2011

Machine:        i686

VM name:        VMWare Version: 6

Instance name: testdb

Redo thread mounted by this instance: 1

Oracle process number: 19

Unix process pid: 4412, image: oracle@localhost.localdomain (TNS V1-V3)


... 중간 생략 ...


*** 2014-11-01 00:22:07.177

*** SESSION ID:(1.5) 2014-11-01 00:22:07.177

*** CLIENT ID:() 2014-11-01 00:22:07.177

*** SERVICE NAME:(SYS$USERS) 2014-11-01 00:22:07.177

*** MODULE NAME:(sqlplus@localhost.localdomain (TNS V1-V3)) 2014-11-01 00:22:07.177

*** ACTION NAME:() 2014-11-01 00:22:07.177


***************************************************************************

DATABASE ENTRY

***************************************************************************

 (size = 316, compat size = 316, section max = 1, section in-use = 1,

  last-recid= 0, old-recno = 0, last-recno = 0)

 (extent = 1, blkno = 1, numrecs = 1)

 09/27/2014 13:35:14

 DB Name "TESTDB"                     DATABASE NAME 임

 Database flags = 0x00404001 0x00001200

 Controlfile Creation Timestamp  09/27/2014 13:35:15

 Incmplt recovery scn: 0x0000.00000000

 Resetlogs scn: 0x0000.000bc19f Resetlogs Timestamp  09/27/2014 13:35:17

 Prior resetlogs scn: 0x0000.00000001 Prior resetlogs Timestamp  09/05/2010 15:39:48

 Redo Version: compatible=0xb200000

 #Data files = 5, #Online files = 5

 Database checkpoint: Thread=1 scn: 0x0000.0014161e   DATABASE 전체의 Chekcpoint SCN

 Threads: #Enabled=1, #Open=1, Head=1, Tail=1

 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000

 

... 중간 생략 ...


***************************************************************************
LOG FILE RECORDS 복구에 필요한 Redo Log File 관련 내용
***************************************************************************
 (size = 72, compat size = 72, section max = 16, section in-use = 3,
  last-recid= 3, old-recno = 0, last-recno = 0)
 (extent = 1, blkno = 10, numrecs = 16)
LOG FILE #1:
  name #3: /app/oracle/oradata/testdb/redo01.log     1번 그룹의 파일 경로
 Thread 1 redo log links: forward: 2 backward: 0
 siz: 0x19000 seq: 0x00000016 hws: 0xd bsz: 512 nab: 0x18247 flg: 0x1 dup: 1
 Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00132247
 Low scn: 0x0000.00137883 10/26/2014 16:59:37
 Next scn: 0x0000.00139a51 10/26/2014 21:04:30
LOG FILE #2:
  name #2: /app/oracle/oradata/testdb/redo02.log        2번 그룹의 파일 경로
 Thread 1 redo log links: forward: 3 backward: 1
 siz: 0x19000 seq: 0x00000017 hws: 0xd bsz: 512 nab: 0x108a8 flg: 0x1 dup: 1
 Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00137883
 Low scn: 0x0000.00139a51 10/26/2014 21:04:30
 Next scn: 0x0000.0014161d 10/31/2014 23:27:36
LOG FILE #3:
  name #1: /app/oracle/oradata/testdb/redo03.log        3번 그룹의 파일 경로
 Thread 1 redo log links: forward: 0 backward: 2
 siz: 0x19000 seq: 0x00000018 hws: 0x2 bsz: 512 nab: 0xffffffff flg: 0x8 dup: 1
 Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.00139a51
 Low scn: 0x0000.0014161d 10/31/2014 23:27:36
 Next scn: 0xffff.ffffffff 01/01/1988 00:00:00


***************************************************************************
DATA FILE RECORDS        Data file 관련 내용
***************************************************************************
 (size = 520, compat size = 520, section max = 100, section in-use = 5,
  last-recid= 38, old-recno = 0, last-recno = 0)
 (extent = 1, blkno = 11, numrecs = 100)
DATA FILE #1:
  name #7: /app/oracle/oradata/testdb/system01.dbf
creation size=0 block size=8192 status=0xe head=7 tail=7 dup=1
 tablespace 0, index=1 krfil=1 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:139 scn: 0x0000.0014161e 10/31/2014 23:27:36
 Stop scn: 0xffff.ffffffff 10/27/2014 03:12:19
 Creation Checkpointed at scn:  0x0000.00000007 09/05/2010 15:39:53
 thread:0 rba:(0x0.0.0)



데이터 파일안에는 두가지 scn이 있음


ckeckpoint cnt : 현재 데이터 파일에 저장 되어 있는 scn 번호
stop scn : 추가로 작업이 진행될 때 추가되는 scn을 의미

현재까지 저장완료된 scn은 몇 번인지 알 수 있지만,
신규로 추가되는 scn은 현재 작업 중이기 때문에 몇 번까지 들어올지 모름

-> 오라클 DB가 open 상태이면, stop scn을 임시로 무한대(0xffff.fffffff)로 설정해둠
    DB 정상종료가되거나 OFFLINE  되는 경우에 
    checkpoint 를 발생시켜 checkpoint scn / stop scn을 동일하게 만들고 해당 데이터 파일을 닫음

만약에 운영 중 DB가 장애가 생겨서 shutdown abort 된 상황
- checkpoint scn / stop scn의 값이 동기화 되지 않은 상황에서 종료


... 중간 생략 ...


 Hot Backup end marker scn: 0x0000.00000000

 aux_file is NOT DEFINED

 Plugged readony: NO

 Plugin scnscn: 0x0000.00000000

 Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Online move state: 0

DATA FILE #2:

  name #6: /app/oracle/oradata/testdb/sysaux01.dbf

creation size=0 block size=8192 status=0xe head=6 tail=6 dup=1

 tablespace 1, index=2 krfil=2 prev_file=0

 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00

 Checkpoint cnt:139 scn: 0x0000.0014161e 10/31/2014 23:27:36

 Stop scn: 0xffff.ffffffff 10/27/2014 03:12:19

 Creation Checkpointed at scn:  0x0000.00000883 09/05/2010 15:39:57

 thread:0 rba:(0x0.0.0)

 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000


... 중간 생략 ...


 Hot Backup end marker scn: 0x0000.00000000

 aux_file is NOT DEFINED

 Plugged readony: NO

 Plugin scnscn: 0x0000.00000000

 Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Online move state: 0

DATA FILE #3:

  name #5: /app/oracle/oradata/testdb/undotbs01.dbf

creation size=0 block size=8192 status=0xe head=5 tail=5 dup=1

 tablespace 2, index=3 krfil=3 prev_file=0

 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00

 Checkpoint cnt:67 scn: 0x0000.0014161e 10/31/2014 23:27:36

 Stop scn: 0xffff.ffffffff 10/27/2014 03:12:19

 Creation Checkpointed at scn:  0x0000.000bb6b4 09/05/2010 16:17:54

 thread:0 rba:(0x0.0.0)

 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000


... 중간 생략 ...


 Hot Backup end marker scn: 0x0000.00000000
 aux_file is NOT DEFINED
 Plugged readony: NO
 Plugin scnscn: 0x0000.00000000
 Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
 Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
 Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
 Online move state: 0
DATA FILE #4:
  name #4: /app/oracle/oradata/testdb/users01.dbf
creation size=0 block size=8192 status=0xe head=4 tail=4 dup=1
 tablespace 4, index=4 krfil=4 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:138 scn: 0x0000.0014161e 10/31/2014 23:27:36
 Stop scn: 0xffff.ffffffff 10/27/2014 03:12:19
 Creation Checkpointed at scn:  0x0000.000049c6 09/05/2010 15:40:06
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000

... 중간 생략 ...


 Hot Backup end marker scn: 0x0000.00000000

 aux_file is NOT DEFINED

 Plugged readony: NO

 Plugin scnscn: 0x0000.00000000

 Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00

 Online move state: 0

DATA FILE #5:

  name #9: /app/oracle/oradata/testdb/example01.dbf

creation size=12800 block size=8192 status=0xe head=9 tail=9 dup=1

 tablespace 6, index=6 krfil=5 prev_file=0

 unrecoverable scn: 0x0000.00141a59 10/31/2014 23:27:50

 Checkpoint cnt:63 scn: 0x0000.0014161e 10/31/2014 23:27:36

 Stop scn: 0xffff.ffffffff 10/27/2014 03:12:19

 Creation Checkpointed at scn:  0x0000.000c2efc 09/27/2014 13:37:19

 thread:1 rba:(0x1.b3fa.10)

 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000


... 중간 생략 ...


***************************************************************************
TEMP FILE RECORDS
***************************************************************************
 (size = 56, compat size = 56, section max = 100, section in-use = 1,
  last-recid= 10, old-recno = 0, last-recno = 0)
 (extent = 1, blkno = 90, numrecs = 100)
TEMP FILE #1: External File #201
  name #8: /app/oracle/oradata/testdb/temp01.dbf
creation size=2560 block size=8192 status=0x1e head=8 tail=8 dup=1
 tablespace 3, index=5 krfil=1 prev_file=0
 unrecoverable scn: 0x0000.000bc288 09/27/2014 13:35:35




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

ora-01190  (0) 2014.11.04
archive log mode 아카이브 로그 모드 장애 복구  (0) 2014.11.03
오라클이 시작되는 원리  (0) 2014.10.31
오라클 실습시 용량부족으로 디스크 붙이는 방법  (0) 2014.10.31
backup  (0) 2014.10.30
Posted by 성장하는yw
2014. 10. 31. 23:39
nomount

1. 서버프로세스(server process)[각주:1]가 파라미터파일(parameter file[각주:2] - spfile / pfile)을 
    PGA(program global area[각주:3])로 가지고 와서 읽음
2. 해당 파라미터 파일에서 지정한 값을 확인함
3. 파라미터 파일에 지정된 값대로 메모리에 instance를 생성

mount

주로 하는 작업
- 파라미터 파일에 기록되어 있는 위치에서 컨트롤 파일을 읽어서 장애복구시 사용
- data file 이나  redo log file 관련된 작업(rename, drop) 등을 함

1. 체크포인트 프로세스(ckpt process) 가 모든 컨트롤 파일(control file)을 읽고 일시적으로 lock를 설정함
2. 컨트롤 파일 헤더 정보를 검증해서 컨트롤 파일에 이상유무를 확인
    mountid를 계산해서 컨트롤 파일에 저장
3. 파라미터 파일의 데이터베이스 네임과 컨트롤 파일의 디비 네임이 동일한지 검사
4. 위 과정이 이상이 없으면 alert log file 에 successful mount of redo thread 메시지를 기록 한 후 
    각 프로세스 정보나 db 상세내역을 기록함

*확인방법: 동시에 터미널 창을 2개 열어서 확인 가능

open

1. 데이터 파일 헤더 부분의 정보와 컨트롤 파일의 정보를 서로 비교해 장애유무를 판단
    이때 사용하는 것이 checkpoint scn 정보임, 이 정보들에 이상이 없을 경우 DB에 문제가 없다고 판단
    정상적으로 open

출처 : 백업과 복구(서진수) p20





  1. 유저프로세스가 전해 준 sql 문장을 실제 수행하는 프로세스 [본문으로]
  2. 오라클 시작시 SGA를 생성할 때 참고하는 파일 [본문으로]
  3. 각 프로세스들이 개별적으로 사용하는 메모리 공간 [본문으로]
Posted by 성장하는yw
2014. 10. 31. 01:33

1. vmware에서 원하는 용량만큼 새로운 hard disk를 생성

2. fdisk -l 에서 83 형식

3. ext3.mkfs

4. mkdir /새로운 폴더

5. mount /디바이스 /불일폴더

6. vi /etc/fstab 편집













혹시

터미널 창에서 fdisk -l 명령어로 추가한 새로운 디스크가 나오지 않으면

vmware의 리눅스를 재부팅하면 새롭게 추가한 디스를 볼 수 있음



1. 루트로 터미널 창으로 접속함


2. 연결된 하드 디스크 내용 확인


[root@localhost ~]# fdisk -l


Disk /dev/sda: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1288    10241437+  83  Linux

/dev/sda3            1289        1925     5116702+  83  Linux

/dev/sda4            1926        3916    15992707+   5  Extended

/dev/sda5            1926        2180     2048256   82  Linux swap / Solaris

/dev/sda6            2181        2307     1020096   83  Linux

/dev/sda7            2308        3916    12924261   83  Linux


Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdb doesn't contain a valid partition table



3. 파티션 하기

[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n                  새롭게 파티션을 만들 때 n(new) 입력
Command action
   e   extended
   p   primary partition (1-4)
p                                                    주 파티션
Partition number (1-4): 1                   주 파티션 번호
First cylinder (1-2610, default 1): 1    시작 실린더번호
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):    엔터 : 모든용량     
Using default value 2610

Command (m for help): p                    파티션 생성시 설정한 옵션 볼 수 있음

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+  83  Linux

Command (m for help): w                파티션 저장
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

4. 파티션 완료 된 디스크를 포맷, 주의할 점 장치명을 적을 때 뒤에 숫자 1을 적어주어야 함

[root@localhost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


5. 디렉토리를 생성해서 마운트 작업을 함

[root@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/sdb1 /data

6. 재부팅 후에도 적용되도록 /etc/fstab 파일에 등록

[root@localhost ~]# vi /etc/fstab
LABEL=/                     /                       ext3    defaults        1 1
LABEL=/app                /app                 ext3    defaults        1 2
LABEL=/var                 /var                   ext3    defaults        1 2
LABEL=/home             /home                ext3    defaults        1 2
LABEL=/boot               /boot                 ext3    defaults        1 2
tmpfs                         /dev/shm          tmpfs   defaults        0 0
devpts                        /dev/pts    devpts  gid=5,mode=620  0 0
sysfs                          /sys                  sysfs   defaults        0 0
proc                           /proc                proc    defaults        0 0
LABEL=SWAP-sda5    swap                 swap    defaults        0 0
/dev/sdb1                    /data                ext3    defaults        1 2  내용 추가

:wq!

7. 장치확인

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             4.8G  3.0G  1.5G  67% /
/dev/sda7              12G   12G  279M  98% /app
/dev/sda6             965M   80M  836M   9% /var
/dev/sda2             9.5G  1.1G  8.0G  12% /home
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/sdb1              20G  173M   19G   1% /data


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

recovery 이론 및 dump파일 내용  (0) 2014.11.01
오라클이 시작되는 원리  (0) 2014.10.31
backup  (0) 2014.10.30
[실습] parameter file 삭제 후 재생성하기  (0) 2014.10.29
컨트롤 파일 다중화시 ora-00205 에러  (0) 2014.10.29
Posted by 성장하는yw
2014. 10. 30. 19:22

1. 닫힌 백업( cold backup, close backup )

- database의 운영상태가 closed 된 상태에서 수행하는 백업을 의미

- 백업 시점이 모두 동일해야 함

- data file, online redo log file, control file 백업가능

- 운영중(open) 상태에서는 수행할 수 없음

- archived log mode / no archived mode 상관없음


2. 열린 백업(hot backup, begin backup, online backup)

- 닫힌 백업과 달리 DB가 운영중(open) 상태에서도 백업을 수행 가능

- archived log mode 상태에서만 수행 가능

- 많은 양의 redo log가 발생됨

- data file, control file만 백업가능(redo log file 백업 불가)

- hotbackup 할 때, 디비 offline  하면 안 됨


*노아카이브-아카이브 /  아카이브-노아카이브 모드가 바뀌면 무조건 백업을 받아야 한다.

왜냐하면 scn이 달라지기 때문이다. 


cold back


백업대상확인 -> DB종료 -> 대상백업수행


1. data file 확인


SQL> select name from v$datafile;

NAME

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

/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


2. control file 확인 


SQL> select name from v$controlfile;


NAME

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

/app/oracle/oradata/testdb/control01.ctl

/app/oracle/oradata/testdb/control02.ctl

/app/oracle/oradata/testdb/control03.ctl


3. online redo log file 확인


SQL> select member from v$logfile;


MEMBER

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

/app/oracle/oradata/testdb/redo01_a.log

/app/oracle/oradata/testdb/redo03_a.log

/app/oracle/oradata/testdb/redo01_b.log

/app/oracle/oradata/testdb/redo03_b.log


4. parameter file / password file 확인

SQL> !ls $ORACLE_HOME/dbs
afiedt.buf    hc_testdb.dat  lkTESTDB  orapwtestdb
hc_DBUA0.dat  init.ora       log.sql   spfiletestdb.ora

5. DB 종료

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

6. 각 백업파일들을 원하는 경로에 복사

[oracle@localhost backup]$ ls -al
#հ# 24
drwxr-xr-x 6 oracle dba      4096 10## 29 20:34 .
drwxr-xr-x 6 oracle dba      4096 10## 29 15:42 ..
drwxr-xr-x 3 oracle dba      4096 10## 29 19:13 close
drwxr-xr-x 2 oracle oinstall 4096 10## 29 20:35 close1
drwxr-xr-x 2 oracle dba      4096 10## 29 19:42 open
drwxr-xr-x 2 oracle oinstall 4096 10## 29 20:34 open1

*cp -av : cp 옵션
a 원본 파일 완전히 똑같은 파일로 복사
v 복사 과정을 직접 보여줌

[oracle@localhost ~]$ cp -av /app/oracle/oradata/testdb/*.dbf /data/backup/close/
`/app/oracle/oradata/testdb/example01.dbf' -> `/data/backup/close/example01.dbf'
`/app/oracle/oradata/testdb/sysaux01.dbf' -> `/data/backup/close/sysaux01.dbf'
`/app/oracle/oradata/testdb/system01.dbf' -> `/data/backup/close/system01.dbf'
`/app/oracle/oradata/testdb/temp01.dbf' -> `/data/backup/close/temp01.dbf'
`/app/oracle/oradata/testdb/undotbs01.dbf' -> `/data/backup/close/undotbs01.dbf'
`/app/oracle/oradata/testdb/users01.dbf' -> `/data/backup/close/users01.dbf'

[oracle@localhost ~]$ cp -av /app/oracle/oradata/testdb/*.ctl /data/backup/close/
`/app/oracle/oradata/testdb/control01.ctl' -> `/data/backup/close/control01.ctl'
`/app/oracle/oradata/testdb/control02.ctl' -> `/data/backup/close/control02.ctl'
`/app/oracle/oradata/testdb/control03.ctl' -> `/data/backup/close/control03.ctl'

[oracle@localhost ~]$ cp -av /app/oracle/oradata/testdb/*.log /data/backup/close/
`/app/oracle/oradata/testdb/redo01_a.log' -> `/data/backup/close/redo01_a.log'
`/app/oracle/oradata/testdb/redo01_b.log' -> `/data/backup/close/redo01_b.log'
`/app/oracle/oradata/testdb/redo02_a.log' -> `/data/backup/close/redo02_a.log'
`/app/oracle/oradata/testdb/redo02_b.log' -> `/data/backup/close/redo02_b.log'
`/app/oracle/oradata/testdb/redo03_a.log' -> `/data/backup/close/redo03_a.log'
`/app/oracle/oradata/testdb/redo03_b.log' -> `/data/backup/close/redo03_b.log'

[oracle@localhost ~]$ cp -av $ORACLE_HOME/dbs /data/backup/close
`/app/oracle/product/11g/dbs' -> `/data/backup/close/dbs'
`/app/oracle/product/11g/dbs/lkTESTDB' -> `/data/backup/close/dbs/lkTESTDB'
`/app/oracle/product/11g/dbs/orapwtestdb' -> `/data/backup/close/dbs/orapwtestdb'
`/app/oracle/product/11g/dbs/log.sql' -> `/data/backup/close/dbs/log.sql'
`/app/oracle/product/11g/dbs/afiedt.buf' -> `/data/backup/close/dbs/afiedt.buf'
`/app/oracle/product/11g/dbs/spfiletestdb.ora' -> `/data/backup/close/dbs/spfiletestdb.ora'
`/app/oracle/product/11g/dbs/hc_DBUA0.dat' -> `/data/backup/close/dbs/hc_DBUA0.dat'
`/app/oracle/product/11g/dbs/hc_testdb.dat' -> `/data/backup/close/dbs/hc_testdb.dat'
`/app/oracle/product/11g/dbs/init.ora' -> `/data/backup/close/dbs/init.ora'

[oracle@localhost ~]$ cd /data/backup/close
[oracle@localhost close]$ ls
control01.ctl  example01.dbf  redo02_b.log  system01.dbf
control02.ctl  redo01_a.log   redo03_a.log  temp01.dbf
control03.ctl  redo01_b.log   redo03_b.log  undotbs01.dbf
dbs            redo02_a.log   sysaux01.dbf  users01.dbf

hot backup


tablespace를 백업 모드로 변경 - OS 명령어로 해당 tablespace의 datafile을 백업장소로 복사 - 파일 복사 후 백업모드 종료


1. 아카이브 로그 모드 확인


SQL> archive log list;


Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /data/arc2

Oldest online log sequence     30

Next log sequence to archive   31

Current log sequence           31



SQL> select tablespace_name, status, contents
  2  from dba_tablespaces;

TABLESPACE STATUS    CONTENTS
---------- --------- ---------
SYSTEM     ONLINE    PERMANENT
SYSAUX     ONLINE    PERMANENT
UNDOTBS1   ONLINE    UNDO
TEMP       ONLINE    TEMPORARY
USERS      ONLINE    PERMANENT
EXAMPLE    ONLINE    PERMANENT

6 rows selected.

보기 좋게 화면에 출력하는 명령어들
SQL> set line 200
SQL> col tablspace_name format a10
SQL> col file_name format a50
현재 테이블스페이스 , 데이터 파일을 확인
SQL> select tablespace_name, bytes/1024/1024 MB, file_name
  2  from dba_data_files;

TABLESPACE         MB FILE_NAME
---------- ---------- --------------------------------------------------
USERS             7.5 /app/oracle/oradata/testdb/users01.dbf
UNDOTBS1           90 /app/oracle/oradata/testdb/undotbs01.dbf
SYSAUX            520 /app/oracle/oradata/testdb/sysaux01.dbf
SYSTEM            710 /app/oracle/oradata/testdb/system01.dbf
EXAMPLE       345.625 /app/oracle/oradata/testdb/example01.dbf

SQL> !

명령어를 따로 치지 않고, 스크립트를 만들어서 핫백업을 받음
스크립트를 만들지않고 각각의 명령어를 따로 입력해도 결과는 같음
스크립트 안에 있는 명령어는 모두 중요

[oracle@localhost backup]$ vi /app/oracle/open_backup.sql
alter tablespace users begin backup;
!cp -av /app/oracle/oradata/testdb/users01.dbf /data/backup/open/
alter tablespace users end backup;

alter tablespace sysaux begin backup;
!cp -av /app/oracle/oradata/testdb/sysaux01.dbf /data/backup/open/
alter tablespace sysaux end backup;

alter tablespace undotbs1 begin backup;
!cp -av /app/oracle/oradata/testdb/undotbs1.dbf /data/backup/open/
alter tablespace undotbs1 end backup;

alter tablespace system begin backup;
!cp -av /app/oracle/oradata/testdb/system01.dbf /data/backup/open/
alter tablespace system end backup;

alter tablespace example begin backup;
!cp -av /app/oracle/oradata/testdb/example01.dbf /data/backup/open/
alter tablespace example end backup;

alter database backup controlfile to '/data/backup/open/control01.ctl'
:wq!

SQL> @/app/oracle/open_backup.sql







Posted by 성장하는yw