1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| # 确保MySQL开启了binlog功能,且格式为ROW server-id=1 log-bin=mysql-bin binlog_format=ROW
# 开启GTID模式(主从一致性) gtid-mode=on enforce-gtid-consistency=1 # 设置为主从强一致性 log-slave-updates=1 # 记录日志
#MySQL数据 CREATE DATABASE testck; CREATE TABLE `testck`.`t_organization` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` int NOT NULL, `name` text DEFAULT NULL, `updatetime` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY (`code`) ) ENGINE=InnoDB;
INSERT INTO testck.t_organization (code, name,updatetime) VALUES(1000,'Realinsight',NOW()); INSERT INTO testck.t_organization (code, name,updatetime) VALUES(1001, 'Realindex',NOW()); INSERT INTO testck.t_organization (code, name,updatetime) VALUES(1002,'EDT',NOW());
CREATE TABLE `testck`.`t_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` int, PRIMARY KEY (`id`) ) ENGINE=InnoDB; INSERT INTO testck.t_user (code) VALUES(1);
#开启CK物化引擎 set allow_experimental_database_materialize_mysql=1;
#创建复制管道 CREATE DATABASE test_binlog ENGINE = MaterializeMySQL('hadoop1:3306','testck','root','000000'); MySQL地址,DataBase,Username,Password
use test_binlog; show tables; select * from t_organization; select * from t_user;
#修改MySQL数据 update t_organization set name = CONCAT(name,'-v1') where id = 1;
#查看CK内数据 select * from t_organization;
#删除MySQL数据 DELETE FROM t_organization where id = 2;
#查看CK内虚拟字段 select *,_sign,_version from t_organization order by _sign desc,_version desc;
|