0

我想创建一个 confiserver 的副本集。为此,我执行了以下步骤:

1. 我使用以下配置创建了两个配置服务器:

sharding:
 clusterRole: configsvr

replication:
 replSetName: TestConfigServer1

net:
 bindIp: 127.0.0.1
 port: 27018

storage:
 dbPath: E:\Programming\MongoDBProgramming\Mongodb

sharding:
 clusterRole: configsvr

replication:
 replSetName: TestConfigServer1

net:
 bindIp: 127.0.0.1
 port: 27019

storage:
 dbPath: E:\Programming\MongoDBProgramming\Mongodb1


2. 然后我将“mongo”连接到第一个配置,并运行以下命令:

rs.initiate()
rs.add( {_id: 1,host: 127.0.0.1:27019} )

这创建了以 27018 端口为主的副本集。

然后在关闭所有 mongod 服务器后,我尝试再次启动副本集。

我先使用相应的配置文件启动了27018端口,然后我尝试以同样的方式启动27019端口。对于 27019,我收到以下错误:

2020-05-20T21:48:37.449+0530 F - [replication-0] 致命断言 40088 InitialSyncFailure:错误克隆数据库 :: 由 :: Location14037 引起:错误克隆集合“.new_enrollment” :: 由 :: can't 引起在 src\mongo\db\repl\replication_coordinator_impl.cpp 743 的 --configsvr 实例上创建用户数据库

此外,当将 mongo shell 连接到 27018 服务器并检查副本集状态时,它显示 27018 服务器为辅助服务器。我在这里做错了什么?


编辑:来自 rs.status() 的结果

TestConfigServer1:SECONDARY> rs.status()
{
        "set" : "TestConfigServer1",
        "date" : ISODate("2020-05-20T17:03:47.950Z"),
        "myState" : 2,
        "term" : NumberLong(4),
        "syncingTo" : "",
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "configsvr" : true,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 2,
        "writeMajorityCount" : 2,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(0, 0),
                        "t" : NumberLong(-1)
                },
                "lastCommittedWallTime" : ISODate("1970-01-01T00:00:00Z"),
                "appliedOpTime" : {
                        "ts" : Timestamp(1589991517, 1),
                        "t" : NumberLong(4)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1589991517, 1),
                        "t" : NumberLong(4)
                },
                "lastAppliedWallTime" : ISODate("2020-05-20T16:18:37.962Z"),
                "lastDurableWallTime" : ISODate("2020-05-20T16:18:37.962Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1589907661, 1),
        "lastStableCheckpointTimestamp" : Timestamp(1589907661, 1),
        "members" : [
                {
                        "_id" : 0,
                        "name" : "127.0.0.1:27018",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 3168,
                        "optime" : {
                                "ts" : Timestamp(1589991517, 1),
                                "t" : NumberLong(4)
                        },
                        "optimeDate" : ISODate("2020-05-20T16:18:37Z"),
                        "syncingTo" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "could not find member to sync from",
                        "configVersion" : 2,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                },
                {
                        "_id" : 1,
                        "name" : "127.0.0.1:27019",
                        "health" : 0,
                        "state" : 8,
                        "stateStr" : "(not reachable/healthy)",
                        "uptime" : 0,
                        "optime" : {
                                "ts" : Timestamp(0, 0),
                                "t" : NumberLong(-1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(0, 0),
                                "t" : NumberLong(-1)
                        },
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2020-05-20T17:03:46.549Z"),
                        "lastHeartbeatRecv" : ISODate("2020-05-20T16:18:37.166Z"),
                        "pingMs" : NumberLong(7),
                        "lastHeartbeatMessage" : "Error connecting to 127.0.0.1:27019 :: caused by :: No connection could be made because the target machine actively refused it.",
                        "syncingTo" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "configVersion" : -1
                }
        ],
        "ok" : 1,
        "$gleStats" : {
                "lastOpTime" : Timestamp(0, 0),
                "electionId" : ObjectId("7fffffff0000000000000004")
        },
        "lastCommittedOpTime" : Timestamp(0, 0),
        "$clusterTime" : {
                "clusterTime" : Timestamp(1589991517, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1589991517, 1)
}
4

1 回答 1

1

我猜你在之前用于另一个部署的数据目录中启动了第一个配置服务器。从一个空的数据目录开始。

于 2020-05-20T17:03:54.210 回答