Software package download address: Link: https://pan.baidu.com/s/15dDeGufVWOgVrfATGWBzaA Password: gnz8
DBAs or developers sometimes delete or update data by mistake. If it is an online environment , it will have a great impact, which requires fast rollback ; MySQL flashback (flashback) uses binlog to roll back directly, and it can be quickly rolled back. Restore data ( MySQL Flashback now only supports DML statements for flashback ) .
Conditions required to use binlog flashback:
mysql parameter settings:
log_bin = /directory/mysql-bin.log ( on)
binlog_format = row
binlog_row_image = full ( default is full )
The working principle is mainly for the delete operation, the delete information is taken out from the binlog, and the rollback statement of the insert is generated. For insert operations, the rollback SQL is delete. For update operations, the rollback sql should swap the values of SET and WHERE.
Install:
The environment is ready to install a list of various dependent toolkits
Replace python with python3.6 version (python version upgrade reference blog: https://blog.csdn.net/wwwdaan5com/article/details/78218277)
python-pip ,
PyMySQL ,
python-mysql-replication,
wheel argparse
1, binlog2sql download
https://github.com/danfengcao/binlog2sql
2, binlog2sql dependency package installation
(1) PyMySQL-0.8.0 installation
https://pypi.python.org/pypi/PyMySQL/
[root@node1 binlogsql]# tar -xzvf PyMySQL-0.8.0.tar.gz
[root@node1 binlogsql]# cd PyMySQL-0.8.0
[root@node1 PyMySQL-0.8.0]# python setup.py install
(2) wheel-0.31.0 installation
https://pypi.python.org/pypi/wheel/
[root@node1 binlogsql]# tar -xzvf wheel-0.31.0.tar.gz
[root@node1 binlogsql]# cd wheel-0.31.0
[root@node1 wheel-0.31.0]# python setup.py install
(3) python-mysql-replication installation
https://github.com/noplay/python-mysql-replication
[root@node1 binlogsql]# unzip python-mysql-replication-master.zip
[root@node1 binlogsql]# cd python-mysql-replication-master
[root@node1 python-mysql-replication-master]# python setup.py install
(4) You can install the corresponding dependency package through pip
https://pypi.python.org/pypi/pip
[root @ node1 tools] # tar -xzvf pip-10.0.1.tar.gz
[root@node1 tools]# cd pip-10.0.1
[root@node1 pip-10.0.1]# python setup.py install
[root@node1 binlog2sql-master]# pip install -r requirements.txt
Errors may occur.
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/mysql_replication-0.18-py3.6.egg'
Dependency package version problem.
implement. . pip install mysql-replication
Then execute pip install -r requirements.txt
Shows that the installation is complete.