温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySQL闪回技术之binlog2sql恢复binlog中的SQL

发布时间:2020-08-07 02:18:23 来源:ITPUB博客 阅读:185 作者:tangyunoracle 栏目:MySQL数据库

># yum remove git

下载git2.2.1并将git添加到环境变量中

># wget https://github.com/git/git/archive/v2.2.1.tar.gz

># 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 https://github.com/danfengcao/binlog2sql.git && cd binlog2sql

Cloning into 'binlog2sql'...

fatal: unable to access 'https://github.com/danfengcao/binlog2sql.git/': 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 -h227.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-------------------------------------------------

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI