'MongoDB - ReplicaSet - Failed to refresh key cache
I am deploying my first replica set on a Windows 10 machine with MongoDB 5.0. For the purpose of the tutorial, I want all the servers running on my machine, on different ports.
A)
I created my first server with :
mongod --replSet rs0 --port 27018 --dbpath C:\data\R0S1
I opened another command line prompt and I connected to it with mongo --port 27018
.
I iniated the set with the command rs.initiate()
.
B)
I created my second and third server with :
mongod --replSet rs0 --port 27019 --dbpath C:\data\R0S2
mongod --replSet rs0 --port 27020 --dbpath C:\data\R0S3
(I ran each of these commands in new command line prompts)
C)
I added the second and third server to the set by connecting to the primary server (on 27018
with mongo --port 27018
) with :
rs.add("localhost:27019")
rs.add("localhost:27020")
At this stage, everything has worked as expected.
Running rs.conf()
gives me :
{
"_id" : "rs0",
"version" : 5,
"term" : 1,
"members" : [
{
"_id" : 0,
"host" : "localhost:27018",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"secondaryDelaySecs" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "localhost:27019",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"secondaryDelaySecs" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "localhost:27020",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"secondaryDelaySecs" : NumberLong(0),
"votes" : 1
}
],
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : -1,
"catchUpTakeoverDelayMillis" : 30000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("61cc297329dca2f0673c2cff")
}
}
D) In a new command line prompt, I create my fourth server (with the idea of making it an arbiter) with :
mongod --replSet rs0 --port 30000 --dbpath C:\data\arb
Here I have a problem. The log file for this new server contains the following error :
{"t":{"$date":"2021-12-29T10:50:51.767+01:00"},"s":"I", "c":"-",
"id":4939300, "ctx":"monitoring-keys-for-HMAC","msg":"Failed to refresh key cache","attr":{"error":"NotYetInitialized: Cannot use non-local read concern until replica set is finished initializing.","nextWakeupMillis":19200}}
When connecting to the primary and trying to do "rs.addArb(localhost:30000)", the command blocks and does nothing, because of the above error on server on port 30000 I believe.
Do you have any ideas on what's going on and how I could solve my issue ?
---- edit 1 ----
below is my mongod.cfg file :
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: C:\Program Files\MongoDB\Server\5.0\data
journal:
enabled: true
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\Server\5.0\log\mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|