mk-table-checksum -d mysql,information-schame--count -d test u=gaoc,h=192.168.0.100,p='111111' u=root,h=localhost,p='111111'
DATABASE TABLE CHUNK HOST ENGINE COUNT CHECKSUM TIME WAIT STAT LAG
test beat 0 192.168.81.100 InnoDB NULL 396522190 0 0 NULL NULL
test.beat does not exist on slave localhost:3306 at /usr/bin/mk-table-checksum line 6812.
test beat 0 localhost InnoDB NULL NULL 0 0 NULL NULL
test.tb_test does not exist on slave localhost:3306 at /usr/bin/mk-table-checksum line 6812.
test tb_test 0 192.168.81.100 InnoDB NULL 3069635991 0 0 NULL NULL
test tb_test 0 localhost InnoDB NULL NULL 0 0 NULL NULL
同时在主库从库创建表:
CREATE TABLE heartbeat (
id int NOT NULL PRIMARY KEY,
ts datetime NOT NULL
);
主库进程:
mk-heartbeat -D test --update -h192.168.0.100 -ugaoc -p111111 --daemonize
从库进程:
mk-heartbeat -D test --monitor -hlocalhost -uroot -p111111 //--file= 可输出到文件
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
0s [ 0.00s, 0.00s, 0.00s ]
检查:
mk-heartbeat -D test --check -hlocalhost -uroot -p111111
0 //没有延迟
这里需要顺带介绍下mk-table-checksum的过滤工具mk-checksum-filter,例如我只想知道上面的例子中,test库中哪些表不是一致的。只需要加一个管道符。
mk-table-checksum -d test u=gaoc,h=192.168.81.100,p='111111' u=root,h=localhost,p='111111' |mk-checksum-filter
test.tb_test does not exist on slave localhost:3307 at /usr/bin/mk-table-checksum line 6812.
test tb_test 0 192.168.81.100 InnoDB NULL 3069635991 0 0 NULL NULL
test tb_test 0 localhost InnoDB NULL NULL 0 0 NULL NULL
需要提醒一下,在使用mk-table-checksum进行操作的时候,会对表加一个表级锁,所以一般这类检查最好是在业务比较闲的时候进行。
参考:http://hi.baidu.com/fans_lamp/blog/item/189c1100cd58bb08738da590.html
mk-table-sync执行后主库记录的binlog
DELETE FROM `test`.`tb_test` WHERE `id`='2' LIMIT 1 /*maatkit src_db:test src_tbl:tb_test src_dsn:P=3306,h=192.168.81.100,p=...,u=gaoc dst_db:test dst_tbl:tb_test dst_dsn:S=/tmp/mysql2.sock,h=localhost,p=...,u=root lock:1 transaction:1 changing_src:1 replicate:0 bidirectional:0 pid:31049 user:root host:localhost*/
执行语句:
mk-table-sync --execute --sync-to-master -d test -t tb_test u=gaoc,h=192.168.81.100,p='111111' u=root,h=localhost,p='111111',S=/tmp/mysql2.sock
阅读(3523) | 评论(0) | 转发(0) |