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.
rs.inititate()
. Better question for dba site – Than