首页 > 解决方案 > 无法为 sharded MongoDB 集群的配置服务器启动副本集

问题描述

我正在按照这个链接部署一个分片集群。正如他们所说,在第一步中,我已经启动了三个单独的 mongod 实例

mongod --configsvr --replSet “cs” --dbpath mongodb/config/config-c --bind_ip localhost --port 57042
mongod --configsvr --replSet “cs” --dbpath mongodb/config/config-c --bind_ip localhost --port 57042
mongod --configsvr --replSet “cs” --dbpath mongodb/config/config-c --bind_ip localhost --port 57042

在第二步之后,当我尝试像他们提到的那样启动副本集时

rs.initiate( { _id: "cs", configsvr: true, members: [ { _id : 0, host : "localhost:57040" }, { _id : 1, host : "localhost:57041" }, { _id : 2, host : "localhost:57042" }]})

我收到一个错误

{
    "operationTime" : Timestamp(0, 0),
    "ok" : 0,
    "errmsg" : "Attempting to initiate a replica set with name cs, but command line reports “cs”; rejecting",
    "code" : 93,
    "codeName" : "InvalidReplicaSetConfig",
    "$gleStats" : {
        "lastOpTime" : Timestamp(0, 0),
        "electionId" : ObjectId("000000000000000000000000")
    },
    "lastCommittedOpTime" : Timestamp(0, 0),
    "$clusterTime" : {
        "clusterTime" : Timestamp(0, 0),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    }
}

为什么我会收到此错误?如何解决这个问题?

标签: mongodbmongodb-replica-set

解决方案


推荐阅读