251201 TIL
2025. 12. 1. 18:29ㆍCourses/아이티윌 오라클 DBA 과정
백그라운드 프로세스(Cont.)

LGWR(Cont.)
- Redo Log 파일은 순환 형식
- 1번 파일이 다 차면 2번 파일 → 2번 파일이 다 차면 3번 파일 → 3번 파일이 다 차면 다시 1번 파일
CKPT(Checkpoint)
Database Concepts
This chapter explains the nature of an Oracle database instance, the parameter and diagnostic files associated with an instance, and what occurs during instance creation and the opening and closing of a database.
docs.oracle.com

- checkpoint event 발생 시점에 DBWR에게 시그널 전송
- checkpoint 정보를 데이터 파일 헤더, control file에 갱신
- Data Buffer Cache에 있는 dirty buffer(변경된 블록)를 정기적으로 데이터 파일에 기록함으로써 시스템이나 데이터베이스에 failure가 발생한 경우 데이터가 손실되지 않도록 함
- instance recovery에 필요한 시간 단축
- 마지막 체크 포인트 이후에 redo log file에 있는 redo entry에 대해서만 recovery를 수행하면 됨
- 체크 포인트 정보 : 체크 포인트 시간, SCN, recovery를 시작할 redo log file 위치, redo log 정보
[oracle@ora19c ~]$ ps -ef | grep ckpt
oracle 3995 1 0 Nov26 ? 00:00:20 ora_ckpt_ora19c
체크 포인트가 발생하는 경우
- Full Checkpoint
- 데이터베이스를 정상 종료했을 때 :
shutdown [ normal | transactional | immediate ] alter system checkpoint;alter database begin backup;
- 데이터베이스를 정상 종료했을 때 :
- Partial Checkpoint
- log switch 발생 시 → 가장 자주 발생
alter tablespace users offline normal;alter tablespace users read only;alter tablespace users begin backup;drop table hr.emp;truncate table hr.emp;- parallel query :
select /*+ full(e) parallel(e,2) */ from hr.emp e;
- Incremental Checkpoint
fast_start_mttr_target: instance recovery 시간을 제어하는 파라미터- mttr = Mean Time To Recover = 평균 복구 시간
- instance failure가 발생한 경우 recovery 시간을 제어
- 복구에 필요한 시간이 fast_start_mttr_target 값보다 오래 걸린다면 DBWR에 시그널 전달
→ DBWR가 가장 오래 된 더티 블록부터 데이터 파일에 기록 - 최대 3600초(1시간)까지 설정 가능
- 3초마다 복구 시간이 fast_start_mttr_target를 넘는지 확인
log_checkpoints_to_alert: 체크포인트 정보를 alert_SID.log에 기록하는 파라미터- true인 경우에만 체크 포인트 정보를 기록 -> true로 설정하기
SYS@ora19c> show parameter fast_start_mttr_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fast_start_mttr_target integer 0
select * from v$parameter where name = 'fast_start_mttr_target';
alter system set fast_start_mttr_target = 600;
show parameter log_checkpoints_to_alert
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_checkpoints_to_alert boolean TRUE
select * from v$parameter where name = 'log_checkpoints_to_alert';
-- true인 경우에만 체크 포인트 정보를 기록 -> true로 설정하기
alter system set log_checkpoints_to_alert = true;
SCN 조회
select checkpoint_change#, current_scn from v$database; -- 2467344
select name, checkpoint_change# from v$datafile; -- 2467344
select * from v$log;


SMON(System Monitor)
- Instance Recovery를 수행하는 백그라운드 프로세스
- 디스크 조각 모음
- 임시 블록 세그먼트들을 재사용할 수 있도록 하는 역할
[oracle@ora19c ~]$ ps -ef | grep smon
oracle 3999 1 0 Nov26 ? 00:00:02 ora_smon_ora19c
PMON(Process Monitor)
- User Process가 실패할 경우
- 유저가 수행 중이던 트랜잭션은 자동 rollback
- 사용하고 있던 리소스 자동 해제
- 사용하고 있던 데이터 버퍼 캐시 블록 정리
- lock 해제
- Listener에게 DB정보를 등록시키는 작업
- 12c부터는 LREG(Listener Registration Process) 백그라운드 프로세스 작업으로 변경됨
[oracle@ora19c ~]$ ps -ef | grep pmon
oracle 3956 1 0 Nov26 ? 00:00:05 ora_pmon_ora19c
[oracle@ora19c ~]$ ps -ef | grep lreg
oracle 4011 1 0 Nov26 ? 00:00:03 ora_lreg_ora19c
Control File
- 작은 binary file
- 물리적 데이터베이스 현재 상태 정보
- 필요한 경우 : 데이터베이스 시작하는 동안 mount 상태일 때 , 데이터베이스 운영할 때
- 손실된 경우 복구 필요
- control file은 다중화하자
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl, /u01/app/oracl
e/fast_recovery_area/ORA19C/co
ntrol02.ctl
select * from v$controlfile;

