MongoDB利用dbhash检查一致性

2021/4/27 19:29:16

本文主要是介绍MongoDB利用dbhash检查一致性,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

我的环境是分片集群,抽样检查ycsb库hdshard1是否一致。

检查primary节点

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)
}

检查secondary节点

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)
}

可以看到是一致的。但是这个操作在大库上会非常耗时,而且会阻塞操作,需谨慎。



这篇关于MongoDB利用dbhash检查一致性的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程