Collection [local.oplog.rs] not found issue when restarting mongod for setting up replica set
Asked Answered
A

1

9

I have followed the official documentation for converting the standalone mongodb instance (local ubuntu machine) to replica set. The part where we restart mongod with --replset flag seems to invite an error.

Command used:

sudo systemctl stop mongod

sudo mongod --port 27017 --dbpath /var/lib/mongodb --replSet rs1 --bind_ip localhost

{"t":{"$date":"2023-11-24T17:58:28.002+05:30"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found."},"stats":{},"cmd":{"aggregate":"oplog.rs","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"local"}}}

The cmd goes into a loop printing this message again and again, till I force close the program.

I have tried reinstalling mongodb to see if it is a random issue. But it prevails nevertheless.

Tried multiple variations of the mongod restart command. Used different shutdown procedures.

Annettannetta answered 24/11, 2023 at 12:37 Comment(2)
That error is probably expected until you rs.inititate(). Better question for dba siteThan
I forgot to mention that the whole process goes into a loop and we need to force close it by typing Ctrl+C. Due to this issue, Mongod will not spin up. So, I cannot enter the shell and execute the initiate() function. On top of that, Mongod will remain shut down even if I try to start the service. I then reinstall MongoDB to obtain a working service.Annettannetta
M
2

I had the same problem when trying to connect with Compass.

But I was able to run mongosh on the server's shell, and then run rs.initiate() from there.

Once rs.initiate() was finished, I am able to connect with Compass to all of the nodes in the replication set and verify replication is working.

Margetts answered 7/2, 2024 at 16:57 Comment(1)
Also the local.oplog.rs stopped appearing in the log.Margetts

© 2022 - 2025 — McMap. All rights reserved.