开启log-bin
[mysqld]
log-bin = /data/3306/mysql-bin # 表示开启binlog
binlog_format=mixed # binlog日志格式,mysql默认采用statement
expire_logs_days = 10 # binlog过期清理时间,默认值为0,表示“没有自动删除
max_binlog_size = 512M # 定义binlog日志大小,默认1G
binlog_cache_size = 1M # binlog缓存大小
max_binlog_cache_size = 1M # 最大binlog缓存大小
-- 修改
binlog_format="ROW"
binlog_format="STATEMENT"
Binlog_Do_DB # 设定哪些数据库需要记录Binlog;
Binlog_Ignore_DB # 设定哪些数据库不要记录Binlog;
mysql> show variables like '%binlog_format%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | MIXED |
+---------------+-------+
1 row in set (0.00 sec)
binlog_cache_size (默认32KB,调优以及状态查看)
mysql> show global status like 'bin%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| Binlog_cache_disk_use | 35 | # 测试环境没调大,已经使用了35次disk
| Binlog_cache_use | 32078 | # 默认32K 设置太大的话,会比较消耗内存资源;设置太小又会使用到临时文件即disk
| Binlog_stmt_cache_disk_use | 46 |
| Binl