인성장

[Oracle] Active Data Guard 구성 후, Standby DB Archive log file 관리 방법 본문

Oracle/Admin

[Oracle] Active Data Guard 구성 후, Standby DB Archive log file 관리 방법

인성장 2025. 9. 18. 16:03
Acitve Data Guard 구성 후, Standby DB Archive log file 관리 방법

 

Oracle에서 ADG 구성 후, Standby DB 서버의 Archive log file을 주기적으로 관리(삭제) 해주지 않으면 해당 디스크 경로가 100% Full이 차는 경우가 종종 있습니다. 이미 적용(Apply)된 Archive log file을 수동으로 삭제해줘도 무방하지만, 매번 모니터링하고 관리해주기 번거롭기 때문에 스크립트화 하여 자동으로 DR 서버 Archive log file을 정리해주는 것이 좋습니다.

 

아래와 같이 스크립트를 참조하여 각 환경에 맞게 만들고 crontab에 등록하여 사용하시면 됩니다.

Standby DB Archive log file Automatic delete 방법

$ vi applied_rm_archive.sh
===============================================================================================
#!/bin/ksh
#
#
# Remove applied archivelog thread 1;
#
#
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=/oracle/app/oracle/product/19c
export ORACLE_SID=TEST
export PATH=/usr/sbin:/usr/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch


tmpfile=/home/oracle/arch_id1.out

$ORACLE_HOME/bin/sqlplus -S /nolog <<EOF > $tmpfile
connect / as sysdba
set head off
set pages 0
select max(sequence#) from v\$archived_log where applied = 'YES' and thread#=1 group by thread#;
exit
EOF

echo DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = `head -n 1  $tmpfile | awk '{print $1}'` THREAD 1 ';' > $tmpfile

$ORACLE_HOME/bin/rman target / <<EOF > applied_archive_del.log
 @$tmpfile
exit
EOF
===============================================================================================