MySQL Binary Log 삭제 > 정보공유

본문 바로가기

정보공유

일반글
Server

MySQL Binary Log 삭제

페이지 정보

게시물QR코드

본문

보통 용량 확보를 위해 Binary Log 삭제해야 할 경우가 있습니다.

mysql 디렉토리 가보면 막 00001 00002 00003.. 삭제하고 싶은 파일들이 보이는데요

수동 삭제하지 말고, MySQL 내에서 purge 로 삭제해 주어야 합니다. 



해당 바이너리 로그 보관은 expire_logs_days 에서 조절할 수 있습니다

( mysql> show variables like 'expire%'; 로 확인 하고, 

set globa; expire_logs_days=일수; 로 설정 ) 

단 set global 은 데몬 재구동시 설정 초기화되므로, 

값 업데이트 또는 my.cnf 설정 하세요.


root@Web1:/usr/local/mysql/var# mysql -u root -p      권한자 로그인

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 10

Server version: 5.1.67-log Source distribution



Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.



Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.



Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+


3 rows in set (0.00 sec)



mysql> use mysql;

Database changed

mysql> show binary logs;              로그 리스트 보기

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000012 |       149 |

| mysql-bin.000013 |       149 |

| mysql-bin.000014 |       106 |

+------------------+-----------+

3 rows in set (0.00 sec)



mysql> purge master logs to 'mysql-bin.000013';   000013 제외한 "이전" 의 바이너리 로그 모두 삭제. 

Query OK, 0 rows affected (0.03 sec)



mysql> show binary logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000013 |       149 |    13 이전의 12가 삭제 됌. 

| mysql-bin.000014 |       106 |

+------------------+-----------+


2 rows in set (0.00 sec)



mysql> show variables like 'expire%';    바이너리 로그 보관기간 확인

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| expire_logs_days | 2     |

+------------------+-------+

1 row in set (0.00 sec)



mysql> set global expire_logs_days=2;    설정은 set global 로 가능. 

Query OK, 0 rows affected (0.00 sec)


모든 작업 후에는 혹시 모르니 flush privileges; 를 해주는 버릇을 들여보자.

댓글목록

등록된 댓글이 없습니다.

  • Addr.부산광역시 동구 중앙대로 319, 9층 L4호(초량동, 부산YMCA빌딩) Email. gnuwiz@naver.com
  • BR. 625-68-00172 TRC. 2019-부산해운대-1186 TEL. 0507-1382-2790
All rights reserved.