YUMSERV
Published 2022. 11. 25. 16:47
[MySQL] Mysql8 Audit 로그 설정 LINUX/DB
반응형

Audit 로그 (감사로그)

Audit 로그는 보안 기능중에 하나로, DB에서 누가, 어떤 쿼리를 날렸는지 확인 할 수 있게, 로그 형태로 남기는 것을 말합니다.

 

 

1. AUDIT 로그 설치

* 환경 : Mysql 8.0.29

 

Percona 사이트에서 자신의 맞는 버전에 따라 다운로드 받습니다.

https://www.percona.com/downloads/Percona-Server-LATEST/#

 

Download Percona Server for MySQL 8.0

Software: -- Select Software Platform -- Debian GNU/Linux 10.0 ("buster")Debian GNU/Linux 11.0 ("bullseye")Linux - GenericRed Hat Enterprise Linux / CentOS / Oracle Linux 7Red Hat Enterprise Linux / CentOS / Oracle Linux 8Red Hat Enterprise Linux / CentOS

www.percona.com

 

플러그인 다운로드 및 설치

tar xvfz Percona-Server-8.0.29-21-Linux.x86_64.glibc2.17.tar.gz
cd Percona-Server-8.0.29-21-Linux.x86_64.glibc2.17/lib/
cp -arp audit_log.so /usr/local/mysql/lib/plugin/
chown -R mysql.mysql audit_log.so

 

DB 내에 audit로그 설정 확인

mysql> show variables like 'audit%';
Empty set (0.01 sec)

 

DB내에서 audit 로그 설치

mysql> INSTALL PLUGIN audit_log SONAME 'audit_log.so';
Query OK, 0 rows affected (0.00 sec)

 

audit 로그 확인

mysql> show variables like 'audit%';
+-----------------------------+---------------+
| Variable_name               | Value         |
+-----------------------------+---------------+
| audit_log_buffer_size       | 1048576       |
| audit_log_exclude_accounts  |               |
| audit_log_exclude_commands  |               |
| audit_log_exclude_databases |               |
| audit_log_file              | audit.log     |
| audit_log_flush             | OFF           |
| audit_log_format            | JSON          |
| audit_log_handler           | FILE          |
| audit_log_include_accounts  |               |
| audit_log_include_commands  |               |
| audit_log_include_databases |               |
| audit_log_policy            | ALL           |
| audit_log_rotate_on_size    | 0             |
| audit_log_rotations         | 0             |
| audit_log_strategy          | ASYNCHRONOUS  |
| audit_log_syslog_facility   | LOG_USER      |
| audit_log_syslog_ident      | percona-audit |
| audit_log_syslog_priority   | LOG_INFO      |
+-----------------------------+---------------+

 

 

Audit 로그 설정

vi /etc/my.cnf

audit_log_file='/data/log/db_audit/audit.json'
audit-log=FORCE_PLUS_PERMANENT
audit_log_format=json
audit_log_policy=ALL


audit_json_log_file

로그 파일 이름, 만약 audit_json_file 옵션이 활성화 되어 있다면 이 파일에 감사 추적을 작성하게 됩니다.

Default 값은 MySQL datadir로 되어있습니다. 기본적인 파일이름은 audit.log 입니다.

 

audit_log_buffer_size

로깅 시 사용되는 메모리 버퍼사이즈

 

audit_log_format

OLD, NEW, JSON, CSV 총 4가지가 있습니다.

 

audit_json_file_flush
set global audit_json_file_flush = on을 호출할 때 로그 파일의 flush를 일어난다.이것은 MySQL이 로그파일을 관리하는 방법과 유사하게 기록을 저장한다.

 

audit_log_include_accounts

audit_log_exclude_accounts

모니터링 할 사용자와 모니터링에 제외할 사용자를 설정합니다.

 

audit_log_strategy

감사로그 전략으로 ASYNCHRONOUS, PERFORMANCE, SEMISYNCHRONOUS, SYNCHRONOUS

ASYNCHRONOUS- (기본값) 메모리 버퍼를 사용하여 로그, 버퍼가 가득 차면 메시지를 삭제하지 않음
PERFORMANCE- 메모리 버퍼를 사용하여 로그, 버퍼가 가득 차면 메시지 삭제
SEMISYNCHRONOUS- 파일에 직접 기록, 모든 이벤트를 플러시 및 동기화하지 않음
SYNCHRONOUS- 파일에 직접 기록, 모든 이벤트 플러시 및 동기화

 

 

[로그 설정 참고]

 

반응형
profile

YUMSERV

@lena04301

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!