错误日志
二进制日志
作用:数据恢复、主从复制
配置:
- server_id
- log_bin
- binlog_format
- expires_logs_days
- sync_binlog=1/0
双一说明?
innodb_flush_log_at_trx_commit=1 每次日志提交,必然log buffer中redo落到磁盘
sync_binlog=1 每次日志提交,必然保证binlog cache中的日志落到磁盘
涉及重点命令:
show master status; # 看当前使用的binlog
show binlog event in 'mysql-bin.000001'; # 事件查看
mysql -e 'how binlog event in 'mysql-bin.000001;'|grep 'DROP' # 过滤
mysqlbinlog --start-position --stop-position mysql-bin.000002 # 无GTID
mysqlbinlog -d zabbix --start-position --stop-position mysql-bin.000002 # 无GTID
mysqlbinlog --start-datetime --stop-endtime mysql-bin.000002
mysqlbinlog --skip-gtids --include-gtids='xxxxxxxxxxx:7-11' mysql-bin.000002 mysql-bin.000003
set sql_log_bin=0; 临时关闭bin-log
source /tmp/bin.log
set sql_log_bin=1;
>flush logs # 滚动日志
purge binary logs to ...
reset master # 全部删除,主从必崩