1.确认MySQL相关配置以及用户权限
使用MySQL server必须设置以下参数:
[mysqld]
server_id = 1
log_bin = /var/log/mysql/mysql-bin.log
max_binlog_size = 1G
binlog_format = row
binlog_row_image = full
user需要的最小权限集合:
select, super/replication client, replication slave
建议授权
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO
2.下载安装binlog2sql,并做调整requirements文件
shell> git clone https://github.com/danfengcao/binlog2sql.git && cd binlog2sql
**binlog2sql路径下的requirements.txt文件需要调整**
cat requirements.txt
PyMySQL==0.7.11
wheel==0.29.0
mysql-replication==0.13
需要将PyMySQL由0.7.11调整为0.9.3
shell> pip install -r requirements.txt
3.测试
- 测试数据准备
mysql> select * from test;
+
| id | name | create_time |
+
| 1 | crmsb | 2020-