2014. 11. 6. 18:20

1. conventional path로 full export 받기(기본모드)


SYS>!

[oracle@localhost ~]$ mkdir /data/exp/

[oracle@localhost ~]$ time exp system/oracle full=y file=/data/exp/full01.dmp log=/data/exp/full_log01.log

나는 하는 도중에 temp 테이블스페이스 없어서 에러가 났음
그래서 기본으로 temp 테이블 스페이스를 만들어주니까 정상적으로 작동함

....생략


. exporting posttables actions

. exporting triggers

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    4m13.880s

user    0m22.326s

sys     0m6.277s


약 4분 13초 걸림

2. direct path로 full export  받기

마지막에 옵션 하나만 더 추가함

[oracle@localhost ~]$ time exp system/oracle full=y file=/data/exp/full02.dmp log=/data/exp/full_log02.log direct=y


. exporting synonyms

. exporting views

. exporting referential integrity constraints

. exporting stored procedures

. exporting operators

. exporting indextypes

. exporting bitmap, functional and extensible indexes

. exporting posttables actions

. exporting triggers

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    3m11.137s

user    0m20.209s

sys     0m5.754s


약 3분 11초 걸림


3. export를 저장하는 파일을 분할해서 받기

큰 파일 하나를 여러 개의 작은 파일로 분할해서 백업받음


[oracle@localhost ~]$ time exp system/oracle full=y file=/data/exp/full03_1.dmp,\

/data/exp/full03_2.dmp,\

/data/exp/full03_3.dmp\

filesize=100M;


실행할 때 파일명을 고치지 않고 그대로 실행을 다시 하면 원본 파일을 그대로 물어보지 않고, 덮어써 버린다.

주의하자. 



. exporting posttables actions

. exporting triggers

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    2m45.807s

user    0m21.065s

sys     0m5.704s


그냥 확인해 봄 
[oracle@localhost ~]$ cd /data/exp
[oracle@localhost exp]$ ls
full01.dmp  full03_1.dmp  full_log01.log
full02.dmp  full03_2.dmp  full_log02.log

용량을 잘못 계산해서 파일 개수를 부족하게 지정할 경우는 추가적으로 파일 이름을 입력하도록 프롬프트가 나와서
사용자에게 다음 파일이름을 입력하라고 중간에서 대기하고 있음
그 때 파일 이름을 지정해주면 그 파일에 exp 됨

time exp system/oracle full=y file=/data/exp/full04_1.dmp, /data/exp/full04_2.dmp, /data/exp/fulll04_3.dmp filesize=10m;
...생략
. . exporting table         WWV_FLOW_RANDOM_IMAGES         42 rows exported
. . exporting table WWV_FLOW_REGION_CHART_SER_ATTR          0 rows exported
. . exporting table  WWV_FLOW_REGION_REPORT_COLUMN
Export file: expdat.dmp > /data/exp/full04_4.dmp 
...생략


위와 같이 파일 이름 입력해줌

한 세번 정도 떠서 각각 /data/exp/full04_5.dmp, /data/exp/full04_6.dmp ...이런식으로 계속 멈추면 원하는 파일명을 입력하면 됨


. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    7m11.178s

user    0m20.848s

sys     0m5.364s



4. 특정 tablespace 만 export 하기

[oracle@localhost ~]$ time exp system/oracle file=/data/exp/ex_user.dmp tablespaces=example, users


...생략

. . exporting table                TEST_NOVALIDATE          3 rows exported

. . exporting table                  TEST_VALIDATE          3 rows exported

. . exporting table                          TT111          1 rows exported

. . exporting table                 CATEGORIES_TAB         22 rows exported

. . exporting table     PRODUCT_REF_LIST_NESTEDTAB        288 rows exported

. . exporting table SUBCATEGORY_REF_LIST_NESTEDTAB         21 rows exported

EXP-00079: Data in table "PURCHASEORDER" is protected. Conventional path may only be exporting partial table.

. . exporting table                  PURCHASEORDER        132 rows exported

. exporting referential integrity constraints

. exporting triggers

Export terminated successfully with warnings.


real    0m18.972s

user    0m2.302s

sys     0m0.469s


5. 특정 table만 exp하기

[oracle@localhost ~]$ exp scott/tiger tables=emp,dept file=emp_dept.dmp;


Export: Release 11.2.0.2.0 - Production on Fri Nov 7 01:56:55 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.



Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production

With the Partitioning option

Export done in KO16MSWIN949 character set and AL16UTF16 NCHAR character set


About to export specified tables via Conventional Path ...

. . exporting table                            EMP         14 rows exported

. . exporting table                           DEPT          4 rows exported

Export terminated successfully without warnings.


현재 경로에 만들어진 것 확인

[oracle@localhost ~]$ ls

!           ar.sh      Desktop       hot_back.sql  redo.sql

afiedt.buf  cold_back  emp_dept.dmp  ll.sql        shut

a.out       database   expdat.dmp    login.sql     test_data.sql

arch.sql    dd.sql     hot_back      log.sql


6. 여러 사용자를 동시에 exp 하기


[oracle@localhost ~]$ time exp system/oracle file=/data/exp/scott_hr.emp owner=scott,hr;

... 생략

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting statistics

Export terminated successfully without warnings.


real    0m4.183s

user    0m0.120s

sys     0m0.023s


7. evaluation Buffer값이 export에 주는 영향 테스트 하기

실습을 위해 테스트용 테이블 생성

SQL> create table scott.test01

  2  (no number,

  3  name varchar2(50),

  4  address varchar2(50))

  5  tablespace users;


Table created.


대량의 데이터를 users tablespace에 입력하기 때문에 용량이 부족할 수 있으므로

용량을 충분히 늘려줌



SQL> @/home/oracle/dd.sql


TABLESPACE    MB FILE_NAME

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

EXAMPLE      346 /data/temp7/example01.dbf

USERS          8 /data/temp7/users01.dbf

UNDOTBS1      90 /data/temp7/undotbs01.dbf

SYSAUX       560 /data/temp7/sysaux01.dbf

SYSTEM       710 /data/temp7/system01.dbf


SQL> alter database datafile '/data/temp7/users01.dbf' autoextend on;


Database altered.


SQL> alter database datafile '/data/temp7/undotbs01.dbf' autoextend on;


Database altered.

SQL>begin

for i in 1..5000000 loop

insert into scott.test01

values(i, dbms_random.string('A',49),

             dbms_random.string('Q',49));

end loop;

commit;

end;

/


하지만 시간이 한 20~30분 잡아야 함 ㅠ 


생성 후 해당테이블 크기 확인

SYS> select sum(bytes)/1024/1024 MB

from dba_segments

where owner='SCOTT'

and segment_name='TEST01';


테스트 

1 .evaluation buffer 값을 설정하지 않고 export 수행

time exp scott/tiger file=/data/exp/test_01_1.dmp tables=test01;


2. evaluation buffer 값을 1M 설정하고 export 수행

time exp scott/tiger file=/data/exp/test_01_2.dmp tables=test01 buffer=1024000


3. evaluation buffer 값을 10M 설정하고 export 수행

time exp scott/tiger file=/data/exp/test_01_3.dmp tables=test01 buffer=10240000


4. evaluation buffer 값을 20M 설정하고 export 수행

time exp scott/tiger file=/data/exp/test_01_4.dmp tables=test01 buffer=20480000


5. direct path로 export 수행

time exp scott/tiger file=/data/exp/tect_01_5.dmp tables=test01 direct=y


결과 :

evaluation buffer 의 크기를 조절하면서 export를 수행하는 것이 속도에 영향을 미침

무조건 크기가 크다고 속도가 빨라지는 것이 아님

또 temporary tablespace의 크기도 exp/imp에 영향을 많이 줌

작업 전에 미리 큰 용량을 확보한 수 작업을 하자 


8. parameter file을 이용한 export 수행

[oracle@localhost ~]$ vi full.dat

file=/data/exp/full02.dmp

full=y

direct=y

:wq!


[oracle@localhost ~]$ exp system/oracle parfile=full.dat

