행위

"오라클 alert log"의 두 판 사이의 차이

DB CAFE

(SQL로 alert log 내용 확인)
(SQL로 alert log 내용 확인)
53번째 줄: 53번째 줄:
 
 
 
=== SQL로 alert log 내용 확인 ===
 
=== SQL로 alert log 내용 확인 ===
{{틀: 고지상자2
+
{{틀: 고지상자
 
|제목=V$DBGALERTEXT (11g 이상)
 
|제목=V$DBGALERTEXT (11g 이상)
 
}}
 
}}
62번째 줄: 62번째 줄:
 
</source>
 
</source>
  
{{틀: 고지상자2
+
{{틀: 고지상자
 
|제목=V$DIAG_ALERT_EXT (12c 이상)
 
|제목=V$DIAG_ALERT_EXT (12c 이상)
 
|내용=
 
|내용=

2023년 7월 12일 (수) 15:23 판

thumb_up 추천메뉴 바로가기


1 오라클 alert log 위치, 정보 및 관리[편집]

1.1 alert log위치[편집]

  • ~ 10g 이하
$ORACLE_BASE/admin/$ORACLE_SID/bdump
  • 11g ~ 이상
$ORACLE_BASE/diag/rdbms/'DATABASE NAME'/$ORACLE_SID/trace

1.1.1 SQL 로 위치 조회[편집]

SELECT *
  FROM V$DIAG_INFO
 WHERE NAME = 'Diag Alert'

1.2 쿼리로 찾기[편집]

1.2.1 파라미터[편집]

SQL> show parameter background_dump_dest

1.2.2 v$parameter[편집]

SQL> select value from v$parameter where name='background_dump_dest';

1.2.3 v$diag_info[편집]

11g 버전에서는 아래의 뷰에서도 조회 가능

SQL> select value from v$diag_info where name='Diag Trace';
(+)DB가 내려갔을 시, 도무지 찾기가 힘들 때에는 find 명령어로 찾는다.

1.2.4 Unix find 명령[편집]

$> find / -name alert_*.log 2>/dev/null

1.3 저장되는 정보[편집]

다음을 포함하는 메시지와 에러를 시간 순으로 기록한다.

  • 발생된 모든 내부에러(ora-600), 블럭 훼손 에러(ora-1578), 데드락 에러(ora-60)
  • CREATE/ALTER/DROP DATABASE/TABLESPACE, STARTUP, SHUTDOWN, ARCHIVE LOG, RECOVER 같은 SQL 문장을 사용한 관리 작업
  • 공유 서버와 디스패처 프로세스의 기능과 관련된 에러와 메시지
  • 구체화된 뷰의 자동 갱신 시 발생하는 에러
  • STARTUP시에 사용된 비 기본 초기화 파라미터들
  • 오라클은 이러한 이벤트를 기록하기 위해 ALERT LOG를 이용한다. 만약 관리 작업이 성공한다면, 메시지는 ALERT LOG에 시간과 "completed" 라는 메시지를 기록한다.
  • 대체적으로 alert log에는 시스템 관련 에러나 정보들을 보여줍니다. 사용자 관련 에러가 저장되는 곳은 아니다.

1.3.1 SQL로 alert log 내용 확인[편집]



select message_text 
  from x$dbgalertext 
  where message_level = 1; --  critical events


  • MESSAGE_TYPE(NUMBER)

Type of the message, indicating that a different type of response is required. Possible values include:

1: UNKNOWN - Essentially the NULL type

2: INCIDENT_ERROR - The program has encountered an error for some internal or unexpected reason, and it must be reported to Oracle Support

3: ERROR - An error of some kind has occurred

4: WARNING: An action occurred or a condition was discovered that should be reviewed and may require action

5: NOTIFICATION: reports a normal action or event. This could be a user action such as "logon completed"

6: TRACE: Output of a diagnostic trace

  • MESSAGE_LEVEL(NUMBER)

Level the message belongs to. Lower level values imply higher severity for errors. Possible values include:

1: CRITICAL: critical errors

2: SEVERE: severe errors

8: IMPORTANT: important message

16: NORMAL: normal message



-- critical events
select message_text 
  from v$diag_alert_ext 
where message_level = 1;
select message_type
     , message_level
     , message_text 
  from v$diag_alert_ext 
 where message_type in (2, 3);
  • MESSAGE_TYPE

2: INCIDENT_ERROR 3: ERROR

1.4 Alert log 파일 관리[편집]

운영 중에 rm으로 지워도 무방하다.

지워서 alert log 파일을 없애버려도 오라클이 alert log가 입력 될 시점에는 자동으로 파일을 생성하고 기록한다.

1.5 Alert log 파일 초기화[편집]

$>  cp /dev/null alert로그파일명.log

1.6 로그 관리 주기[편집]

오라클 10g의 경우 엔진 설치를 위한 디렉토리 공간을 20GB 이상 주는 것을 권장.

오라클의 adump, bdump, udump, 리스너 로그, 아카이브 로그 등을 백업할 수 있으면

백업하는 것을 권장한다. 하지만 대부분의 경우 백업의 필요성이 절실하지 않기 때문에삭제한다.

각종 로그의 자동 관리를 위하여 첨부한 파일과 같이 CRONTAB 에 등록하여 관리하면 편리하다. 각각의 로그 관리에 대한 정책이 필요하다.

정책 예시)

  1. alert 로그 : 월별로 로그를 관리. 영구 보관하는 것이 좋다. compress 명령으로 압축하여 보관.
  2. adump audit 파일 : 180일 정도 유지, 매일 180일이 지난 trc파일을 삭제
  3. bdump trace 파일 : 90일 정도 유지, 매일 90일이 지난 trc파일을 삭제
  4. udump trace 파일 : 90일 정도 유지, 매일 90일이 지난 trc파일을 삭제
  5. 리스너 로그 : 리스너를 로깅하도록 설정했을 경우 월별로 로그를 관리. 180일이 지난 파일은 삭제. compress 명령으로 압축하여 보관.
  6. 아카이브로그 파일 : 기본적으로 1주일에 1번 이상 FULL BACKUP을 받을 경우 백업 툴에서 아카이브로그를 관리해 주지 않을 경우 등록하여 사용 7일전 아카이브로그 파일 삭제.

1.7 alert log 최근것만 조회[편집]

tail -5000 alert_ACCTEST.log > alert_ACCTEST_last.txt

1.8 로그 관리 쉘 스크립트[편집]

쉘 스크립트 작성 시 오타에 주의할 것. 반드시 테스트 후 적용할 것

1.8.1 alert.log[편집]

- (매월 1일 실행할 수 있도록 cron job 등록 )
nDate=`date +%Y%m%d`
cp $ORACLE_BASE/admin/TESTDB/bdump/alert_TESTDB.log $ORACLE_BASE/TESTDB/bdump/alert_TESTDB.log.$nDate
cat /dev/null > $ORACLE_BASE/admin/TESTDB/bdump/alert_TESTDB.log
compress -vf $ORACLE_BASE/TESTDB/bdump/alert_TESTDB.log.$nDate


1.8.2 listener.log[편집]

- (매월 1일 실행할 수 있도록 cron job 등록 )
nDate=`date +%Y%m%d`
cp $ORACLE_HOME/network/admin/listener.log $ORACLE_HOME/network/admin/listener.log.$nDate
cat /dev/null > $ORACLE_HOME/network/admin/listener.log
compress -vf $ORACLE_HOME/network/admin/listener.log.$nDate

1.8.3 audit[편집]

- 180일이 지난 *.aud를 찾아 삭제
find $ORACLE_BASE/admin/TESTDB/adump \( -ctime +180 -name '*.aud' \) -exec rm -f {} \;

1.8.4 .trc[편집]

- 90일이 지난 *.trc를 찾아 삭제

find $ORACLE_BASE/admin/TESTDB/bdump \( -ctime +90 -name '*.trc' \) -exec rm -f {} \;
find $ORACLE_BASE/admin/TESTDB/udump \( -ctime +90 -name '*.trc' \) -exec rm -f {} \;

1.8.5 archive log[편집]

# 7일이 지난 *.arc를 찾아 삭제
find /archive_log \( -ctime +7 -name '*.arc' \) -exec rm -f {} \;

[참고] $는 변수, #은 주석을 표시 쉘 예시)

쉘 스크립트 작성 시 오타에 주의할 것. 반드시 테스트 후 적용할 것

1.8.6 alert.log[편집]

1.8.7 (매월 1일 실행할 수 있도록 cron job 등록 )[편집]

nDate=`date +%Y%m%d`
cp $ORACLE_BASE/admin/TESTDB/bdump/alert_TESTDB.log $ORACLE_BASE/TESTDB/bdump/alert_TESTDB.log.$nDate
cat /dev/null > $ORACLE_BASE/admin/TESTDB/bdump/alert_TESTDB.log
compress -vf $ORACLE_BASE/TESTDB/bdump/alert_TESTDB.log.$nDate


1.8.8 listener.log[편집]

-  (매월 1일 실행할 수 있도록 cron job 등록 )

nDate=`date +%Y%m%d`
cp $ORACLE_HOME/network/admin/listener.log $ORACLE_HOME/network/admin/listener.log.$nDate
cat /dev/null > $ORACLE_HOME/network/admin/listener.log
compress -vf $ORACLE_HOME/network/admin/listener.log.$nDate


1.8.9 audit[편집]

- 180일이 지난 *.aud를 찾아 삭제
find $ORACLE_BASE/admin/TESTDB/adump \( -ctime +180 -name '*.aud' \) -exec rm -f {} \;


1.8.10 .trc[편집]

- 90일이 지난 *.trc를 찾아 삭제                    

find $ORACLE_BASE/admin/TESTDB/bdump \( -ctime +90 -name '*.trc' \) -exec rm -f {} \;
find $ORACLE_BASE/admin/TESTDB/udump \( -ctime +90 -name '*.trc' \) -exec rm -f {} \;


1.8.11 archive log[편집]

# 7일이 지난 *.arc를 찾아 삭제
find /archive_log \( -ctime +7 -name '*.arc' \) -exec rm -f {} \;

[참고] $는 변수, #은 주석을 표시