【发布时间】:2017-09-07 15:03:01
【问题描述】:
我有一个使用 MariaDB 的简单主->从设置:
大师:Ubuntu 16.04 LTS 和 MariaDB 10.2.8 和 percona-toolkit 3.0.4
从站:Ubuntu 16.04 LTS 和 MariaDB 10.2.7
复制运行良好,现在我想检查主从之间的数据是否相同。
我在master上安装了percona-toolkit并创建了一个校验和用户:
MariaDB> GRANT REPLICATION SLAVE,PROCESS,SUPER, SELECT ON *.* TO `pt_checksum`@'%' IDENTIFIED BY 'password';
MariaDB> GRANT ALL PRIVILEGES ON percona.* TO `pt_checksum`@'%';
MariaDB> FLUSH PRIVILEGES;
我还在 slave conf 中添加了 report_host,以便它向 master 展示自己:
MariaDB [(none)]> show slave hosts;
+-----------+-----------+------+-----------+
| Server_id | Host | Port | Master_id |
+-----------+-----------+------+-----------+
| 2 | 10.0.0.49 | 3306 | 1 |
+-----------+-----------+------+-----------+
1 row in set (0.00 sec)
为了测试 pt-table-checksum,我从从属服务器上的测试数据库中的 Tickets 表中删除了一行。我已经验证了这一行确实丢失了,但仍然存在于 master 上。
但是 pt-table-checksum 没有报告这个差异:
# pt-table-checksum --databases=shop_test --tables=Tickets --host=localhost --user=pt_checksum --password=... --no-check-binlog-format --no-check-replication-filters
TS ERRORS DIFFS ROWS CHUNKS SKIPPED TIME TABLE
09-07T16:15:02 0 0 14 1 0 0.013 shop_test.Tickets
所以我在我的环境中设置了 PTDEBUG=1,但似乎主服务器与从服务器连接良好。我试图从输出中挑选出相关位:
# MasterSlave:5175 9725 Connected to h=localhost,p=...,u=pt_checksum
# MasterSlave:5184 9725 SELECT @@SERVER_ID
# MasterSlave:5186 9725 Working on server ID 1
# MasterSlave:5219 9725 Looking for slaves on h=localhost,p=...,u=pt_checksum using methods processlist hosts
# MasterSlave:5226 9725 Finding slaves with _find_slaves_by_processlist
# MasterSlave:5288 9725 DBI::db=HASH(0x31c5190) SHOW GRANTS FOR CURRENT_USER()
# MasterSlave:5318 9725 DBI::db=HASH(0x31c5190) SHOW FULL PROCESSLIST
# DSNParser:1417 9725 Parsing h=10.0.0.49
[...]
# MasterSlave:5231 9725 Found 1 slaves
# MasterSlave:5208 9725 Recursing from h=localhost,p=...,u=pt_checksum to h=10.0.0.49,p=...,u=pt_checksum
# MasterSlave:5155 9725 Recursion methods: processlist hosts
[...]
# MasterSlave:5175 9725 Connected to h=10.0.0.49,p=...,u=pt_checksum
# MasterSlave:5184 9725 SELECT @@SERVER_ID
# MasterSlave:5186 9725 Working on server ID 2
# MasterSlave:5097 9725 Found slave: h=10.0.0.49,p=...,u=pt_checksum
[...]
# pt_table_checksum:9793 9725 Exit status 0 oktorun 1
# Cxn:3764 9725 Destroying cxn
# Cxn:3774 9725 DBI::db=HASH(0x31cd218) Disconnecting dbh on slaveserver h=10.0.0.49
# Cxn:3764 9725 Destroying cxn
# Cxn:3774 9725 DBI::db=HASH(0x31c5190) Disconnecting dbh on masterserver h=localhost
我没有想法,为什么没有检测到丢失的行?
【问题讨论】:
标签: checksum database-replication percona