Guigzer
Guigzer

Reputation: 11

MongoDB Activating Authentication sets replica to OTHER

I'm using MongoDB and SolR together since the beginning of the year now. Allthough this question will be about a specific issue I met with MongoDB since the last few days, that I can't find a fix for.

It is set as follow : 2 replica sets clustered. (I don't know if that's self explanatory but I'll let the experts judge on if there's a better way to say it haha)

See, for some obvious best practice reasons, I decided to enable the authentication on my MongoDB instance. I followed the steps described in the MongoDB documentation as to how to create a user, with specific rights and everything.

rs0:PRIMARY> db.createUser({ user: "louis", pwd: "WhatIsGod", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})
Successfully added user: {
    "user" : "louis",
    "roles" : [
        "userAdminAnyDatabase",
        "dbAdminAnyDatabase",
        "readWriteAnyDatabase"
    ]
}

So far, nothing going wrong you might tell me. Well so did I think ! After successfully creating the user, I stopped my MongoDB service in order to modify the mongo.conf file and replace disabled by enabled then restarted the service.

As soon as the service restarts, I saw that my replica sets were in the OTHER state, and there's literally nothing I can do in the Mongo Shell without an error popping, not a single command (few examples below)

2019-10-07T16:34:16.312+0200 E QUERY    [thread1] Error: not master and slaveOk=false :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
2019-10-07T16:22:15.583+0200 E QUERY    [thread1] Error: Could not retrieve replica set config: {
    "ok" : 0,
    "errmsg" : "not authorized on admin to execute command { replSetGetConfig: 1.0 }",
    "code" : 13,
    "codeName" : "Unauthorized"

This basically stays the same, until I revert the changes in the mongo.conf file.

So after searching, I'm here to ask if this happened to anybody before ?

If not, could I get any suggestion as to what I could check about this issue ?

Upvotes: 0

Views: 165

Answers (1)

Guigzer
Guigzer

Reputation: 11

I actually found out what was going on.

Since working with replica sets, the Authentication needs a file for both the replicas to acknowledge the users and their rights (as far as I understood)

You can find details here : MongoDB replica set with simple password authentication

(cc @datdinhquoc for the answer 3 years ago that I just found)

Upvotes: 0

Related Questions