replication을 유지하면서 mysql-bin 로그 삭제
[마스터에서 수행]
1. 로그 목록 확인 [마스터에서 수행]
MariaDB [mysql]> show binary logs;
+------------------+------------+
| Log_name | File_size |
+------------------+------------+
| mysql-bin.000001 | 1073742334 |
| mysql-bin.000002 | 1073742066 |
| mysql-bin.000003 | 1073742021 |
| mysql-bin.000004 | 1073742090 |
| mysql-bin.000005 | 1074091311 |
| mysql-bin.000006 | 1074186164 |
| mysql-bin.000007 | 1074181534 |
| mysql-bin.000008 | 1073741968 |
| mysql-bin.000009 | 1073744583 |
| mysql-bin.000010 | 1073741939 |
| mysql-bin.000011 | 1000547863 |
+------------------+------------+
11 rows in set (0.00 sec)
1. 로그전체 삭제 --> replication 이 깨지므로 slave에서 replication을 다시 시작해줘야 한다.
MariaDB [mysql]>RESET MASTER;
2. replication유지하며 과거 로그 삭제
아래 명령어로 현재 slave가 사용중인 로그 확인[slave에서 수행]
MariaDB [mysql]> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000011
Read_Master_Log_Pos: 1002605164
Relay_Log_File: mysql-relay-bin.000034
Relay_Log_Pos: 185226372
Relay_Master_Log_File: mysql-bin.000011
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1002605164
Relay_Log_Space: 1002606071
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
1 row in set (0.00 sec)
ERROR: No query specified
MariaDB [mysql]>
현재 slave가 사용중인 master 의 로그 파일은 mysql-bin.000011 이다.
그러므로 이것 이전 로그파일은 삭제해도 replication이 깨지지 않는다.
로그를 삭제하기 위해 PURGE BINARY LOGS 명령어를 사용한다.[마스터에서 수행]
첫번째 방법 : PURGE BINARY LOGS TO 'mysql-bin.00003';
mysql-bin.00003 보다 낮은 번호의 로그들이 한꺼번에 삭제된다.
(mysql-bin.000001, mysql-bin.000002이 삭제됨)
두번째 방법 : PURGE BINARY LOGS BEFORE '2019-01-15 00:00:00';
2019년 1월 15일 0시 이전에 생성된 로그 파일들이 모두 삭제된다.
끝.
'MySQL, MariaDB' 카테고리의 다른 글
Last_SQL_Errno: 1032 Last_SQL_Error: Could not execute Delete_rows_v1 event on table (0) | 2019.01.31 |
---|---|
ERROR 1201 (HY000): Could not initialize master info structure for ''; (0) | 2019.01.31 |
replication (0) | 2018.06.26 |
CentOS7 nginx, mariadb10, php-fpm 설치 (0) | 2017.01.05 |
MySQL/Mariadb 테이블 사이즈 확인 (0) | 2016.12.06 |