错误日志


二进制日志

作用:数据恢复、主从复制
配置:

  1. server_id
  2. log_bin
  3. binlog_format
  4. expires_logs_days
  5. sync_binlog=1/0

双一说明?
innodb_flush_log_at_trx_commit=1 每次日志提交,必然log buffer中redo落到磁盘
sync_binlog=1 每次日志提交,必然保证binlog cache中的日志落到磁盘
涉及重点命令:

  1. show master status; # 看当前使用的binlog
  2. show binlog event in 'mysql-bin.000001'; # 事件查看
  3. mysql -e 'how binlog event in 'mysql-bin.000001;'|grep 'DROP' # 过滤
  4. mysqlbinlog --start-position --stop-position mysql-bin.000002 # 无GTID
  5. mysqlbinlog -d zabbix --start-position --stop-position mysql-bin.000002 # 无GTID
  6. mysqlbinlog --start-datetime --stop-endtime mysql-bin.000002
  7. mysqlbinlog --skip-gtids --include-gtids='xxxxxxxxxxx:7-11' mysql-bin.000002 mysql-bin.000003
  8. set sql_log_bin=0; 临时关闭bin-log
  9. source /tmp/bin.log
  10. set sql_log_bin=1;
  11. >flush logs # 滚动日志
  12. purge binary logs to ...
  13. reset master # 全部删除,主从必崩

慢日志