简体   繁体   中英

Getting “can't create user databases on a --configsvr instance” error while trying to start replicaset of config server

I want to create a replicaset of confiserver. For that I performed the following steps:

1. I created two config server using the following configs:

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. Then I connected "mongo" to the first config, and ran following commands:

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

This created the replicaset with 27018 port as primary.

Then after closing all the mongod servers, I tried to start the replicaset again.

I started the port 27018 first using the corresponding config file, and then I tried started port 27019 the same way. For the 27019 I got the following error:

2020-05-20T21:48:37.449+0530 F - [replication-0] Fatal assertion 40088 InitialSyncFailure: error cloning databases:: caused by:: Location14037: Error cloning collection '.new_enrollment':: caused by:: can't create user databases on a --configsvr instance at src\mongo\db\repl\replication_coordinator_impl.cpp 743

Also, when connected mongo shell to the 27018 server, and checked the replicaset status, then it showed the 27018 server as secondary. What am I doing wrong here?


Edit: Result from 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)
}

I'm guessing you started the first config server in a data directory that was previously used for another deployment. Start with an empty data directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM