MySQL error log(PLC)

Rsyslog : MySQL Error 로그와 Slow-Query 취합을 위한 설정

1. rsyslog conf 설정

1-1. 설정

vi /etc/rsyslog.d/80-mysql.conf
#variables required for non-syslog log file forwarding – mysql error
#edit on your location

input(type=”imfile”
File=”/var/log/mysqld.log”
Tag=”mysqld-errors”
Severity=”error”
Facility=”local7″)

input(type=”imfile”
File=”/var/log/mysql-slow.log”
Tag=”mysql-slow”
Severity=”notice”
Facility=”local7″)

###### Creates a template for each log file in the Logentries UI
### logic to apply the relevant templates to the different log files

if $programname == ‘mysqld-errors’ then /var/log/plura/ceelog-127.0.0.1.log;CEETemplate
:programname, isequal, “mysqld-errors” ~

if $programname == ‘mysql-slow’ then /var/log/plura/ceelog-127.0.0.1.log;CEETemplate
:programname, isequal, “mysql-slow” ~

1-2. rsyslog 데몬 재시작

1-3. PLURA V5 repo 에서 다운로드 받기

2. MySQL – SLOW QUERY 설정

2-1. 설정

2-2. 로그 파일 생성 및 권한 설정

2-3. 권한 확인

2-4. mysql 데몬 재시작

2-5. 활성화 확인

3. 로그 확인

  • Error 또는 Slow Query 발생 후 호스트 로그에서 MySQL 관련 로그를 확인

  • 로그 예시 : 전체로그 > 호스트

참고 사이트

https://www.rsyslog.com/doc/v8-stable/configuration/modules/imfile.html

Last updated