install mysql replication listenerhttps://github.com/bullsoft/mysql-replication-listener/archive/master.zipunzip mysql-replication-listener-master.zipcd mysql-replication-listener-mastercmake . -dcmake_install_prefix=/usr/local/mysql-replicationmake & make install
install php-binloghttps://github.com/bullsoft/php-binlog/archive/master.zip unzip php-binlog-master.zipcd php-binlog-master/ext/usr/local/php5.5.15/bin/phpize./configure --with-php-config=/usr/local/php5.5.15/bin/php-config --with-mysql-binlog=/usr/local/mysql-replication
examples注:binlog为行格式
update_rowsupdate `type` set type_id = 22 where id in (58, 59);
array(5) { 'type_code' => int(24) 'type_str' => string(11) update_rows 'db_name' => string(5) cloud 'table_name' => string(4) type 'rows' => array(4) { [0] => array(5) { [0] => string(2) 58 [1] => string(8) adsfasdf [2] => string(4) asdf [3] => string(2) 22 [4] => string(1) 0 } [1] => array(5) { [0] => string(2) 58 [1] => string(8) adsfasdf [2] => string(4) asdf [3] => string(1) 4 [4] => string(1) 0 } [2] => array(5) { [0] => string(2) 59 [1] => string(8) adsfasdf [2] => string(4) asdf [3] => string(2) 22 [4] => string(1) 0 } [3] => array(5) { [0] => string(2) 59 [1] => string(8) adsfasdf [2] => string(4) asdf [3] => string(1) 4 [4] => string(1) 0 } }}
delete_rowsdelete from `type` where id in (58, 59);
array(5) { 'type_code' => int(25) 'type_str' => string(11) delete_rows 'db_name' => string(5) cloud 'table_name' => string(4) type 'rows' => array(2) { [0] => array(5) { [0] => string(2) 58 [1] => string(8) adsfasdf [2] => string(4) asdf [3] => string(2) 22 [4] => string(1) 0 } [1] => array(5) { [0] => string(2) 59 [1] => string(8) adsfasdf [2] => string(4) asdf [3] => string(2) 22 [4] => string(1) 0 } }}
write_rowsinsert into type values (null, hello, world, best world, 4, 0), (null, 你好,世界, 世界很美好, 3, 5);
array(5) { 'type_code' => int(23) 'type_str' => string(10) write_rows 'db_name' => string(5) cloud 'table_name' => string(4) type 'rows' => array(2) { [0] => array(5) { [0] => string(2) 95 [1] => string(12) hello, world [2] => string(10) best world [3] => string(1) 4 [4] => string(1) 0 } [1] => array(5) { [0] => string(2) 96 [1] => string(15) 你好,世界 [2] => string(15) 世界很美好 [3] => string(1) 3 [4] => string(1) 5 } }}