2014. 10. 26. 22:01

1 컨트롤 파일 / 다중화 의미

- control file :  오라클 서버를 운영하는데 필수적인 정보들이 저장되어 있음

                       instance가 mount 이상의 상태일 때부터 실시간으로 control file의 내용이 변경, 조회됨

                       이 파일이 깨지면 DB가 망가짐

                       파일삭제 등 문제가 생기더라도 복구 할 수 있도록 복사본을 만들어 분산시켜 저장함 (multiplexing 다중화)


2. 작동 순서와 다중화 하는 방법

- 작동순서

startup - parameter file 읽어서 control file의 위치 확인 - control file을 메모리로 불러와 내용 확인 


- 다중화하는 방법 

parameter file에 control file의 위치를 기록한 후 그 경로에  control file을 복사하면 다중화가 됨 


* spfile 일 경우 다중화하는 방법


- 실습예제 

현재 운영중인 control file의 경로 확인 후

/home/oracle/disk1/control01.ctl

/home/oracle/disk2/control02.ctl

/home/oracle/disk3/controlo03.ctl 로 다중화(복사)


- 하는 순서

1. DB 상태 확인

2. 현재 운영중인 control file의 경로 확인

3. spfile경로 변경

4. instance 종료

5. 대상 디렉토리 생성 및 컨트롤 파일을 spfile 수정한 경로로 생성

6. instance  open -> startup


간략히 

spfile의 내용 변경 -> instance 종료 -> control file 복사 -> instance open


- 과정

현재 db 상태 확인

SYS>select status from v$instance;


STATUS

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

OPEN


spfile 인지 pfile 인지 확인

SYS>show parameter spfile;


NAME     TYPE VALUE

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

spfile     string /app/oracle/product/11g/dbs/sp

filetestdb.ora


한 화면에 보기 위해서 칼럼 크기 조정
SYS>col name for a70

control file의 현재경로 조회
SYS>select name from v$controlfile;

NAME
----------------------------------------------------------------------
/app/oracle/oradata/testdb/control01.ctl
/home/oracle/fast_recovery_area/testdb/control02.ctl

spfile안에 기록 되어있는 control file의 경로 변경
SYS>alter system set control_files='/home/oracle/disk1/control01.ctl',
  2  '/home/oracle/disk2/control02.ctl',
  3  '/home/oracle/disk3/control03.ctl' scope=spfile;

System altered.

db instance 종료
SYS>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

sqlplus을 종료하지 않고 터미널창(리눅스커맨드창)으로 이동
SYS>!
[oracle@localhost ~]$ cd /home/oracle
디렉토리 생성
[oracle@localhost ~]$ mkdir disk1 disk2 disk3



spfile 변경 경로에 컨트롤 파일을 복사해 옴
[oracle@localhost ~]$ cp /app/oracle/oradata/testdb/control01.ctl /home/oracle/disk1/control01.ctl
[oracle@localhost ~]$ cp /app/oracle/oradata/testdb/control01.ctl /home/oracle/disk2/control02.ctl
[oracle@localhost ~]$ cp /app/oracle/oradata/testdb/control01.ctl /home/oracle/disk3/control03.ctl

*컨트롤 파일은 여러 곳에 분산이 되어도 내용은 모두 동일해야함
그래서 아래 처럼 control01을 3곳으로 이름을 바꾸어서 복사를 해도 아무런 문제가 없음

리눅스 명령창에서 나와서 sqlplus로 이동
[oracle@localhost ~]$ exit
exit

db instance 시작
SYS>startup
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size    1344616 bytes
Variable Size  322964376 bytes
Database Buffers   92274688 bytes
Redo Buffers    6086656 bytes
Database mounted.
Database opened.

변경된 컨트롤 파일 경로 확인
SYS>select name from v$controlfile;

NAME
----------------------------------------------------------------------
/home/oracle/disk1/control01.ctl
/home/oracle/disk2/control02.ctl
/home/oracle/disk3/control03.ctl



* pfile 일 경우 다중화하는 방법


현재 spfile을 사용하는 상태 -> pfile 생성 -> spfile 삭제 -> instance 재시작 후 다중화 작업을 함

조회한 컨트롤 파일 위치를 아래 경로로 다중화

/home/oracle/disk4/control01.ctl

/home/oracle/disk5/control01.ctl

