不指定起始二进制日志文件,只指定时间起始,会扫描全部的二进制日志文件
-mode repl -work-type 2sql -start-datetime "2021-12-12 09:00:00" -stop-datetime "2021-12-12 09:20:00" -output-dir ./tmpdir
[2021/12/12 11:37:24] [info] stats_process.go:166 start thread to analyze statistics from binlog
[2021/12/12 11:37:24] [info] events.go:210 start thread to write redo/rollback sql into file
[2021/12/12 11:37:24] [info] binlogsyncer.go:144 create BinlogSyncer with config {1113306 mysql 127.0.0.1 3318 root utf8 false false
这很不智能,不能自动定位到吗?
-mode repl -work-type 2sql -start-datetime "2021-12-12 09:00:00" -stop-datetime "2021-12-12 09:20:00" -output-dir ./tmpdir
[2021/12/12 11:37:24] [info] stats_process.go:166 start thread to analyze statistics from binlog [2021/12/12 11:37:24] [info] events.go:210 start thread to write redo/rollback sql into file [2021/12/12 11:37:24] [info] binlogsyncer.go:144 create BinlogSyncer with config {1113306 mysql 127.0.0.1 3318 root utf8 false false false Local false 0 0s 0s 0 false false 0} [2021/12/12 11:37:24] [info] events.go:60 start thread 2 to generate redo/rollback sql [2021/12/12 11:37:24] [info] binlogsyncer.go:360 begin to sync binlog from position (, 4) [2021/12/12 11:37:24] [info] events.go:60 start thread 1 to generate redo/rollback sql [2021/12/12 11:37:24] [info] repl.go:16 start to get binlog from mysql [2021/12/12 11:37:24] [info] binlogsyncer.go:777 rotate to (mysql_bin.000107, 4) 第一个日志文件
这很不智能,不能自动定位到吗?
文件本身的时间是可以改的,但是你要的肯定以事务时间为准咯,事务时间在日志里,你不指定从哪个日志开始,肯定要自动扫描所有的日志,找到你指定时间呐
生产库的binlog还未见有人去做修改过
感觉可以使用二分法看每个文件的开头来判断找到从哪个文件开始,这样应该可以节省时间。期待更新。
https://github.com/fulldb/my2sql/blob/main/main.go