expire_logs_daysを変更しようとするとエラーになる。
set @@global.expire_logs_days=2;
ERROR: 3683 (HY000): The option expire_logs_days and binlog_expire_logs_seconds cannot be used together. Please use binlog_expire_logs_seconds to set the expire time (expire_logs_days is deprecated)
binlog_expire_logs_secondsのデフォルト値は
show GLOBAL VARIABLES LIKE 'binlog_expire_logs_seconds';
+--------------------------------+---------+
| Variable_name | Value |
+--------------------------------+---------+
| binlog_expire_logs_seconds | 2592000 |
+--------------------------------+---------+
172800(2日)に変更する。
set @@global.binlog_expire_logs_seconds=172800;
show GLOBAL VARIABLES LIKE 'binlog_expire_logs_seconds';
+----------------------------+--------+
| Variable_name | Value |
+----------------------------+--------+
| binlog_expire_logs_seconds | 172800 |
+----------------------------+--------+
古いbinary logsは削除
show binary logs;
+---------------+-----------+-----------+
| Log_name | File_size | Encrypted |
+---------------+-----------+-----------+
| binlog.000001 | 1984 | No |
| binlog.000002 | 179 | No |
| binlog.000003 | 239735703 | No |
| binlog.000004 | 179 | No |
| binlog.000005 | 1713114 | No |
| binlog.000006 | 179 | No |
| binlog.000007 | 249140 | No |
| binlog.000008 | 179 | No |
| binlog.000009 | 17334828 | No |
| binlog.000010 | 179 | No |
| binlog.000011 | 124996 | No |
| binlog.000012 | 179 | No |
| binlog.000013 | 3278665 | No |
+---------------+-----------+-----------+
purge binary logs to 'binlog.000013';
show binary logs;
+---------------+-----------+-----------+
| Log_name | File_size | Encrypted |
+---------------+-----------+-----------+
| binlog.000013 | 3300789 | No |
+---------------+-----------+-----------+
Helm upgrade
これだけだと永続的変更にならないので、helm chartを更新してパラメーターを永続変更する。
helm chartに下記を追加
primary:
configuration: |-
[mysqld]
binlog_expire_logs_seconds=172800
helm upgrade
helm upgrade mysql bitnami/mysql --reuse-values --namespace mysql -f ./mysql-values.yml
deploy確認
helm ls -n mysql
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
mysql mysql 14 2022-01-04 14:22:10.524728 +0900 JST deployed mysql-8.8.19 8.0.27
k8sステータス確認
kubectl -n mysql get all,pvc ✘ 1
NAME READY STATUS RESTARTS AGE
pod/mysql-0 1/1 Running 0 7m6s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/mysql ClusterIP 10.245.84.17 <none> 3306/TCP 12d
service/mysql-headless ClusterIP None <none> 3306/TCP 12d
NAME READY AGE
statefulset.apps/mysql 1/1 2d3h
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/data-mysql-0 Bound pvc-c04e1f94-4dc7-4e91-b144-a6ab8b78b5fe 4Gi RWO do-block-storage 12d
mysql設定値確認
show GLOBAL VARIABLES LIKE 'binlog_expire_logs_seconds';
+----------------------------+--------+
| Variable_name | Value |
+----------------------------+--------+
| binlog_expire_logs_seconds | 172800 |
+----------------------------+--------+