MySQL閃回技術之binlog2sql恢復binlog中的SQL

tangyunoracle發表於2019-12-06

># yum remove git

下載git2.2.1並將git新增到環境變數中

># wget

># tar zxvf v2.2.1.tar.gz

># cd git-2.2.1

># make configure

># ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv

># make all doc

># make install install-doc install-html

># echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc

># source /etc/bashrc


4.2 安裝xmlto

yum install xmlto

檢視版本號

># git --version

>git version 2.2.1


[root@dbtest git]# git clone && cd binlog2sql

Cloning into 'binlog2sql'...

fatal: unable to access '/': SSL connect error


解決辦法是把https 改成git

[root@dbtest git]# git clone git://github.com/danfengcao/binlog2sql.git && cd binlog2sql

Cloning into 'binlog2sql'...

remote: Enumerating objects: 323, done.

remote: Total 323 (delta 0), reused 0 (delta 0), pack-reused 323

Receiving objects: 100% (323/323), 151.51 KiB | 88.00 KiB/s, done.

Resolving deltas: 100% (170/170), done.

Checking connectivity... done.


yum install python3 -y

python3 -m pip install pymysql pymysql

cd /usr/local/src

wget 10.70.161.22/python/python-mysql-replication-0.21.tar.gz

tar xf python-mysql-replication-0.21.tar.gz

cd python-mysql-replication-0.21

python3 setup.py install


python3 /app/ty/binlog2sql/binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uroot -p'ty#Tangyun' -dapollo -tt --start-file='mysql-bin.000004' --start-datetime='2019-12-04 14:00:00' --stop-datetime='2019-12-04 14:05:00' > /tmp/binlog_sql.sql


# more /tmp/binlog_sql.sql

USE b'apollo';

create table t(t1 int,t2 varchar(10));

INSERT INTO `apollo`.`t`(`t1`, `t2`) VALUES (1, '1'); #start 41133116 end 41133351 time 2019-12-04 14:01:42

INSERT INTO `apollo`.`t`(`t1`, `t2`) VALUES (1, 't'); #start 41133382 end 41133624 time 2019-12-04 14:02:20

INSERT INTO `apollo`.`t`(`t1`, `t2`) VALUES (2, 't'); #start 41133382 end 41133624 time 2019-12-04 14:02:20


----------------End By【TangYun】2019-12-06-------------------------------------------------


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24930246/viewspace-2667229/,如需轉載,請註明出處,否則將追究法律責任。

相關文章