-- False, 정적파라미터
select issys_modifiable from v$parameter where name = 'control_files';
Control file 내용
- 데이터베이스 이름, 식별자, 생성 시간
- 테이블스페이스 정보, 데이터 파일, 리두 로그 정보, 리두 로그 파일
- 체크포인트 정보, scn 정보
- 백업 정보
- archivelog mod, noarchivelog mod
Control file 다중화
SPFILE 이용 중일 경우
# 초기 파라미터 파일 종류 확인
SYS@ora19c> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/19.3.0
/dbhome_1/dbs/spfileora19c.ora
# control_files 파라미터 조회
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl, /u01/app/oracl
e/fast_recovery_area/ORA19C/co
ntrol02.ctl
# control_files 파라미터 설정
SYS@ora19c> alter system set control_files = '/u01/app/oracle/oradata/ORA19C/control01.ctl','/u01/app/oracle/fast_recovery_area/ORA19C/control02.ctl','/home/oracle/control03.ctl' scope = spfile;
System altered.
# 데이터베이스 정상 종료
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
# 기존 컨트롤 파일을 새로운 위치로 복사
SYS@ora19c> ! cp -v /u01/app/oracle/oradata/ORA19C/control01.ctl /home/oracle/control03.ctl
‘/u01/app/oracle/oradata/ORA19C/control01.ctl’ -> ‘/home/oracle/control03.ctl’
# 데이터베이스 시작
SYS@ora19c> startup
ORACLE instance started.
Total System Global Area 830469472 bytes
Fixed Size 8901984 bytes
Variable Size 595591168 bytes
Database Buffers 218103808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
# control_files 파라미터 조회
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl, /u01/app/oracl
e/fast_recovery_area/ORA19C/co
ntrol02.ctl, /home/oracle/cont
rol03.ctl
원상복구
# control_files 설정
SYS@ora19c> alter system set control_files = '/u01/app/oracle/oradata/ORA19C/control01.ctl','/u01/app/oracle/fast_recovery_area/ORA19C/control02.ctl' scope = spfile;
System altered.
# 데이터베이스 정상 종료
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
# controlfile 삭제(control03.ctl)
SYS@ora19c> !
[oracle@ora19c ~]$ ls
control03.ctl LINUX.X64_193000_db_home.zip spfileora19c.ora
[oracle@ora19c ~]$ rm control03.ctl
[oracle@ora19c ~]$ ls
LINUX.X64_193000_db_home.zip spfileora19c.ora
[oracle@ora19c ~]$ exit
exit
# 데이터베이스 재시작
SYS@ora19c> startup
ORACLE instance started.
Total System Global Area 830469472 bytes
Fixed Size 8901984 bytes
Variable Size 595591168 bytes
Database Buffers 218103808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
# # control_files 조회
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl, /u01/app/oracl
e/fast_recovery_area/ORA19C/co
ntrol02.ctl
PFILE 이용 중일 경우
SYS@ora19c> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/19.3.0
/dbhome_1/dbs/spfileora19c.ora
# 데이터베이스 정상 종료
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
# spfile 이름 변경으로 없애기
SYS@ora19c> !
[oracle@ora19c ~]$ cd $ORACLE_HOME/dbs
[oracle@ora19c dbs]$ ls
hc_ora19c.dat initora19c.ora orapwora19c spfileora19c.ora
init.ora lkORA19C spfileora19c.bak
[oracle@ora19c dbs]$ rm spfileora19c.bak
[oracle@ora19c dbs]$ mv spfileora19c.ora spfileora19c.bak
[oracle@ora19c dbs]$ ls
hc_ora19c.dat initora19c.ora orapwora19c
init.ora lkORA19C spfileora19c.bak
[oracle@ora19c dbs]$ exit
exit
# 데이터베이스 재시작
SYS@ora19c> startup
ORACLE instance started.
Total System Global Area 830469472 bytes
Fixed Size 8901984 bytes
Variable Size 595591168 bytes
Database Buffers 218103808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
# pfile로 실행 중
SYS@ora19c> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
# 데이터베이스 정상 종료
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
# pfile control_files 부분 수정
SYS@ora19c> !
[oracle@ora19c ~]$ cd $ORACLE_HOME/dbs
[oracle@ora19c dbs]$ ls
hc_ora19c.dat init.ora initora19c.ora lkORA19C orapwora19c spfileora19c.bak
[oracle@ora19c dbs]$ vi initora19c.ora

