본문 바로가기
etc

mariadb binary log expire 설정

by kyeongseo.oh 2023. 9. 12.

Version : Server version: 10.3.32-MariaDB-log MariaDB Server

 

binary logs 확인

MariaDB [(none)]> show binary logs;
+-------------------------+-----------+
| Log_name                | File_size |
+-------------------------+-----------+
| mysql_binary_log.000001 |     28258 |
| mysql_binary_log.000002 | 157626084 |
| mysql_binary_log.000003 |  14677665 |
+-------------------------+-----------+
3 rows in set (0.005 sec)

 

수동삭제

MariaDB [(none)]> show binary logs;
+-------------------------+-----------+
| Log_name                | File_size |
+-------------------------+-----------+
| mysql_binary_log.000001 |     28258 |
| mysql_binary_log.000002 | 157626084 |
| mysql_binary_log.000003 |  15254270 |
+-------------------------+-----------+
3 rows in set (0.000 sec)

MariaDB [(none)]> PURGE BINARY LOGS TO 'mysql_binary_log.000002';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> show binary logs;
+-------------------------+-----------+
| Log_name                | File_size |
+-------------------------+-----------+
| mysql_binary_log.000002 | 157626084 |
| mysql_binary_log.000003 |  15268051 |
+-------------------------+-----------+
2 rows in set (0.000 sec)

 

variables 설정

mariadb 재시작 시 초기화되므로, my.cnf에 작성 후 db를 재시작하는 것을 추천함.

MariaDB [(none)]> show global variables like 'expire_logs_days';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| expire_logs_days | 0     |
+------------------+-------+
1 row in set (0.001 sec)

MariaDB [(none)]> set global expire_logs_days=1;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> show global variables like 'expire_logs_days';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| expire_logs_days | 1     |
+------------------+-------+
1 row in set (0.001 sec)

flush privileges;

 

my.cnf

/etc/my.cnf에 아래 내용을 추가 후 db 재시작

[mysqld]
expire_logs_days=1

'etc' 카테고리의 다른 글

pysmtpd  (0) 2023.09.27
smtp 서버  (0) 2023.09.27
prometheus, grafana, pushgateway 설치  (0) 2023.09.11
cloudera hue 설치 (rhel8)  (0) 2023.09.11
taskfile  (0) 2023.08.05

댓글