23.06.15
DEVOTEE를 활성화 시키면
지금 작성한 커뮤니티 글에 대해 1개의 댓글을 달아줍니다.
버튼을 누르면 글 수정 시 ChatGPT가 작성한 댓글이 수정됩니다.
| 컨텐츠 유형 | 제목 | 저장일 | 삭제 |
|---|
본인인증 로그인에 실패하였습니다.
회원이 아니시거나 본인인증 등록이
완료되지 않은 사용자입니다.
.png)
.png)
아무튼, 우선 root 계정으로 접속해서 bin 로그를 확인해보겠습니다.
root@magic01:/># mysql -u root -p****
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2175974
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show binary logs;
+------------------+------------+
| Log_name | File_size |
+------------------+------------+
| mysql-bin.001053 | 1073742172 |
| mysql-bin.001054 | 1075783074 |
| mysql-bin.001055 | 1073743192 |
| mysql-bin.001056 | 1073742537 |
| mysql-bin.001057 | 1073745245 |
| mysql-bin.001058 | 142485535 |
| mysql-bin.001059 | 1073742579 |
| mysql-bin.001060 | 1073741946 |
| mysql-bin.001061 | 1073742045 |
| mysql-bin.001062 | 1073742518 |
| mysql-bin.001063 | 1073744313 |
| mysql-bin.001064 | 1073742239 |
| mysql-bin.001065 | 1073742997 |
| mysql-bin.001066 | 1073742046 |
| mysql-bin.001067 | 1073745739 |
| mysql-bin.001068 | 1073744518 |
| mysql-bin.001069 | 1073745517 |
| mysql-bin.001070 | 1073742263 |
| mysql-bin.001071 | 1073742406 |
| mysql-bin.001072 | 1073742386 |
| mysql-bin.001073 | 1073742055 |
| mysql-bin.001074 | 1073742081 |
| mysql-bin.001075 | 1073744681 |
| mysql-bin.001076 | 1073747052 |
| mysql-bin.001077 | 1073743710 |
| mysql-bin.001078 | 1073742244 |
| mysql-bin.001079 | 1073742915 |
| mysql-bin.001080 | 1073741935 |
| mysql-bin.001081 | 1073742697 |
| mysql-bin.001082 | 1073743203 |
| mysql-bin.001083 | 1073742068 |
| mysql-bin.001084 | 1073742451 |
| mysql-bin.001085 | 1073742550 |
| mysql-bin.001086 | 1073746090 |
| mysql-bin.001087 | 1073742003 |
| mysql-bin.001088 | 423993152 |
+------------------+------------+
36 rows in set (0.02 sec)
MariaDB [(none)]> show variables like "%expire_logs_days%"
-> ;
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 0 |
+------------------+-------+
1 row in set (0.00 sec)
bin 로그의 삭제주기는 MariaDB 의 환경설정중 expire_logs_days 를 확인하면 됩니다.
확인결과 현재는 기본값인 0 으로 세팅되어 있는것을 확인할 수 있었습니다.
참고로 0의 의미는 "bin log 를 삭제하지 않는다" 입니다.
결과적으로 expire_logs_days 가 세팅되어 있지 않아서 bin log 가 쌓이고 있었던거죠..
그리고, 환경설정을 잠시 보자면, 아래 파일을 확인하면 됩니다.
/etc/my.cnf
root@magic01:/etc># ll my.cnf
-rw-r--r-- 1 root root 20751 8월 26 14:12 my.cnf
root@magic01:/etc># cat my.cnf | more
#BEGIN CONFIG INFO
#DESCR: 4GB RAM, InnoDB only, ACID, few connections, heavy queries
#TYPE: SYSTEM
#END CONFIG INFO
#
# This is a MariaDB example config file for systems with 4GB of memory
# running mostly MariaDB using InnoDB only tables and performing complex
# queries with few connections.
#
# MariaDB programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, do:
# 'my_print_defaults --help' and see what is printed under
# Default options are read from the following files in the given order:
# More information at: http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
root@magic01:/etc># cat my.cnf | grep expire
expire_logs_days=7
root@magic01:/etc>#
물론, 해당 환경설정파일에 저장을 하면, MariaDB 를 재기동 할때 적용이 됩니다.
위와 같이 환경설정파일에서 환경변수를 입력시키면, 실시간적용이 안되기때문에 실시간으로 적용하는 방법을 말씀드리겠습니다.
아래와 같이 세팅하시면 됩니다.
MariaDB [(none)]> set global expire_logs_days=7;
Query OK, 0 rows affected (0.02 sec)
그럼, 정상적으로 세팅되었는지 확인해볼까요?
show variables like 명령을 사용하면 됩니다.
MariaDB [(none)]> show variables like "%expire_logs_days%";
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 7 |
+------------------+-------+
1 row in set (0.00 sec)
위와 같이 정상적으로 7일로 세팅되었음을 확인할 수 있습니다.
MariaDB bin log 를 삭제하려면,
아래와 같이 purge binary logs to 명령어를 사용하면 됩니다.
MariaDB [(none)]> purge binary logs to 'mysql-bin.001080';
Query OK, 0 rows affected (1.13 sec)
그럼 결과를 조회해 보면 아래와 같이 삭제되었음을 확인할 수 있습니다.
AS-IS
root@magic01:/># mysql -u root -p****
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2175974
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show binary logs;
+------------------+------------+
| Log_name | File_size |
+------------------+------------+
| mysql-bin.001053 | 1073742172 |
| mysql-bin.001054 | 1075783074 |
| mysql-bin.001055 | 1073743192 |
| mysql-bin.001056 | 1073742537 |
| mysql-bin.001057 | 1073745245 |
| mysql-bin.001058 | 142485535 |
| mysql-bin.001059 | 1073742579 |
| mysql-bin.001060 | 1073741946 |
| mysql-bin.001061 | 1073742045 |
| mysql-bin.001062 | 1073742518 |
| mysql-bin.001063 | 1073744313 |
| mysql-bin.001064 | 1073742239 |
| mysql-bin.001065 | 1073742997 |
| mysql-bin.001066 | 1073742046 |
| mysql-bin.001067 | 1073745739 |
| mysql-bin.001068 | 1073744518 |
| mysql-bin.001069 | 1073745517 |
| mysql-bin.001070 | 1073742263 |
| mysql-bin.001071 | 1073742406 |
| mysql-bin.001072 | 1073742386 |
| mysql-bin.001073 | 1073742055 |
| mysql-bin.001074 | 1073742081 |
| mysql-bin.001075 | 1073744681 |
| mysql-bin.001076 | 1073747052 |
| mysql-bin.001077 | 1073743710 |
| mysql-bin.001078 | 1073742244 |
| mysql-bin.001079 | 1073742915 |
| mysql-bin.001080 | 1073741935 |
| mysql-bin.001081 | 1073742697 |
| mysql-bin.001082 | 1073743203 |
| mysql-bin.001083 | 1073742068 |
| mysql-bin.001084 | 1073742451 |
| mysql-bin.001085 | 1073742550 |
| mysql-bin.001086 | 1073746090 |
| mysql-bin.001087 | 1073742003 |
| mysql-bin.001088 | 423993152 |
+------------------+------------+
36 rows in set (0.02 sec)
MariaDB [(none)]> show binary logs;
+------------------+------------+
| Log_name | File_size |
+------------------+------------+
| mysql-bin.001080 | 1073741935 |
| mysql-bin.001081 | 1073742697 |
| mysql-bin.001082 | 1073743203 |
| mysql-bin.001083 | 1073742068 |
| mysql-bin.001084 | 1073742451 |
| mysql-bin.001085 | 1073742550 |
| mysql-bin.001086 | 1073746090 |
| mysql-bin.001087 | 1073742003 |
| mysql-bin.001088 | 433079778 |
+------------------+------------+
9 rows in set (0.00 sec)
MariaDB [(none)]>
DEVOTEE를 활성화 시키면
지금 작성한 댓글에 AI가 댓글을 달아줍니다.