我的环境是分片集群,抽样检查ycsb库hdshard1是否一致。
hdshard1:PRIMARY> use ycsb switched to db ycsb hdshard1:PRIMARY> db.runCommand({dbhash:1}) { "host" : "mongo6:40001", "collections" : { "usertable" : "8606c40cdb5bc61de864a745e71a343c" }, "capped" : [ ], "uuids" : { "usertable" : UUID("10ebd9a7-fad0-4891-a8b3-454dbe2095e7") }, "md5" : "68ca51e2d360adba7258c504b34806ca", "timeMillis" : 4272, "ok" : 1, "$gleStats" : { "lastOpTime" : Timestamp(0, 0), "electionId" : ObjectId("7fffffff00000000000000b6") }, "lastCommittedOpTime" : Timestamp(1619491176, 2), "$configServerState" : { "opTime" : { "ts" : Timestamp(1619491184, 2), "t" : NumberLong(22) } }, "$clusterTime" : { "clusterTime" : Timestamp(1619491184, 2), "signature" : { "hash" : BinData(0,"mWREst7NePQWOC/KmRzHyswkTfA="), "keyId" : NumberLong("6941260985399246879") } }, "operationTime" : Timestamp(1619491176, 2) }
hdshard1:SECONDARY> db.runCommand({dbhash:1}) { "host" : "mongo7:40001", "collections" : { "usertable" : "8606c40cdb5bc61de864a745e71a343c" }, "capped" : [ ], "uuids" : { "usertable" : UUID("10ebd9a7-fad0-4891-a8b3-454dbe2095e7") }, "md5" : "68ca51e2d360adba7258c504b34806ca", "timeMillis" : 31044, "ok" : 1, "$gleStats" : { "lastOpTime" : Timestamp(0, 0), "electionId" : ObjectId("000000000000000000000000") }, "lastCommittedOpTime" : Timestamp(1619491315, 1), "$configServerState" : { "opTime" : { "ts" : Timestamp(1619491302, 1), "t" : NumberLong(22) } }, "$clusterTime" : { "clusterTime" : Timestamp(1619491315, 1), "signature" : { "hash" : BinData(0,"1Y/JEnLjwSA2w0x0MXox/dgLXmw="), "keyId" : NumberLong("6941260985399246879") } }, "operationTime" : Timestamp(1619491269, 3) }
可以看到是一致的。但是这个操作在大库上会非常耗时,而且会阻塞操作,需谨慎。