Skip to content

fengxiangyun/mysql-replication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
zhao.zhiqiang
Aug 12, 2019
a9da836 · Aug 12, 2019

History

61 Commits
Aug 12, 2019
Sep 15, 2017
Jan 12, 2016
Jan 12, 2016
Aug 12, 2019
Sep 15, 2017
Jan 12, 2016
Mar 11, 2017
Jul 22, 2016
Aug 20, 2016
Jun 8, 2017

Repository files navigation

php-mysql-replication

参考python版本:https://github.com/noplay/python-mysql-replication

运行环境

目前只支持数据库utf8编码
php版本>=5.4
mysql版本>=5.1
需要安装php sockets扩展
运行用户需要有创建文件的权限

Config.php 配置文件

运行run.php 目前只支持row模式
项目中 可以用supervisor监控 run.php 进程
Connect::analysisBinLog bool true存储当前的file pos
本例中 通过读取binlog存储到kafka中 kafka版本 0.8.2.0
kafka-client 用到了github开源的一个项目 https://github.com/nmred/kafka-php
BinLogPack.php打印了事件类型

配置mysql,打开mysql的binlog,配置binlog格式为row

log-bin=mysql-bin
server-id=1
binlog_format=row

持久化

file-pos 保存了当前读取到binlog的filename和pos,保证程序异常退出后能继续读取binlog
新项目运行时 要删除file-pos,从当前show master status,读取到的filename pos开始读取
可以设置file-pos,程序则从当前设置的位置读取binlog

流程

image

联系我

任何问题可以mail
[email protected]
QQ:838⑤91688

About

mysql replication binlog php 同步工具

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages