利用mysqlbinlog_flashback闪回丢失数据
[root@zlm1 :: /vagrant]
#cd mysqlbinlog_flashback-master [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#ls -l
total
-rwxrwxrwx vagrant vagrant Dec binlogstream.py.diff
-rwxrwxrwx vagrant vagrant Dec CHANGELOG.txt
-rwxrwxrwx vagrant vagrant Dec constant.py
-rwxrwxrwx vagrant vagrant Dec flashback.py
-rwxrwxrwx vagrant vagrant Dec func.py
drwxrwxrwx vagrant vagrant Jun : internal
-rwxrwxrwx vagrant vagrant Dec joint_sql.py
-rwxrwxrwx vagrant vagrant Dec LICENSE
drwxrwxrwx vagrant vagrant Jun : log
-rwxrwxrwx vagrant vagrant Dec mysqlbinlog_back.py
-rwxrwxrwx vagrant vagrant Dec mysql_table.py
drwxrwxrwx vagrant vagrant Jun : pymysqlreplication
-rwxrwxrwx vagrant vagrant Dec README.md
drwxrwxrwx vagrant vagrant Jun : test [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --help
Traceback (most recent call last):
File "mysqlbinlog_back.py", line , in <module>
from flashback import Parameter,deal_all_event,generate_create_table,convert_datetime_to_timestamp
File "/vagrant/mysqlbinlog_flashback-master/flashback.py", line , in <module>
from pymysqlreplication import BinLogStreamReader
File "/vagrant/mysqlbinlog_flashback-master/pymysqlreplication/__init__.py", line , in <module>
from .binlogstream import BinLogStreamReader
File "/vagrant/mysqlbinlog_flashback-master/pymysqlreplication/binlogstream.py", line , in <module>
import pymysql
ImportError: No module named pymysql [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#python --version
Python 2.7. [root@zlm1 :: /vagrant/mysqlbinlog_flashback-master]
#
the tool need python 2.6,mine is 2.7.5,i'll go to the python official website to download it,Python 2.6.9 is the final version of 2.6.x since Oct.29 2013.here's the address:https://www.python.org/download/releases/2.6.9/,below is the directory structure in Python 2.6.9:
[root@zlm1 :: ~/Python-2.6.]
#ls -l
total
-rwxr-xr-x root root Oct configure
-rw-r--r-- root root Oct configure.in
drwxrwxr-x root root Oct Demo
drwxrwxr-x root root Oct Doc
drwxrwxr-x root root Oct Grammar
drwxrwxr-x root root Oct Include
-rwxr-xr-x root root Oct install-sh
drwxrwxr-x root root Oct Lib
-rw-r--r-- root root Oct LICENSE
drwxrwxr-x root root Oct Mac
-rw-r--r-- root root Oct Makefile.pre.in
drwxrwxr-x root root Oct Misc
drwxrwxr-x root root Oct Modules
drwxrwxr-x root root Oct Objects
drwxrwxr-x root root Oct Parser
drwxrwxr-x root root Oct PC
drwxrwxr-x root root Oct PCbuild
-rw-r--r-- root root Oct pyconfig.h.in
drwxrwxr-x root root Oct Python
-rw-r--r-- root root Oct README
drwxrwxr-x root root Oct RISCOS
-rw-r--r-- root root Oct setup.py
drwxrwxr-x root root Oct Tools [root@zlm1 :: ~/Python-2.6.]
#./configure && make && make install
... -- Omitted
[root@zlm1 :: ~/Python-2.6.]
#python --version
Python 2.6. [root@zlm1 :: ~/Python-2.6.]
#[root@zlm1 :: ~/mysqlbinlog_flashback-master]
#pwd
/root/mysqlbinlog_flashback-master [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --help
Traceback (most recent call last):
File "mysqlbinlog_back.py", line , in <module>
from flashback import Parameter,deal_all_event,generate_create_table,convert_datetime_to_timestamp
File "/root/mysqlbinlog_flashback-master/flashback.py", line , in <module>
from pymysqlreplication import BinLogStreamReader
File "/root/mysqlbinlog_flashback-master/pymysqlreplication/__init__.py", line , in <module>
from .binlogstream import BinLogStreamReader
File "/root/mysqlbinlog_flashback-master/pymysqlreplication/binlogstream.py", line , in <module>
import pymysql
ImportError: No module named pymysql [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#
it still appear the identical issue,what's wrong?once more i check the readme.md it says besides the python version,"pymysql" module is also necessary.
[root@zlm1 :: ~/pip-10.0.]
#pip install pymysql
Traceback (most recent call last):
File "/usr/bin/pip", line , in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources [root@zlm1 :: ~/pip-10.0.]
#
[root@zlm1 :: ~/PyMySQL-0.8.]
#ls -l
total
-rw-r--r-- games May : CHANGELOG
-rw-r--r-- games May example.py
-rw-r--r-- games Nov LICENSE
-rw-r--r-- games Jan MANIFEST.in
-rw-r--r-- games May : PKG-INFO
drwxr-xr-x games May : pymysql
drwxr-xr-x games May : PyMySQL.egg-info
-rw-r--r-- games May : README.rst
-rwxr-xr-x games Aug runtests.py
-rw-r--r-- games May : setup.cfg
-rwxr-xr-x games May : setup.py
-rw-r--r-- games Jan tox.ini [root@zlm1 :: ~/PyMySQL-0.8.]
#python setup.py install
Traceback (most recent call last):
File "setup.py", line , in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools [root@zlm1 :: ~/PyMySQL-0.8.]
#chown root.root -R * [root@zlm1 :: ~/PyMySQL-0.8.]
#ls -l
total
-rw-r--r-- root root May : CHANGELOG
-rw-r--r-- root root May example.py
-rw-r--r-- root root Nov LICENSE
-rw-r--r-- root root Jan MANIFEST.in
-rw-r--r-- root root May : PKG-INFO
drwxr-xr-x root root May : pymysql
drwxr-xr-x root root May : PyMySQL.egg-info
-rw-r--r-- root root May : README.rst
-rwxr-xr-x root root Aug runtests.py
-rw-r--r-- root root May : setup.cfg
-rwxr-xr-x root root May : setup.py
-rw-r--r-- root root Jan tox.ini [root@zlm1 :: ~/PyMySQL-0.8.]
#python setup.py install
Traceback (most recent call last):
File "setup.py", line , in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools -- It seems another module name "setuptools" is needed. [root@zlm1 :: ~/setuptools-39.2.]
#ls -l
total
-rwxrwxrwx root root May : bootstrap.py
-rwxrwxrwx root root May : CHANGES.rst
-rwxrwxrwx root root May : conftest.py
drwxrwxrwx root root Jun : docs
-rwxrwxrwx root root May : easy_install.py
-rwxrwxrwx root root May : launcher.c
-rwxrwxrwx root root May : LICENSE
-rwxrwxrwx root root May : MANIFEST.in
-rwxrwxrwx root root May : msvc-build-launcher.cmd
-rwxrwxrwx root root May : pavement.py
-rwxrwxrwx root root May : PKG-INFO
drwxrwxrwx root root Jun : pkg_resources
-rwxrwxrwx root root May : pytest.ini
-rwxrwxrwx root root May : README.rst
-rwxrwxrwx root root May : setup.cfg
-rwxrwxrwx root root May : setup.py
drwxrwxrwx root root Jun : setuptools
drwxrwxrwx root root Jun : setuptools.egg-info
drwxrwxrwx root root Jun : tests
-rwxrwxrwx root root May : towncrier_template.rst
-rwxrwxrwx root root May : tox.ini [root@zlm1 :: ~/setuptools-39.2.]
#python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to setuptools.egg-info/requires.txt
writing setuptools.egg-info/PKG-INFO
writing top-level names to setuptools.egg-info/top_level.txt
writing dependency_links to setuptools.egg-info/dependency_links.txt
writing entry points to setuptools.egg-info/entry_points.txt
reading manifest file 'setuptools.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'setuptools.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
... -- Omitted. root@zlm1 :: ~/PyMySQL-0.8.]
#python setup.py install
/usr/lib64/python2./distutils/dist.py:: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing PyMySQL.egg-info/PKG-INFO
writing top-level names to PyMySQL.egg-info/top_level.txt
writing dependency_links to PyMySQL.egg-info/dependency_links.txt
reading manifest file 'PyMySQL.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'PyMySQL.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/pymysql
... -- Omitted. --Finally the PyMySQL was installed successfully.
[root@zlm1 :: ~/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --help
===log will also write to .//mysqlbinlog_flashback.log===
Usage: python mysqlbinlog_back.py [options]
sample1:python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="" --schema=test --table="test5"
sample2:python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="" --schema=test --table="test5,test6" --binlog_end_time="2016-11-05 11:27:13" --binlog_start_file_name="mysql-bin.000024" --binlog_start_file_position= --binlog_start_time="2016-11-04 11:27:13" --skip_delete --skip_insert --add_schema_name
sample3:python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="" --schema=test --table="test5,test6" --binlog_start_file_name="mysql-bin.000022" Options:
-h, --help show this help message and exit
-H HOST, --host=HOST mandatory,mysql hostname
-P PORT, --port=PORT mysql port,default
-u USERNAME, --username=USERNAME
mandatory,username
-p PASSWORD, --password=PASSWORD
password
-s SCHEMA, --schema=SCHEMA
mandatory,mysql schema
-t TABLES, --tables=TABLES
mandatory,mysql tables,suport multiple tables,use
comma as separator
-N BINLOG_END_TIME, --binlog_end_time=BINLOG_END_TIME
binlog end time,format yyyy-mm-dd hh24:mi:ss,default
is current time
-S BINLOG_START_FILE_NAME, --binlog_start_file_name=BINLOG_START_FILE_NAME
binlog start file name,default is current logfile of
db
-L BINLOG_START_FILE_POSITION, --binlog_start_file_position=BINLOG_START_FILE_POSITION
binlog start file name
-E BINLOG_START_TIME, --binlog_start_time=BINLOG_START_TIME
binlog start time,format yyyy-mm-dd hh24:mi:ss
-l OUTPUT_FILE_PATH, --output_file_path=OUTPUT_FILE_PATH
file path that sql generated,,default ./log
-I, --skip_insert skip insert(WriteRowsEvent) event
-U, --skip_update skip update(UpdateRowsEvent) event
-D, --skip_delete skip delete(DeleteRowsEvent) event
-a, --add_schema_name
add schema name for flashback sql
-v, --version version info
okay,now the tool mysqlbinlog_flashback can te used normally,let's begin our data-loss flashback test:
root@localhost:mysql3306.sock [zlm]05:39:39>create table test(
-> id bigint not null auto_increment,
-> name varchar(20) not null default '',
-> primary key(id)
-> ) engine=innodb default charset=utf8mb4;
Query OK, 0 rows affected (0.05 sec) root@localhost:mysql3306.sock [zlm]05:39:45>delimiter //
root@localhost:mysql3306.sock [zlm]05:39:51>create procedure pro_insert()
-> begin
-> declare id int;
-> set id = 100000;
-> while id>0 do
-> insert into test(name) values ('aaron8219');
-> set id=id-1;
-> end while;
-> end //
Query OK, 0 rows affected (0.05 sec) root@localhost:mysql3306.sock [zlm]05:39:51>delimiter ;
root@localhost:mysql3306.sock [zlm]05:39:53>call pro_insert();
Query OK, 1 row affected (8.87 sec) root@localhost:mysql3306.sock [zlm]05:40:40>select count(*) from test;
+----------+
| count(*) |
+----------+
| 100000 |
+----------+
1 row in set (0.03 sec) root@localhost:mysql3306.sock [zlm]05:41:02>flush logs;
Query OK, 0 rows affected (0.12 sec) root@localhost:mysql3306.sock [zlm]05:42:03>show binary log;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'log' at line 1
root@localhost:mysql3306.sock [zlm]05:42:10>show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000016 | 680 |
| mysql-bin.000017 | 268435617 |
| mysql-bin.000018 | 72724171 |
| mysql-bin.000019 | 241 |
| mysql-bin.000020 | 11019314 |
| mysql-bin.000021 | 241 |
| mysql-bin.000022 | 1305983 |
| mysql-bin.000023 | 268435590 |
| mysql-bin.000024 | 9566499 |
| mysql-bin.000025 | 19081875 |
| mysql-bin.000026 | 27801367 |
| mysql-bin.000027 | 1908620 |
| mysql-bin.000028 | 1908617 |
| mysql-bin.000029 | 8337364 |
| mysql-bin.000030 | 83100241 |
| mysql-bin.000031 | 3214613 |
| mysql-bin.000032 | 241 |
| mysql-bin.000033 | 217 |
| mysql-bin.000034 | 217 |
| mysql-bin.000035 | 217 |
| mysql-bin.000036 | 27000879 |
| mysql-bin.000037 | 194 |
+------------------+-----------+
22 rows in set (0.00 sec) root@localhost:mysql3306.sock [zlm]05:42:14>update test set name='zlm';
Query OK, 100000 rows affected (1.83 sec)
Rows matched: 100000 Changed: 100000 Warnings: 0 root@localhost:mysql3306.sock [zlm]05:42:38>select * from test limit 1,5;
+----+------+
| id | name |
+----+------+
| 2 | zlm |
| 3 | zlm |
| 4 | zlm |
| 5 | zlm |
| 6 | zlm |
+----+------+
5 rows in set (0.00 sec) root@localhost:mysql3306.sock [zlm]05:43:02>show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000016 | 680 |
| mysql-bin.000017 | 268435617 |
| mysql-bin.000018 | 72724171 |
| mysql-bin.000019 | 241 |
| mysql-bin.000020 | 11019314 |
| mysql-bin.000021 | 241 |
| mysql-bin.000022 | 1305983 |
| mysql-bin.000023 | 268435590 |
| mysql-bin.000024 | 9566499 |
| mysql-bin.000025 | 19081875 |
| mysql-bin.000026 | 27801367 |
| mysql-bin.000027 | 1908620 |
| mysql-bin.000028 | 1908617 |
| mysql-bin.000029 | 8337364 |
| mysql-bin.000030 | 83100241 |
| mysql-bin.000031 | 3214613 |
| mysql-bin.000032 | 241 |
| mysql-bin.000033 | 217 |
| mysql-bin.000034 | 217 |
| mysql-bin.000035 | 217 |
| mysql-bin.000036 | 27000879 |
| mysql-bin.000037 | 3214558 |
+------------------+-----------+
22 rows in set (0.00 sec) root@localhost:mysql3306.sock [zlm]05:43:22>
obviously,the lost data should be contained in "mysql-bin.000037",let's have a try by using mysqlbinlog_flash to get back the data,first of all,let's see what's in the binary log "mysql-bin.000037":
[root@zlm1 :: /data/mysql/mysql3306/logs]
#mysqlbinlog -vv --base64-output=decode-rows mysql-bin. | sed -n '1,50p'
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at
# :: server id end_log_pos CRC32 0xf0e90436 Start: binlog v , server v 5.7.-log created ::
# Warning: this binlog is either in use or was not closed properly.
# at
# :: server id end_log_pos CRC32 0xb6bac207 Previous-GTIDs
# 2a4b3562-2ab6-11e8-be7a-080027de0e0e:-
# at
# :: server id end_log_pos CRC32 0x67866ae9 GTID last_committed= sequence_number= rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= '2a4b3562-2ab6-11e8-be7a-080027de0e0e:2600052'/*!*/;
# at
# :: server id end_log_pos CRC32 0xd92b1815 Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
SET @@session.pseudo_thread_id=/*!*/;
SET @@session.foreign_key_checks=, @@session.sql_auto_is_null=, @@session.unique_checks=, @@session.autocommit=/*!*/;
SET @@session.sql_mode=/*!*/;
SET @@session.auto_increment_increment=, @@session.auto_increment_offset=/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=,@@session.collation_connection=,@@session.collation_server=/*!*/;
SET @@session.lc_time_names=/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos CRC32 0xcfa8815d Table_map: `zlm`.`test` mapped to number -- The Table_map event from position .
# at
# :: server id end_log_pos CRC32 0xadcde7b6 Update_rows: table id -- The Update_rows event from postion .
# at
# :: server id end_log_pos CRC32 0xee29017d Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x6306a3c2 Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x69ca971f Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xb99e0b43 Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xe8438e0a Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x2a83a31d Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xbcb85d9c Update_rows: table id
# at
# :: server id end_log_pos CRC32 0xfd385e6b Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x5dd0ec46 Update_rows: table id
# at
# :: server id end_log_pos CRC32 0x14c028cb Update_rows: table id
-- Omitted
[root@zlm1 :: ~/mysqlbinlog_flashback-master]
#pwd
/root/mysqlbinlog_flashback-master [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#python mysqlbinlog_back.py --host="127.0.0.1" --username="root" --port= --password="Passw0rd" --schema=zlm --table="test" --add_schema_name
===log will also write to .//mysqlbinlog_flashback.log===
parameter={'start_binlog_file': u'mysql-bin.000037', 'stream': None, 'keep_data': True, 'file': {'data_create': None, 'flashback': None, 'data': None}, 'add_schema_name': True, 'start_time': None, 'keep_current_data': False, 'start_to_timestamp': None, 'mysql_setting': {'passwd': 'Passw0rd', 'host': '127.0.0.1', 'charset': 'utf8', 'port': , 'user': 'root'}, 'table_name': 'test', 'skip_delete': False, 'schema': 'zlm', 'stat': {'flash_sql': {}}, 'table_name_array': ['test'], 'one_binlog_file': False, 'output_file_path': './log', 'start_position': , 'skip_update': False, 'dump_event': False, 'end_to_timestamp': 1528473771.0, 'skip_insert': False, 'schema_array': ['zlm']}
===statistics===
scan events
{'flash_sql': {u'zlm': {u'test': {'insert': , 'update': , 'delete': }}}} [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#ls -l
total
-rwxrwxrwx root root Dec binlogstream.py.diff
-rwxrwxrwx root root Dec CHANGELOG.txt
-rwxrwxrwx root root Dec constant.py
-rw-r--r-- root root Jun : constant.pyc
-rwxrwxrwx root root Dec flashback.py
-rwxrwxrwx root root Jun : flashback.pyc
-rwxrwxrwx root root Dec func.py
-rwxrwxrwx root root Jun : func.pyc
drwxrwxrwx root root Jun : internal
-rwxrwxrwx root root Dec joint_sql.py
-rw-r--r-- root root Jun : joint_sql.pyc
-rwxrwxrwx root root Dec LICENSE
drwxrwxrwx root root Jun : log -- If you don't sepcify the "OUTPUT_FILE_PATH",this directory is default value.
-rwxrwxrwx root root Dec mysqlbinlog_back.py
-rw-r--r-- root root Jun : mysqlbinlog_flashback.log
-rwxrwxrwx root root Dec mysql_table.py
-rw-r--r-- root root Jun : mysql_table.pyc
drwxrwxrwx root root Jun : pymysqlreplication
-rwxrwxrwx root root Dec README.md
drwxrwxrwx root root Jun : test [root@zlm1 :: ~/mysqlbinlog_flashback-master]
#cd log [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#ls -l
total
-rw-r--r-- root root Jun : flashback_zlm_20180608_180251.sql -- This file contains the real records to flashback.
-rw-r--r-- root root Jun : save_data_create_table_zlm_20180608_180251.sql -- This file contains the structure of intermediate table.
-rw-r--r-- root root Jun : save_data_dml_zlm_20180608_180251.sql -- This file contains the records which will be inserted into the intermediate table which called "_test_keep_data_"(here,"test" is the real table name which you want to flashback data)
-rwxrwxrwx root root Dec test.txt [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#cat save_data_create_table_zlm_20180608_180251.sql
CREATE TABLE `_test_keep_data_` (op varchar(),op_datetime datetime,bfr_id bigint(),bfr_name varchar(),aft_id bigint(),aft_name varchar()) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#cat save_data_dml_zlm_20180608_180251.sql | tail -
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update');
insert into `_test_keep_data_`(`op_datetime`,`bfr_name`,`aft_id`,`aft_name`,`bfr_id`,`op`) values('2018-06-08 17:42:36','aaron8219',,'zlm',,'update'); [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#cat flashback_zlm_20180608_180251.sql | tail -
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=;
update `zlm`.`test` set`id`=,`name`='aaron8219' where `id`=; [root@zlm1 :: ~/mysqlbinlog_flashback-master/log]
#
since we've got the sql file which can flashback our lost data,let's have a try:
[root@zlm1 18:08:50 ~/mysqlbinlog_flashback-master/log]
#mysql --default-character-set=utf8mb4 < flashback_zlm_20180608_180251.sql [root@zlm1 18:19:59 ~/mysqlbinlog_flashback-master/log]
#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.21-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@localhost:mysql3306.sock [(none)]06:20:09>use zlm;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
root@localhost:mysql3306.sock [zlm]06:20:12>select count(*) from test where name='zlm';
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.03 sec) root@localhost:mysql3306.sock [zlm]06:20:49>select count(*) from test where name='aaron8219';
+----------+
| count(*) |
+----------+
| 100000 |
+----------+
1 row in set (0.03 sec) root@localhost:mysql3306.sock [zlm]06:20:55>
- mysqlbinlog_flashback is similar with the binglog2sql which also depend on python 2.6(maybe above is also feasible),you must install several python module such as PyMySQL,setuptools to ensure the tool can work normally.
- mysqlbinlog_flashback is surely non-offline tool when parsing the needed binary logs which is the same as MyFlash,binlog2sql.
- mysqlbinlog_flashback works effectively,10w rows of records can be flashback in a rather short time.
- what i most favorate point is that the output file is extraordinarily unambiguous,you can clearly see what it will really do by these sql files(check them first then flashback).
- contrast the tool with MyFlash & binlog2sql,mysqlbinlog_flashback is the most convenient tool to flashback lost data.the other two tools are difficult to dignose when exception occurs.they seem like black boxes i'm afraid.
利用mysqlbinlog_flashback闪回丢失数据的更多相关文章
- 利用binlog2sql闪回丢失数据
today,i'll using the open source tool named "binlog2sql" which is release by danfengch ...
- 利用MyFlash闪回丢失数据(续)
last night,i've tested flashback by MyFlash tool,but failed,now let's do some other test with ...
- 利用MyFlash闪回丢失数据
MyFlash is an open source tool released by Meituan-Dianping which can be used to flashback MyS ...
- oracle_利用闪回功能恢复数据
方便起见一般:执行如下即可不用往下看: ① 启用行移动功能 alter table tbl_a enable row movement; ② 闪回表数据到某个时间点 flashback table t ...
- Oracle 闪回 找回数据的实现方法
Oracle 闪回 找回数据的实现方法 闪回技术是Oracle强大数据库备份恢复机制的一部分,在数据库发生逻辑错误的时候,闪回技术能提供快速且最小损失的恢复.这篇文章主要介绍了Oracle 闪回 找回 ...
- Oracle闪回技术之一Oracle 11g 利用FlashTable (闪回表)恢复(用delete)误删的数据
闪回表,实际上就是将表中的数据快速恢复到过去的一个时间点或者系统改变号SCN上.实现表的闪回,需要用到撤销表空间相关的UNDO信息,通过SHOW PARAMETER UNDO命令就可以了解这些信息.用 ...
- Flashback Version Query、Flashback Transaction Query快速闪回细粒度数据
Flashback Version Query 闪回版本查询 使用Flashback Version Query 返回在指定时间间隔或SCN间隔内的所有版本,一次commit命令就会创建一个版本. ...
- Oracle 闪回 找回数据
使用闪回技术,实现基于磁盘上闪回恢复区的自动备份与还原. 一.恢复表对象 1.创建学生表 create table STUDENT ( idno INTEGER, name VARCHAR2(30), ...
- oracle flashback data archive闪回数据归档天坑之XID重用导致闪回查询数据重复
我们有个系统使用了Oracle flashback data archive闪回数据归档特性来作为基于时间点的恢复机制,在频繁插入.更新期间发现SYS_FBA_HIST_NNNN表中的XID被两个事务 ...
随机推荐
- python 进程池的使用
进程同步 进程的数据是独立存在的,进程也能加锁. from multiprocessing import Process, Lock def f(l,i): l.acquire() print('he ...
- git rebase vs git merge详解
https://medium.com/@porteneuve/getting-solid-at-git-rebase-vs-merge-4fa1a48c53aa#.std3ddz0g 请参考另外一篇文 ...
- base64编码加密图片和展示图片
base64是当前网络上最为常见的传输8Bit字节代码的编码方式其中之一.base64主要不是加密,它主要的用途是把某些二进制数转成普通字符用于 网络传输.由于这些二进制字符在传输协议中属于控制字符, ...
- Visual Stuio 2010 常用快捷及操作(转)
文章来源:http://www.cnblogs.com/martianzone/p/3373791.html 1.如果你想复制一行代码(超级长,鼠标拖老久的),只需要在这行的空白处 CTRL+C 同理 ...
- GCD学习(五) dispatch_barrier_async
先看段代码 dispatch_queue_t concurrentQueue = dispatch_queue_create("my.concurrent.queue", DISP ...
- poj 3253 Fence Repair (STL优先队列)
版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/34805369 转载请注明出 ...
- 20165214 2018-2019-2 《网络对抗技术》Exp6 信息搜集与漏洞扫描 Week9
<网络对抗技术>Exp6 信息搜集与漏洞扫描 Week9 一.实验目标与内容 1.实践目标 掌握信息搜集的最基础技能与常用工具的使用方法. 2.实践内容 (1)各种搜索技巧的应用 使用搜索 ...
- Linux 进程与信号的概念和操作 linux process and signals
进程 主要参考: http://www.bogotobogo.com/Linux/linux_process_and_signals.php 译者:李秋豪 信号与进程几乎控制了操作系统的每个任务. 在 ...
- bagging 和boosting的概念和区别
1.先弄清楚模型融合中的投票的概念 分为软投票和硬投票,硬投票就是几个模型预测的哪一类最多,最终模型就预测那一类,在投票相同的情况下,投票结果会按照分类器的排序选择排在第一个的分类器结果.但硬投票有个 ...
- 手工检测SQL注入(安全性测试)
手动你的ASP站可否注入: http://127.0.0.1/xx?id=11 and 1=1 (正常页面) http://127.0.0.1/xx?id=11 and 1=2 (出错页面) 检测表段 ...