MariaDB(MySQL):バイナリログの削除(パージ)方法

MariaDB(MySQL)バイナリログの削除は「rm」コマンドファイルで削除せず、専用のバイナリログのpurge(パージ)コマンドを使用します。(2017/06/03作成)

追放 CristianFerronato / Pixabay

0.環境

$ cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

$ mysql --version
mysql  Ver 15.1 Distrib 10.1.23-MariaDB, for Linux (x86_64) using readline 5.1

※レプリケーションを使用している場合は、スレーブ側にてどこまで伝搬しているかを「 show slave status \G 」コマンドで確認します。

1.バイナリログの確認

MariaDB [(none)]> show master logs;
+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000128 | 1074014684 |
| mysql-bin.000129 | 1073952936 |
| mysql-bin.000130 | 1073806927 |
| mysql-bin.000131 | 1073796757 |
| mysql-bin.000132 | 1073915707 |
| mysql-bin.000133 | 1073866295 |
| mysql-bin.000134 | 1074071362 |
| mysql-bin.000135 | 1073926610 |
| mysql-bin.000136 | 1074045501 |
| mysql-bin.000137 | 1073813079 |
| mysql-bin.000138 | 1073742366 |
| mysql-bin.000139 | 1074091442 |
| mysql-bin.000140 | 1074025347 |
| mysql-bin.000141 | 1073742075 |
| mysql-bin.000142 | 1073783039 |
| mysql-bin.000143 | 1073901573 |
| mysql-bin.000144 | 1074076711 |
| mysql-bin.000145 |  593905096 |
| mysql-bin.000146 |     314952 |
+------------------+------------+
19 rows in set (0.00 sec)

2.バイナリログのpurge(パージ)

MariaDB [(none)]> purge master logs to 'mysql-bin.000146';
Query OK, 0 rows affected (0.49 sec)

mysql-bin.000146 より前の「バイナリログ」がパージされます。

3.バイナリログの確認(パージ後)

MariaDB [(none)]> show master logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000146 |    676846 |
+------------------+-----------+
1 row in set (0.00 sec)

以上

About yoshimasa

埼玉県さいたま市在住、2男3女のパパです。Linux系の技術情報を中心にまとめています。1978年2月生まれ。