4,552,354 th visitor since 2017.2.1 ( Today : 127 )
Programming
No. 678
Name. swindler
Subject. mysql-bin 로그 삭제
Main Cate. MySQL
Sub Cate.
Date. 2010-05-19 20:09
Hit. 6227 (211.36.27.8)
File.
PURGE {MASTER | BINARY} LOGS TO 'log_name'
PURGE {MASTER | BINARY} LOGS BEFORE 'date'

Deletes all the binary logs listed in the log index that are strictly prior to the specified log or date. The logs also are removed from the list recorded in the log index file, so that the given log becomes the first.

Example:

PURGE MASTER LOGS TO 'mysql-bin.010';
PURGE MASTER LOGS BEFORE '2003-04-02 22:46:26';

The BEFORE variant is available as of MySQL 4.1. Its date argument can be in 'YYYY-MM-DD hh:mm:ss' format. MASTER and BINARY are synonyms, but BINARY can be used only as of MySQL 4.1.1.

If you have an active slave that currently is reading one of the logs you are trying to delete, this statement does nothing and fails with an error. However, if a slave is dormant and you happen to purge one of the logs it wants to read, the slave will be unable to replicate once it comes up. The statement is safe to run while slaves are replicating. You do not need to stop them.

To purge logs, follow this procedure:

  1. On each slave server, use SHOW SLAVE STATUS to check which log it is reading.

  2. Obtain a listing of the logs on the master server with SHOW MASTER LOGS.

  3. Determine the earliest log among all the slaves. This is the target log. If all the slaves are up to date, this will be the last log on the list.

  4. Make a backup of all the logs you are about to delete. (The step is optional, but a good idea.)

  5. Purge all logs up to but not including the target log.

-------------------------------------------------------------
지정된 로그 이전의 로그를 모두 삭제합니다.
reset master 라는 명령도 있더군요.
purge 는 좀더 안정적으로 동작하는데 반해 reset master 는 단순히 로그를 모두 삭제해 버립니다.
주기적으로 로그를 관리하시려면 주기적으로 mysqladmin flush-logs 명령을 내려주시면 새 로그를 기록하게 됩니다.
저의 경우 주기적인 백업과 동시에 로그를 새로 기록하도록 하고 있습니다.



삭제주기를 지정하는 방법
SHOW VARIABLES LIKE '%expire%';
set global expire_logs_days=10;


[바로가기 링크] : http://coolx.net/cboard/develop/678


swindler mysqlbinlog xxx.log 로 내용을 볼 수 있음 2013-08-13
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog