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- 파일에 직접 기록, 모든 이벤트 플러시 및 동기화
[로그 설정 참고]
https://docs.percona.com/percona-server/8.0/management/audit_log_plugin.html#audit-log-plugin
Audit Log Plugin - Percona Server for MySQL
Audit event indicates that audit logging started or finished. NAME field will be Audit when logging started and NoAudit when logging finished. Audit record also includes server version and command-line arguments. ??? example "Audit event" ```text ``` Conne
docs.percona.com
'LINUX > DB' 카테고리의 다른 글
[MongoDB] Percona-toolkit 설치 (0) | 2023.01.29 |
---|---|
[AWS-RDS] MYSQL you *might* want to use the less safe log_bin_trust_function_creators variable (0) | 2022.10.24 |
[MSSQL] (Backup, Restore) Database 진행률 확인 쿼리 (0) | 2022.08.30 |
[MSSQL] 제일 많은 빈도수 쿼리 조회 스크립트 (0) | 2022.07.19 |
[MYSQL] 한 서버에서 여러개 mysql 관리 (mysqld_multi) (0) | 2022.05.03 |