9. 특정조건만 export 받기 - query 옵션 사용하기
test1. emp 테이블에서 이름 첫 글자가 F인 사람만 export 받기
(OS에서 사용하는 ' / " /  < 등의 문자를 쓸 경우 \ escape문자를 꼭!!! 써야함)
[oracle@localhost ~]$ exp scott/tiger query=\"where ename like \'F%\'\"tables=empfile=/data/exp/test06.dmp

test2. emp테이블에서 job이 clerk이고 급여가 1000이상인 사람만 export 받기



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

drop tablespace 장애 복구 - clone db 사용 정리할것..;;;  (0) 2014.11.11
temporary tablespace  (0) 2014.11.07
리두로그 장애3  (0) 2014.11.06
리두로그 장애2  (0) 2014.11.06
리두로그 장애1  (0) 2014.11.05
Posted by 성장하는yw
2014. 11. 6. 14:21

Current 아닌 그룹 중 archive 안 된 그룹이 삭제되고 DB open 상태일 경우


삭제된 그룹이 archive되지 않은 경우

서버 운영중에 특정 그룹이 지워진 후 계속 log switch가 발생하면 이와 같은 상황이 됨

DB에 archive hang 현상이 발생하여 중단 후 강제 비정상 종료됨

- 평소에 꾸준히 alert log 모니터링을 잘 해서 이런 상황을 막아야 함


현재상태 확인

SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   63 INACTIVE YES

     1 /data/temp7/redo01_b.log                         5   63 INACTIVE YES

     2 /data/temp7/redo02_a.log                        50   64 CURRENT  NO

     2 /data/temp7/redo02_b.log                        50   64 CURRENT  NO

     3 /data/temp7/redo03_a.log                        50    0 UNUSED   YES

     3 /data/temp7/redo03_b.log                        50    0 UNUSED   YES


6 rows selected.


SYS>alter system switch logfile;


System altered.


SYS>alter system switch logfile;


System altered.


SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   66 CURRENT  NO

     1 /data/temp7/redo01_b.log                         5   66 CURRENT  NO

     2 /data/temp7/redo02_a.log                        50   64 ACTIVE   YES

     2 /data/temp7/redo02_b.log                        50   64 ACTIVE   YES

     3 /data/temp7/redo03_a.log                        50   65 ACTIVE   YES

     3 /data/temp7/redo03_b.log                        50   65 ACTIVE   YES


6 rows selected.

 

SYS>alter system switch logfile;


System altered.


SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   66 INACTIVE YES

     1 /data/temp7/redo01_b.log                         5   66 INACTIVE YES

     2 /data/temp7/redo02_a.log                        50   67 CURRENT  NO

     2 /data/temp7/redo02_b.log                        50   67 CURRENT  NO

     3 /data/temp7/redo03_a.log                        50   65 INACTIVE YES

     3 /data/temp7/redo03_b.log                        50   65 INACTIVE YES


6 rows selected.


그룹삭제 (현재 archive 완료된 3번 그룹 삭제)

SYS>!rm -rf /data/temp7/redo03*


SYS>!ls /data/temp7/redo03*

ls: /data/temp7/redo03*: #׷# #####̳# ###丮## ###


SYS>!ls /data/temp7

control01.ctl  example01.dbf  redo02_a.log  system01.dbf  undotbs01.dbf

control02.ctl  redo01_a.log   redo02_b.log  temp01.dbf    users01.dbf

control03.ctl  redo01_b.log   sysaux01.dbf  temp02.dbf


log switch를 수차례 발생시켜 hang 상태 유발
hang이 되면 ctrl + c로 취소함

SYS>alter system switch logfile;

System altered.

SYS>alter system switch logfile;

System altered.

SYS>alter system switch logfile;

System altered.

SYS>/

alter system switch logfile

*

ERROR at line 1:

ORA-01013: user requested cancel of current operation


SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   69 INACTIVE  NO

     1 /data/temp7/redo01_b.log                         5   69 INACTIVE  NO

     2 /data/temp7/redo02_a.log                        50   70 CURRENT NO

     2 /data/temp7/redo02_b.log                        50   70 CURRENT NO

     3 /data/temp7/redo03_a.log                        50   68 INACTIVE  NO

     3 /data/temp7/redo03_b.log                        50   68 INACTIVE  NO


6 rows selected.


archive 부분은 전부 no
오라클은 archiving를 순서대로 하기 때문에 3번 다음에 1번 그룹으로 넘어가야 하는데
3번 파일이 없으므로 아카이빙이 안되고 그 뒤에 나머지도 아카이브가 되지 않음을 볼 수 있음
가장 작은 시퀀스에서부터 멈춘 것을 알 수 있음

alert log확인 후 원인 파악하기

[oracle@localhost ~]$ vi $ORACLE_BASE/diag/rdbms/testdb/testdb/trace/alert_testdb.log

Errors in file /app/oracle/diag/rdbms/testdb/testdb/trace/testdb_arc0_5152.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/data/temp7/redo03_b.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/data/temp7/redo03_a.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Thu Nov 06 23:07:40 2014
Errors in file /app/oracle/diag/rdbms/testdb/testdb/trace/testdb_m000_5939.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/data/temp7/redo03_b.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/data/temp7/redo03_a.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

장애해결

[oracle@localhost ~]$ exit

exit


SYS>alter database clear unarchived logfile group 3;


Database altered.


SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   69 INACTIVE YES

     1 /data/temp7/redo01_b.log                         5   69 INACTIVE YES

     2 /data/temp7/redo02_a.log                        50   70 CURRENT  NO

     2 /data/temp7/redo02_b.log                        50   70 CURRENT  NO

     3 /data/temp7/redo03_a.log                        50    0 UNUSED   YES

     3 /data/temp7/redo03_b.log                        50    0 UNUSED   YES


6 rows selected.


복구 끝!

SYS>alter system switch logfile;

System altered.

SYS>alter system switch logfile;

System altered.

SYS>/

System altered.

SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5   72 INACTIVE YES
     1 /data/temp7/redo01_b.log                         5   72 INACTIVE YES
     2 /data/temp7/redo02_a.log                        50   73 CURRENT  NO
     2 /data/temp7/redo02_b.log                        50   73 CURRENT  NO
     3 /data/temp7/redo03_a.log                        50   71 INACTIVE YES
     3 /data/temp7/redo03_b.log                        50   71 INACTIVE YES

6 rows selected.

위 상황은 

11g 이상 해결법


아래 상황은

10g 이하 해결법 (추가 할 것)

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

temporary tablespace  (0) 2014.11.07
export/import 1 미완  (0) 2014.11.06
리두로그 장애2  (0) 2014.11.06
리두로그 장애1  (0) 2014.11.05
리두로그마이너 - 정리 덜됨...엉망임;;  (0) 2014.11.05
Posted by 성장하는yw
2014. 11. 6. 13:41

archive 완료된 그룹이 지워진 후 DB Close 상태


current 아닌 active / inactive 하나의 그룹이 삭제된 후 DB가 종료된 경우


이 상황에서는 DB가 오픈되지 않음


살펴봐야 할 것

archive 완료 여부 :  삭제된 그룹이 삭제 전에 다른 곳으로 저장(archive) 해두었다면 별다른 문제 생기지 않음


장애이유

오라클이 시작할 때 control file을 읽음->지정된 redo log file을 읽으려고 시도 : 현재 os에는 리두로그 파일이 없지만 control file 내용 내에는 redo log file의 경로가 있기때문에 오류가 남


해결책

실제 파일이 없으므로 control file에수 해당그룹의 명단은 삭제


 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>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   63 CURRENT  NO

     1 /data/temp7/redo01_b.log                         5   63 CURRENT  NO

     2 /data/temp7/redo02_a.log                         5   62 INACTIVE YES

     2 /data/temp7/redo02_b.log                         5   62 INACTIVE YES


redo log file 삭제 후 장애 확인
SYS>!rm /data/temp7/redo02*

SYS>!ls /data/temp7/*.log
/data/temp7/redo01_a.log  /data/temp7/redo01_b.log

SYS>shutdown immediate
Database closed.
Database dismounted.
ORA-01013: user requested cancel of current operation

강제 종료되었다는 메시지
SYS>startup
ORA-03113: end-of-file on communication channel
SYS>startup
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist

그룹이 삭제되면 오라클이 시작되지 않고 강제 종료 됨

[oracle@localhost ~]$ vi /app/oracle/diag/rdbms/testdb/testdb/trace/alert_testdb.log
vi로 열고  대문자 G를 입력하면 파일의 맨 끝 화면으로 이동함
Thu Nov 06 20:10:06 2014
Exception [type: SIGSEGV, Address not mapped to object] [ADDR:0x20006098] [PC:0x9A321FF, dbkdEventChk()+1503] [flags: 0x0, count: 1]
Errors in file /app/oracle/diag/rdbms/testdb/testdb/trace/testdb_ora_4295.trc  (incident=69601):
ORA-07445: exception encountered: core dump [dbkdEventChk()+1503] [SIGSEGV] [ADDR:0x20006098] [PC:0x9A321FF] [Address not mapped to object] []
Incident details in: /app/oracle/diag/rdbms/testdb/testdb/incident/incdir_69601/testdb_ora_4295_i69601.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.

어라... 그런데 startup이 안 됨
위 작업시에 shutdown immdiate를 하면서 
중간에  putty에서 복사를 한다고 마우스 오른쪽을 클릭하는 바람에
정상적으로 db가 종료가 된 것이 아니라 abort로 종료가 되었음
그래서 startup 안 됨

어쩔 수 없이 계속 db open 이 안되는 상황이라서
startup force : shutdown abort를 하고 startup를 하는 기능을 해준다.

SYS> startup force
마운트까지 됨
그런데도 db가 죽어서 sqlplus 접속 종료를 하고 sqlplus로 재접속했음
다시 sqlplus로 접속 후 startup mount해 줌

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Thu Nov 6 20:48:03 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SYS>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.

[oracle@localhost temp7]$ ls
control01.ctl  example01.dbf  sysaux01.dbf  temp02.dbf
control02.ctl  redo01_a.log   system01.dbf  undotbs01.dbf
control03.ctl  redo01_b.log   temp01.dbf    users01.dbf
[oracle@localhost temp7]$ exit
exit

SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5   63 CURRENT  NO
     1 /data/temp7/redo01_b.log                         5   63 CURRENT  NO
     2 /data/temp7/redo02_a.log                         5   62 INACTIVE YES
     2 /data/temp7/redo02_b.log                         5   62 INACTIVE YES

오라클에서 권장하는 최소는 그룹 2개에 멤버 1개씩인데 
여기서 내가 그룹2의 리두로그를 모두 지워버리면 이러한 원칙이 깨지게 된다. 
그래서 새로운 리두로그 그룹3을 추가하고 2를 삭제해야 한다.

SYS>alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01567: dropping log 2 would leave less than 2 log files for instance testdb (thread 1)
ORA-00312: online log 2 thread 1: '/data/temp7/redo02_a.log'
ORA-00312: online log 2 thread 1: '/data/temp7/redo02_b.log'


SYS>ed
Wrote file afiedt.buf

  1  alter database add logfile group 3(
  2  '/data/temp7/redo03_a.log',
  3 '/data/temp7/redo03_b.log') size 50m
  4  /

SYS>alter database drop logfile group 2;

Database altered.

SYS>alter database open;

Database altered.

SYS>select member from v$logfile;

MEMBER
---------------------------------------------
/data/temp7/redo01_a.log
/data/temp7/redo01_b.log
/data/temp7/redo03_a.log
/data/temp7/redo03_b.log

오픈이 된다. 복구 완료!

SYS>ed
Wrote file afiedt.buf

  1  alter database add logfile group 2
  2  ('/data/temp7/redo02_a.log',
  3* '/data/temp7/redo02_b.log') size 50m
SYS>/

Database altered.

다시 2를 추가해준다.

SYS>select member from v$logfile;

MEMBER
---------------------------------------------
/data/temp7/redo02_a.log
/data/temp7/redo02_b.log
/data/temp7/redo01_a.log
/data/temp7/redo01_b.log
/data/temp7/redo03_a.log
/data/temp7/redo03_b.log

6 rows selected.


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

export/import 1 미완  (0) 2014.11.06
리두로그 장애3  (0) 2014.11.06
리두로그 장애1  (0) 2014.11.05
리두로그마이너 - 정리 덜됨...엉망임;;  (0) 2014.11.05
컨트롤 파일복구 3-1  (0) 2014.11.04
Posted by 성장하는yw
2014. 11. 5. 19:10

1개의 멤버가 삭제되는 장애 발생


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.


log.sql 파일 내용
SYS>!vi log.sql
set line 200
col group# for 999
col mb for 999
col member for a45
col seq# for 999
col status for a8
col arc for a5

SELECT a.group#,a.member,b.bytes /1024/1024 MB, b.sequence# "SEQ#", b.status,
b.archived "ARC"
FROM v$logfile a,v$log b
where a.group#=b.group#
order by 1,2
/



SYS>!vi log.sql


SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   57 CURRENT  NO

     1 /data/temp7/redo01_b.log                         5   57 CURRENT  NO

     2 /data/temp7/redo02_a.log                         5   56 INACTIVE YES

     2 /data/temp7/redo02_b.log                         5   56 INACTIVE YES


redo01_a.log 삭제
[oracle@localhost ~]$ rm -f /data/temp7/redo01_a.log
[oracle@localhost ~]$ ls -al /data/temp7/*.log
-rw-r----- 1 oracle oinstall 5243392 Nov  6 02:49 /data/temp7/redo01_b.log
-rw-r----- 1 oracle oinstall 5243392 Nov  6 02:46 /data/temp7/redo02_a.log
-rw-r----- 1 oracle oinstall 5243392 Nov  6 02:46 /data/temp7/redo02_b.log

[oracle@localhost ~]$ exit
exit

SYS>alter system switch logfile;

System altered.

SYS>/

System altered.

SYS>/

System altered.

SYS>/

System altered.

파일을 지웠지만 있다고 나옴
SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5   61 CURRENT  NO
     1 /data/temp7/redo01_b.log                         5   61 CURRENT  NO
     2 /data/temp7/redo02_a.log                         5   60 INACTIVE YES
     2 /data/temp7/redo02_b.log                         5   60 INACTIVE YES

정확한 장애내용은 alert log 파일을 열어 확인

SYS>!

[oracle@localhost ~]$ vi  $ORACLE_BASE/diag/rdbms/testdb/testdb/trace/alert_testdb.log
...생략

Errors in file /app/oracle/diag/rdbms/testdb/testdb/trace/testdb_arc1_7763.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '/data/temp7/redo01_a.log'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

...생략

장애가 확인 된 멤버는 삭제 후 다시 생성하면 됨
SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5   61 CURRENT  NO
     1 /data/temp7/redo01_b.log                         5   61 CURRENT  NO
     2 /data/temp7/redo02_a.log                         5   60 INACTIVE YES
     2 /data/temp7/redo02_b.log                         5   60 INACTIVE YES

SYS>alter system switch logfile;

System altered.

SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5   61 ACTIVE   YES
     1 /data/temp7/redo01_b.log                         5   61 ACTIVE   YES
     2 /data/temp7/redo02_a.log                         5   62 CURRENT  NO
     2 /data/temp7/redo02_b.log                         5   62 CURRENT  NO


SYS>alter database drop logfile member
  2  '/data/temp7/redo01_a.log';

Database altered.

SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_b.log                         5   61 ACTIVE   YES
     2 /data/temp7/redo02_a.log                         5   62 CURRENT  NO
     2 /data/temp7/redo02_b.log                         5   62 CURRENT  NO

SYS>alter database add logfile member

  2  '/data/temp7/redo01_a.log' to group 1;


Database altered.


SYS>@log


GROUP# MEMBER                                          MB SEQ# STATUS   ARC

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

     1 /data/temp7/redo01_a.log                         5   61 INACTIVE YES

     1 /data/temp7/redo01_b.log                         5   61 INACTIVE YES

     2 /data/temp7/redo02_a.log                         5   62 CURRENT  NO

     2 /data/temp7/redo02_b.log                         5   62 CURRENT  NO





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

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

 supplemental 기능의 활성화 여부 확인

SYS>select supplemental_log_data_min from v$database;

비활성화 상태

SUPPLEME

--------

NO


활성화상태로 변경


SYS>alter database add supplemental log data;


Database altered.


SYS>select supplemental_log_data_min from v$database;


SUPPLEME

--------

YES


활성화->비활성화로 변경


SYS>alter database drop supplemental log data;


Database altered.



SYS>select supplemental_log_data_min from v$database;


SUPPLEME

--------

NO


이 기능은 DB 전체를 대상으로 적용할 수 있고,혹은 특정테이블만 적용가능

특정테이블만 적용하기

SYS>alter table scott.emp add supplemental log data (all) columns;

Table altered.
 
이 기능을 사용할 경우 리두로그 생성양이 많아지므로 아카이브 로그 모드를 사용할 때는
아카이브 용량을 충분하게 주고 사용해야 함 

log miner 활용하기
- drop table 정보 찾기

SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5    3 CURRENT  NO
     1 /data/temp7/redo01_b.log                         5    3 CURRENT  NO
     2 /data/temp7/redo02_a.log                         5    2 INACTIVE YES
     2 /data/temp7/redo02_b.log                         5    2 INACTIVE YES

SYS>select supplemental_log_data_min from v$database;


SUPPLEME

--------

NO



SYS>alter database add supplemental log data;


Database altered.


활성화 상태에서 실습
SYS>select supplemental_log_data_min from v$database;

SUPPLEME
--------
YES

새로운 테이블 생성 후 데이터 입력, 삭제하기
SYS>create table scott.test1 (no number);

Table created.

SYS>insert into scott.test1 values(1);

1 row created.


SYS>commit;

Commit complete.

SYS>drop table scott.test1 purge;

Table dropped.

SYS>@log

GROUP# MEMBER                                          MB SEQ# STATUS   ARC
------ --------------------------------------------- ---- ---- -------- -----
     1 /data/temp7/redo01_a.log                         5    3 CURRENT  NO
     1 /data/temp7/redo01_b.log                         5    3 CURRENT  NO
     2 /data/temp7/redo02_a.log                         5    2 INACTIVE YES
     2 /data/temp7/redo02_b.log                         5    2 INACTIVE YES

테이블이 생성되고 데이터 입력, 삭제 된 내용이 1번 그룹에 들어가 있음을 current 로 확인할 수 있음

로그 딕셔너리 생성
방법
1 online  
2
3

db 종료 후 파라미터 파일의 딕셔너리 파일 경로 지정
SYS>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@localhost ~]$ mkdir /data/logminer
파일에 아래 내용 추가
[oracle@localhost ~]$ vi $ORACLE_HOME/dbs/inittestdb.ora
utl_file_dir=/data/logminer 

db시작

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>exec dbms_logmnr_d.build(dictionary_filename=>'dict.dbt',-
> dictionary_location=>'/app/oracle/logminer');
log miner에 분석할 로그를 추가

딕셔너리 생성시 경로를 변경하고 싶으면 위와 같은 명령어를 그대로 치고, 
경로만 바꾸어 주면 됨
SYS>exec dbms_logmnr_d.build(dictionary_filename=>'dict.dat', dictionary_location=>'/data/logminer');
PL/SQL procedure successfully completed.



PL/SQL procedure successfully completed.


SYS>exec dbms_logmnr.add_logfile('/data/temp7/redo01_a.log',1); 

PL/SQL procedure successfully completed.

분석시 add_logfilelsl('분석할 리두 경로',숫자옵션)
1 신규생성
2 파일삭제
3 추가등록

2번 그룹에 로그파일을 추가로 등록함

SYS>exec dbms_logmnr.add_logfile('/data/temp7/redo01_a.log',1);

PL/SQL procedure successfully completed.

SYS>exec dbms_logmnr.add_logfile('/data/temp7/redo02_a.log',3);

PL/SQL procedure successfully completed.


등록한 리두로그마이너 삭제할 때

SYS>exec dbms_logmnr.add_logfile('/data/temp7/redo02_b.log',2);

PL/SQL procedure successfully completed.


그룹이 있으면 그 그룹 중에 멤버 하나만 등록하면 리두마이너가 등록이 된다.
한 그룹에 어차피 여러 멤버가 있어서 등록하려고 하면 복사본이라고 에러뜸
그룹당 하나만 리두로그마이너 등록할 수 있음
 
ERROR at line 1:
ORA-01289: cannot add duplicate logfile /data/temp7/redo01_b.log
ORA-06512: at "SYS.DBMS_LOGMNR", line 68
ORA-06512: at line 1


확인

SYS>set line 200
SYS>col db_name for a15
SYS>col filename for a50
SYS>select db_name, filename from v$logmnr_logs;

DB_NAME         FILENAME
--------------- --------------------------------------------------
TESTDB          /data/temp7/redo01_a.log
TESTDB          /data/temp7/redo02_a.log

*대량의 아카이브 리두 로그파일을 분석해야 할 경우 일일이 수동으로 등록하기에 시간이 오래 걸리므로
아래와 같이 스크립트를 생생해서 등록 작업 설정을 쉽게 할 수 있음
[oracle@localhost ~]$ vi ar.sh
for
for i in $(ls /data/arc2);
for i in $(ls 아카이브가 있는 현재경로);
 do echo "exec dbms_logmnr.add_logfile('아카이브 파일이 있는 현재경로/$i',3);" >> /home/oracle/arch.sql;
done;

wq!

[oracle@localhost ~]$ sh ar.sh
파일을 열어보면 명령어가 생성된 것을 확인 할 수 있음 
[oracle@localhost ~]$ vi /home/oracle/arch.sql
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_10_b5ldx374_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_1_b5lgngbh_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_29_b5l414vm_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_2_b5mxx2on_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_3_b5n7wdy1_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_6_b5l00zkp_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_7_b5l0373g_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_8_b5l03lhl_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_8_b5lboj3h_.arc',3);
exec dbms_logmnr.add_logfile('/app/oracle/fast_recovery_area/TESTDB/archivelog/2014_11_05/o1_mf_1_9_b5lboo35_.arc',3);
~
~
~
"~/arch.sql" 10L, 1192C                                       1,1           All


주의!!! 테스트 환경을 만들때, 오라클 설치 파일경로인 /app/oracle 에 남은 용량이 많이 없어서 위와 같이 

작업을 하게 되면 나중에 리두로그마이너가 많이 생겨서 용량이 부족하다는 에러가 생길수도 있음. 

그래서 나는 아카이브 경로를 용량이 많은 다른 경로로 이동해 주겠다.

pfile을 사용하는 경우


[oracle@localhost ~]$ vi $ORACLE_HOME/dbs/inittestdb.ora


#아카이브 로그 파일 저장경로와 이름 지정

log_archive_dest_1='location=/data/arc1'

log_archive_dest_2='location=/data/arc2'

log_archive_format=%s_%t_%r.arc #아카이브 로그파일 이름지정#

:wq!

11g 환경에서 오라클은 기본으로 4G의 용량을 주고 아카이브 파일을 저장한다
하지만 내가 파일을 만들어서 주는 것은 내 마음대로 용량을 줄 수 있음
두 개의 파일은 다중화가 되서 아카이브 파일이 같이 들어감

확인방법

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 switch logfile;


System altered.


[oracle@localhost arc1]$ ls

4_1_862809266.arc  5_1_862809266.arc

[oracle@localhost arc2]$ ls

4_1_862809266.arc  5_1_862809266.arc


위 파일의 명령을 실행시켜주면 됨

SYS>@/app/oracle/arch.sql 




[oracle@localhost ~]$ vi ar.sh

for i in $(ls /data/arc1);

 do echo "exec dbms_logmnr.add_logfile('/data/arc1/$i',3);" >> /home/oracle/arch.sql;

done;

wq!

[oracle@localhost ~]$ sh ar.sh

[oracle@localhost ~]$ vi /home/oracle/arch.sql

exec dbms_logmnr.add_logfile('/data/arc1/4_1_862809266.arc',3);

exec dbms_logmnr.add_logfile('/data/arc1/5_1_862809266.arc',3);


SYS>@/home/oracle/arch.sql

PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.

로그마이너를 시작해서 log를 분석한 후 결과 조회



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

157


SYS>select supplemental_log_data_min from v$database;


SUPPLEME

--------

YES


SYS>create table scott.test2(no number, name varchar2(10));


Table created.


SYS>insert into scott.test2 values(1,'AAA');


1 row created.


SYS>insert into scott.test2 values(2,'BBB');


1 row created.


SYS>insert into scott.test2 values(3,'CCC');


1 row created.


SYS>commit;


Commit complete.


SYS>select * from scott.test2;


        NO NAME

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

         1 AAA

         2 BBB

         3 CCC


SYS>update scott.test2 set name='DDD';


3 rows updated.


SYS>select * from scott.test2;


        NO NAME

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

         1 DDD

         2 DDD

         3 DDD


SYS>commit;


Commit complete.


SYS>show parameter utl


NAME                                 TYPE        VALUE

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

create_stored_outlines               string

utl_file_dir                         string      /data/logminer

SYS>exec dbms_logmnr_d.build(dictionary_filename=>'/dict2.dat',dictionary_location=>'/data/logminer');


PL/SQL procedure successfully completed.




SYS>exec dbms_logmnr.start_logmnr(dictfilename=>'/data/logminer/dict2.dat');


PL/SQL procedure successfully completed.


SYS>col username for a10

SYS>col operation for a10

SYS>col sql_redo for a70

SYS>set pagesize 50

SYS>alter session set nls_date_format='yyyy-mm-dd:hh24:mi:ss';


Session altered.


SYS>select timestamp, username, operation, sql_redo

  2  from v$logmnr_contents

  3  where seg_name='TEST2';


TIMESTAMP           USERNAME   OPERATION  SQL_REDO

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

2014-11-06:02:19:14 SYS        DDL        create table scott.test2(no number, name varchar2(10));

2014-11-06:02:19:47 SYS        INSERT     insert into "SCOTT"."TEST2"("NO","NAME") values ('1','AAA');

2014-11-06:02:20:08 SYS        INSERT     insert into "SCOTT"."TEST2"("NO","NAME") values ('2','BBB');

2014-11-06:02:21:23 SYS        INSERT     insert into "SCOTT"."TEST2"("NO","NAME") values ('3','CCC');

2014-11-06:02:21:44 SYS        UPDATE     update "SCOTT"."TEST2" set "NAME" = 'DDD' where "NAME" = 'AAA' and ROW

                                          ID = 'AAASm+AAEAAAAMnAAA';


2014-11-06:02:21:44 SYS        UPDATE     update "SCOTT"."TEST2" set "NAME" = 'DDD' where "NAME" = 'BBB' and ROW

                                          ID = 'AAASm+AAEAAAAMnAAB';


2014-11-06:02:21:44 SYS        UPDATE     update "SCOTT"."TEST2" set "NAME" = 'DDD' where "NAME" = 'CCC' and ROW

                                          ID = 'AAASm+AAEAAAAMnAAC';



7 rows selected.



리두로그 마이너는 세션별로 볼 수 있다. 
세션창을 끄고 나오거나 셧다운 다른 창에서는 그 해당하는 리두로그 마이너의 결과를 볼 수 없다. 
심지어... 창을 끄고 다시 접속하면 로그파일도 다 등록해줘야함..;;


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

리두로그 장애2  (0) 2014.11.06
리두로그 장애1  (0) 2014.11.05
컨트롤 파일복구 3-1  (0) 2014.11.04
컨트롤 파일 복구 3  (0) 2014.11.04
컨트롤 파일복구 2  (0) 2014.11.04
Posted by 성장하는yw
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
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