# 기존 control file 복사(control03.ctl 생성)
[oracle@ora19c dbs]$ cd
[oracle@ora19c ~]$ ls
LINUX.X64_193000_db_home.zip spfileora19c.ora
[oracle@ora19c ~]$ cp -v /u01/app/oracle/oradata/ORA19C/control01.ctl /home/oracle/control03.ctl
‘/u01/app/oracle/oradata/ORA19C/control01.ctl’ -> ‘/home/oracle/control03.ctl’
[oracle@ora19c ~]$ ls
control03.ctl LINUX.X64_193000_db_home.zip spfileora19c.ora
[oracle@ora19c ~]$ exit
exit
# 데이터베이스 재시작
SYS@ora19c> startup
ORACLE instance started.
Total System Global Area 830469472 bytes
Fixed Size 8901984 bytes
Variable Size 595591168 bytes
Database Buffers 218103808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
# spfile 파라미터 조회
SYS@ora19c> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
# control_files 파라미터 조회
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl, /u01/app/oracl
e/fast_recovery_area/ORA19C/co
ntrol02.ctl, /home/oracle/cont
rol03.ctl
Control File 단일화
# 데이터베이스 정상 종료
SYS@ora19c> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
# PFILE control_files 파라미터 수정
SYS@ora19c> !
[oracle@ora19c ~]$ cd $ORACLE_HOME/dbs
[oracle@ora19c dbs]$ ls
hc_ora19c.dat init.ora initora19c.ora lkORA19C orapwora19c spfileora19c.bak
[oracle@ora19c dbs]$ vi initora19c.ora

[oracle@ora19c dbs]$ exit
exit
# 데이터베이스 재시작
SYS@ora19c> startup
ORACLE instance started.
Total System Global Area 830469472 bytes
Fixed Size 8901984 bytes
Variable Size 595591168 bytes
Database Buffers 218103808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
# spfile 파라미터 조회 : PFILE로 실행 중
SYS@ora19c> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
# control_files 파라미터 조회 : 단일 control file 사용 중
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl
# spfile 생성
SYS@ora19c> create spfile from pfile;
File created.
# 데이터베이스 정상 종료
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 595591168 bytes
Database Buffers 218103808 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
# spfile 파라미터 조회 : SPFILE로 실행 중
SYS@ora19c> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/19.3.0
/dbhome_1/dbs/spfileora19c.ora
# control_files 파라미터 조회 : 단일 control file 사용 중
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl
# control03.ctl 삭제
SYS@ora19c> !
[oracle@ora19c ~]$ ls
control03.ctl LINUX.X64_193000_db_home.zip spfileora19c.ora
[oracle@ora19c ~]$ rm control03.ctl
[oracle@ora19c ~]$ cd $ORACLE_BASE/oradata/ORA19C
[oracle@ora19c ORA19C]$ ls
control01.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@ora19c ORA19C]$ pwd
/u01/app/oracle/oradata/ORA19C
# control02.ctl 삭제
[oracle@ora19c ~]$ cd $ORACLE_BASE
[oracle@ora19c oracle]$ ls
admin cfgtoollogs diag oradata
audit checkpoints fast_recovery_area product
[oracle@ora19c oracle]$ cd fast_recovery_area/
[oracle@ora19c fast_recovery_area]$ ls
ORA19C
[oracle@ora19c fast_recovery_area]$ cd ORA19C
[oracle@ora19c ORA19C]$ ls
archivelog control02.ctl onlinelog
[oracle@ora19c ORA19C]$ pwd
/u01/app/oracle/fast_recovery_area/ORA19C
[oracle@ora19c ORA19C]$ rm control02.ctl
[oracle@ora19c ORA19C]$ ls
archivelog onlinelog
[oracle@ora19c ORA19C]$ exit
exit
# control_files 파라미터 조회
SYS@ora19c> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/ORA19C
/control01.ctl'Courses > 아이티윌 오라클 DBA 과정' 카테고리의 다른 글
| 251203 TIL (0) | 2025.12.05 |
|---|---|
| 251202 TIL (0) | 2025.12.02 |
| 251128 TIL (0) | 2025.11.28 |
| 251127 TIL (0) | 2025.11.27 |
| 251126 TIL (0) | 2025.11.26 |