patternMajor
node is not in primary or recovering state
Viewed 0 times
primaryrecoveringnodestatenot
Problem
My config file is:
So, I'm successfully connecting via
Then connecting to
And getting an error:
To avoid this error, I'm using command
But what does this error mean? Thanks.
systemLog:
destination: file
logAppend: true
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
journal:
enabled: true
replication:
replSetName: "rs0"
net:
bindIp: 127.0.0.1
port: 27017
security:
authorization: enabledSo, I'm successfully connecting via
mongod process:Then connecting to
mongo and trying to open databases and collections:And getting an error:
2018-07-07T15:40:25.092+0300 E QUERY [thread1] Error: error: {
"operationTime" : Timestamp(0, 0),
"ok" : 0,
"errmsg" : "node is not in primary or recovering state",
"code" : 13436,
"codeName" : "NotMasterOrSecondary",
"$clusterTime" : {
"clusterTime" : Timestamp(0, 0),
"signature" : {
"hash" : BinData(0,"FshG5mLBvAQUizPHXGfCITV4ZKA="),
"keyId" : NumberLong("6573732769795407873")
}
}
}To avoid this error, I'm using command
rs.initiate() like:But what does this error mean? Thanks.
Solution
You've configured this node as a replica set member:
On startup a new MongoDB server does not have a replica set configuration yet. The server will be in an
unknown replica set member state
until you either add this member to an existing replica set configuration or
use
You can confirm the current state using
configuration will report something similar to the following in MongoDB 4.0
(the exact output may vary by server version):
Once added to a replica set, you can use
replication:
replSetName: "rs0"On startup a new MongoDB server does not have a replica set configuration yet. The server will be in an
unknown replica set member state
until you either add this member to an existing replica set configuration or
use
rs.initiate() to establish it as the first member of a new replica set.You can confirm the current state using
rs.status(). A server without anyconfiguration will report something similar to the following in MongoDB 4.0
(the exact output may vary by server version):
> rs.status()
{
"operationTime" : Timestamp(0, 0),
"ok" : 0,
"errmsg" : "no replset config has been received",
"code" : 94,
"codeName" : "NotYetInitialized",
"$clusterTime" : {
"clusterTime" : Timestamp(0, 0),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}Once added to a replica set, you can use
rs.status() and rs.conf() to check the current replica set status and configuration respectively.Code Snippets
replication:
replSetName: "rs0"> rs.status()
{
"operationTime" : Timestamp(0, 0),
"ok" : 0,
"errmsg" : "no replset config has been received",
"code" : 94,
"codeName" : "NotYetInitialized",
"$clusterTime" : {
"clusterTime" : Timestamp(0, 0),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}Context
StackExchange Database Administrators Q#211605, answer score: 22
Revisions (0)
No revisions yet.