The binlog of the production environment is put into the local test environment and analyzed with binlog2sql


If you put the binlog of the production environment into the local test environment and parse it with binlog2sql, the following error will occur if you read it directly:

[root@testdb1 mysql]# python /root/binlog2sql-master/binlog2sql/binlog2sql.py -h 192.168.119.130 -uroot -pchengce243 --start-file mysql-bin.000144 > /tmp/binlog2sql-000144.log
Traceback (most recent call last):
File "/root/binlog2sql-master/binlog2sql/binlog2sql.py", line 149, in <module>
back_interval=args.back_interval, only_dml=args.only_dml, sql_type=args.sql_type)
File "/root/binlog2sql-master/binlog2sql/binlog2sql.py", line 53, in __init__
raise ValueError('parameter error: start_file %s not in mysql server' % self.start_file)
ValueError: parameter error: start_file mysql-bin.000144 not in mysql server

The solution is to replace the mysql-bin.000144 of the production environment with the testdb1-bin.000001 of the local test environment
, but only changed the name, but in fact it is the mysql-bin.000144 of the production environment.

If binlog is in GTID mode, but the local test environment is not in GTID mode, the following error will be reported:

[root@testdb1 mysql]# python /root/binlog2sql-master/binlog2sql/binlog2sql.py -h 192.168.119.130 -uroot -pchengce243 --start-file testdb1-bin.000001 > /tmp/binlog2sql-000144.log
Traceback (most recent call last):
File "/root/binlog2sql-master/binlog2sql/binlog2sql.py", line 150, in <module>
binlog2sql.process_binlog()
File "/root/binlog2sql-master/binlog2sql/binlog2sql.py", line 74, in process_binlog
for binlog_event in stream:
File "build/bdist.linux-x86_64/egg/pymysqlreplication/binlogstream.py", line 430, in fetchone
File "build/bdist.linux-x86_64/egg/pymysql/connections.py", line 684, in _read_packet
File "build/bdist.linux-x86_64/egg/pymysql/protocol.py", line 220, in check_error
File "build/bdist.linux-x86_64/egg/pymysql/err.py", line 109, in raise_mysql_exception
pymysql.err.InternalError: (1236, u"Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF, at file ./testdb1-bin.000001, position 234.; the first event 'testdb1-bin.000001' at 4, the last event read from './testdb1-bin.000001' at 299, the last byte read from './testdb1-bin.000001' at 299.")
[root@testdb1 mysql]# python /root/binlog2sql-master/binlog2sql/binlog2sql.py -h 192.168.119.130 -uroot -pchengce243 --start-file testdb1-bin.000001 > /tmp/binlog2sql-000144.log


Solution:
set @@ GLOBAL.GTID_MODE = OFF_PERMISSIVE;


After parsing, remember to turn off GTID_MOD
set @@ GLOBAL.GTID_MODE = OFF;

 

Guess you like

Origin www.cnblogs.com/liang545621/p/12672682.html
Recommended