Traceback (most recent call last): File "./mysqldbcompare.py", line 28, in <module> from mysql.utilities.common.tools import check_python_version ImportError: No module named utilities.common.tools
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Checking databases test on server1 and test on server2 # ERROR: The list of objects differs among database test and test.
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Comparing `test1` to `test1` [PASS] # Comparing `test1`.`aa` to `test1`.`aa` [PASS] # Comparing `test1`.`test` to `test1`.`test` [PASS] # Success. All objects are the same.
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Comparing test1.test to test1.test [PASS] # Success. All objects are the same.
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Checking databases test1 on server1 and test1 on server2 # # Defn Row Data # Type Object Name Diff Count Check # ------------------------------------------------------------------------- # TABLE aa pass pass - # - Compare table checksum pass # TABLE test pass FAIL ERROR: Row counts are not the same among `test1`.`test` and `test1`.`test`. #
提示test1库下面的test表数据不一致。
8、创建测试数据,表结构不同,数据内容相同:
server1:
1 2 3 4 5 6 7 8 9 10 11 12
create table test1 (id int(10) primary key); insert into test1 values (1),(2),(3),(4),(5); select * from test1; +----+ | id | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | +----+
server2:
1 2 3 4 5 6 7 8 9 10 11 12
create table test1 (id bigint(20)); insert into test1 values (1),(2),(3),(4),(5); root@db 06:28: [test1]> select * from test1; +------+ | id | +------+ | 1 | | 2 | | 3 | | 4 | | 5 | +------+
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Comparing test1.test1 to test1.test1 [FAIL] # Object definitions differ. (--changes-for=server1) #
--- test1.test1 +++ test1.test1 @@ -1,4 +1,3 @@ CREATE TABLE `test1` ( - `id` int(10) NOT NULL, - PRIMARY KEY (`id`) + `id` bigint(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 # Compare failed. One or more differences found.
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Checking databases test1 on server1 and test1 on server2 # # Defn Row Data # Type Object Name Diff Count Check # ------------------------------------------------------------------------- # TABLE aa pass pass - # - Compare table checksum pass # TABLE test pass FAIL ERROR: Row counts are not the same among `test1`.`test` and `test1`.`test`. #
当检测到异常之后会直接退出,不进行下面的比较,因此未检测到test1表的内容,加上-t(-t, –run-all-tests do not abort when a diff test fails)参数,运行测试模式,遇到异常之后仍然执行下面的比较: ./mysqldbcompare.py –server1=root:12345678@10.0.7.50:3306 –server2=root:12345678@10.0.7.51:3306 test1 –changes-for=server1 –difftype=sql -t
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Checking databases test1 on server1 and test1 on server2 # # Defn Row Data # Type Object Name Diff Count Check # ------------------------------------------------------------------------- # TABLE aa pass pass - # - Compare table checksum pass # TABLE test pass FAIL - # - Compare table checksum FAIL # - Find row differences FAIL # # Row counts are not the same among `test1`.`test` and `test1`.`test`. # # Transformation for --changes-for=server1: #
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # WARNING: Objects in server1.test but not in server2.test: # TABLE: gtid_test14 # Compare failed. One or more differences found.
# WARNING: Using a password on the command line interface can be insecure. # server1 on 10.0.7.50: ... connected. # server2 on 10.0.7.51: ... connected. # Checking databases test on server1 and test on server2 # ERROR: The list of objects differs among database test and test.