/home/oracle/disk6/control01.ctl


SYS>!ls $ORACLE_HOME/dbs

hc_DBUA0.dat  hc_testdb.dat  init.ora  lkTESTDB  orapwtestdb  spfiletestdb.ora


SYS>create pfile from spfile;


File created.


SYS>!rm -f $ORACLE_HOME/dbs/spfiletestdb.ora


SYS>!ls $ORACLE_HOME/dbs

hc_DBUA0.dat  hc_testdb.dat  init.ora  inittestdb.ora  lkTESTDB  orapwtestdb


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  322964376 bytes

Database Buffers   92274688 bytes

Redo Buffers    6086656 bytes

Database mounted.

Database opened.


pfil 확인, 아래 조회내용에서 value 부분에 아무것도 나오지 않으면 pfile

SYS>show parameter pfile;


NAME     TYPE VALUE

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

spfile     string


SYS>select name from v$controlfile;


NAME

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

/home/oracle/disk1/control01.ctl

/home/oracle/disk2/control02.ctl

/home/oracle/disk3/control03.ctl


SYS>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.


SYS>!vi $ORACLE_HOME/dbs/inittestdb.ora

testdb.__db_cache_size=92274688

testdb.__java_pool_size=4194304

testdb.__large_pool_size=4194304

testdb.__oracle_base='/app/oracle'#ORACLE_BASE set from environment

testdb.__pga_aggregate_target=155189248

testdb.__sga_target=268435456

testdb.__shared_io_pool_size=0

testdb.__shared_pool_size=159383552

testdb.__streams_pool_size=0

*.audit_file_dest='/app/oracle/admin/testdb/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'


주석처리 한 부분을 파란색 글씨처럼 원하는 경로로 수정해줌

#*.control_files='/home/oracle/disk1/control01.ctl','/home/oracle/disk2/control02.ctl','/home/oracle/disk3/control03.ctl'

*.control_files='/home/oracle/disk4/control01.ctl','/home/oracle/disk5/control02.ctl','/home/oracle/disk6/control03.ctl'


*.db_block_size=8192

*.db_domain=''

*.db_name='testdb'

*.db_recovery_file_dest='/home/oracle/fast_recovery_area'

*.db_recovery_file_dest_size=4196401152

*.diagnostic_dest='/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=testdbXDB)'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=422576128

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

~                                                                                                                  

"/app/oracle/product/11g/dbs/inittestdb.ora" 26L, 950C


:wq!


SYS>!

[oracle@localhost ~]$ cd /home/oracle

[oracle@localhost ~]$ mkdir disk4 disk5 disk6

[oracle@localhost ~]$ cp /home/oracle/disk1/control01.ctl /home/oracle/disk4/control01.ctl

[oracle@localhost ~]$ cp /home/oracle/disk1/control01.ctl /home/oracle/disk5/control02.ctl

[oracle@localhost ~]$ cp /home/oracle/disk1/control01.ctl /home/oracle/disk6/control03.ctl

[oracle@localhost ~]$ exit

exit


SYS>startup

ORACLE instance started.


Total System Global Area  422670336 bytes

Fixed Size    1344616 bytes

Variable Size  322964376 bytes

Database Buffers   92274688 bytes

Redo Buffers    6086656 bytes

Database mounted.

Database opened.

SYS>select name from v$controlfile;


NAME

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

/home/oracle/disk4/control01.ctl

/home/oracle/disk5/control02.ctl

/home/oracle/disk6/control03.ctl



pfile을 사용, 컨트롤파일을 다중화 하는 경우는 복사하고 경로를 수정해줘도 전혀 문제가 없지만

spfile일 때, 나머지 과정들은 꼭 순서대로 해야만 한다. 

장애 생김


컨트롤 파일에 변경되는 정보가 실시간으로 저장 되기 때문에 가장 최근에 사용한 것만 진짜 컨트롤 파일이고 

나머지 컨트롤 파일은 예전파일로 변한다. 

이동이나 복사를 할 때, 가장 최근에 사용했던것만 사용해야 한다.

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

dbms_job / dbms_scheduler  (0) 2014.10.27
사용자관리  (0) 2014.10.27
oracle의 시작단계  (0) 2014.10.26
3 oracle background processes  (0) 2014.10.24
9 메모리 관리 기법  (0) 2014.10.24
Posted by 성장하는yw