DevJoy 2025. 11. 27. 21:12

초기 파라미터 파일(Cont.)

기본값으로 재설정

SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'sort_area_size';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
sort_area_size                 1048576                        65536                          DEFERRED

# 기본값으로 재설정
SYS@ora19c> alter system reset sort_area_size SCOPE=SPFILE;

System altered.

# 변경사항을 바로 적용하려는 경우 sort_area_size 파라미터는 deferred 파라미터이기 때문에 
# deferred 키워드 필요
SYS@ora19c> alter system reset sort_area_size scope=both;
alter system reset sort_area_size scope=both
*
ERROR at line 1:
ORA-02096: specified initialization parameter is not modifiable with this
option

# deferred 키워드는 scope 전에 붙여야 함
SYS@ora19c> alter system reset sort_area_size scope=both deferred;
alter system reset sort_area_size scope=both deferred
                                             *
ERROR at line 1:
ORA-00933: SQL command not properly ended

# 기본값으로 재설정
SYS@ora19c> alter system reset sort_area_size deferred scope = both;

System altered.

# deferred 이기 때문에 기존 세션에서는 변경사항 적용 안됨
SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'sort_area_size';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
sort_area_size                 1048576                        65536                          DEFERRED
# 새 세션에서 조회 -> 기본 값으로 변경됨
SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'sort_area_size';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
sort_area_size                 65536                          65536                          DEFERRED

SQL*Plus 자주 사용하는 포맷 지정

[oracle@ora19c admin]$ vi $ORACLE_HOME/sqlplus/admin/glogin.sql

set sqlprompt "_user'@'_connect_identifier> "
set linesize 200
col name format a30
col value format a30
col default_value format a30

PFILE 생성

# pfile 생성
SYS@ora19c> create pfile from spfile;

File created.

SYS@ora19c> !
[oracle@ora19c ~]$ cd $ORACLE_HOME/dbs
[oracle@ora19c dbs]$ ls
hc_ora19c.dat  initora19c.ora  orapwora19c
init.ora       lkORA19C        spfileora19c.ora
# spfile 이름 변경으로 없애기
[oracle@ora19c dbs]$ mv spfileora19c.ora spfileora19c.bak
# pfile로 데이터베이스 시작
SYS@ora19c> startup
ORACLE instance started.

Total System Global Area  830469472 bytes
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.
SYS@ora19c> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'open_cursors';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
open_cursors                   100                            50                             IMMEDIATE

# pfile을 사용중일 때는 파라미터 변경 시 scope = spfile, both 사용 불가
SYS@ora19c> alter system set open_cursors = 200 scope = both;
alter system set open_cursors = 200 scope = both
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE is in use

# 현재 인스턴스(메모리)에서만 변경 가능
SYS@ora19c> alter system set open_cursors = 200 scope = memory;

System altered.

SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'open_cursors';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
open_cursors                   200                            50                             IMMEDIATE

# 데이터베이스 종료 후 재시작
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ora19c> startup
ORACLE instance started.

Total System Global Area  830469472 bytes
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.

# 원래 값으로 돌아옴 -> 메모리에서만 변경하고 초기 파라미터 파일은 변경하지 않았기 때문에
SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'open_cursors';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
open_cursors                   100                            50                             IMMEDIATE

PFILE 파라미터 수정

[oracle@ora19c dbs]$ vi $ORACLE_HOME/dbs/initora19c.ora

# 데이터베이스 재시작
SYS@ora19c> startup
ORACLE instance started.

Total System Global Area  830469472 bytes
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.

# 변경한 파라미터 값으로 적용됨
SYS@ora19c> select name, value, default_value, issys_modifiable from v$parameter where name = 'open_cursors';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
open_cursors                   200                            50                             IMMEDIATE

SPFILE 생성

# SPFILE 생성
SYS@ora19c> create spfile from pfile;

File created.

SYS@ora19c> !
[oracle@ora19c dbs]$ ls
hc_ora19c.dat  init.ora  initora19c.ora  lkORA19C  orapwora19c  spfileora19c.bak  spfileora19c.ora
[oracle@ora19c dbs]$ exit
exit

# 데이터베이스 종료 후 재시작
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ora19c> startup
ORACLE instance started.

Total System Global Area  830469472 bytes
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.

# SPFILE 사용
SYS@ora19c> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/19.3.0
                                                 /dbhome_1/dbs/spfileora19c.ora

PFILE로 STARTUP

SYS@ora19c> startup pfile=$ORACLE_HOME/dbs/initora19c.ora
ORACLE instance started.

Total System Global Area  830469472 bytes
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.
SYS@ora19c> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string

다른 위치에 SPFILE 생성

# 다른 위치에 spfile 생성
SYS@ora19c> create spfile='/home/oracle/spfileora19c.ora' from pfile;

File created.

SYS@ora19c> !
[oracle@ora19c dbs]$ cd /home/oracle
[oracle@ora19c ~]$ ls
LINUX.X64_193000_db_home.zip  spfileora19c.ora

[oracle@ora19c ~]$ vi $ORACLE_HOME/dbs/initora19c.ora

# 내용 전체 삭제 후 spfile 위치만 저장
spfile=/home/oracle/spfileora19c.ora

[oracle@ora19c ~]$ exit
exit

# 다른 위치에 저장된 spfile 위치 정보를 가지는 pfile로 db 시작
SYS@ora19c> startup pfile=$ORACLE_HOME/dbs/initora19c.ora
ORACLE instance started.

Total System Global Area  830469472 bytes
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.
SYS@ora19c> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /home/oracle/spfileora19c.ora

SGA(System Global Area)

  • 모든 오라클 프로세스가 액세스 하는 공유 메모리
  • SGA 메모리는 SGA_MAX_SIZE 로 설정
  • SGA_MAX_SIZE 파라미터는 SGA 총 메모리 사이즈를 설정하는 파라미터(static parameter)
  • SGA 영역에 있는 구성 요소들은 데이터베이스 운영 중에 동적으로 설정 가능
SYS@ora19c> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_max_size                         big integer 792M

SYS@ora19c>  select name, value, default_value, issys_modifiable from v$parameter where name = 'sga_max_size';

NAME                           VALUE                          DEFAULT_VALUE                  ISSYS_MOD
------------------------------ ------------------------------ ------------------------------ ---------
sga_max_size                   830472192                      0                              FALSE

SGA 메모리 구성

SYS@ora19c> show sga

Total System Global Area  830469472 bytes # sga_max_size
Fixed Size                  8901984 bytes
Variable Size             562036736 bytes
Database Buffers          251658240 bytes
Redo Buffers                7872512 bytes

Fixed Size

  • Fixed SGA
  • 백그라운드 프로세스가 액세스하는 데이터베이스 및 인스턴스 상태에 대한 일반 정보
  • Fixed size는 오라클이 관리
  • 오라클이 내부적으로 사용하는 메모리 공간

Variable Size

  • Shared Pool
  • Large Pool
  • Java Pool
  • Streams Pool

Database Buffers

  • Database(Data) Buffer Cache

Redo Buffers

  • Redo Log Buffer

오라클 아키텍처