Database status?
-
@humanmadeaccount said:
not authorized on testdatabase to execute command { serverStatus: 1 }
I do not know Mongo much--if at all. Say, does it needs users/password to access a DB? Maybe the user you are using do not have enough permissions? Did you created a DB for NodeBB, or are reusing one (
testdatabase
)?Wish I could help more, but perhaps what I have written give you enough to poke around.
-
This is probably something to do with mongo's weird authorisation system.
When you create a user you create that user against a database, but that isn't necessarily the database the user with be authorised to use. That is the database they're authorised against.
Example:
Create Tom on database Admin with permission to the database Foo
Create Adam on database Foo with permission to the databases Foo and Bar
Tom can only login against Admin, then change to use Foo
Adam can only login against Foo, but then he could use Foo or change to Bar.I don't know what your specific issue is, because I can't see your user setup or what credentials nodebb is using.
-
Have you got it to work yet?
I tried giving dbOwner permission to nodebb user but still get that error.
db.getUser("nodebb") { "_id" : "nodebb.nodebb", "user" : "nodebb", "db" : "nodebb", "roles" : [ { "role" : "dbOwner", "db" : "nodebb" } ] }
-
@humanmadeaccount @lullerhaus . Sorry me English is bad..
I've some problem to. I use mongodb v.3.2.1But I remove or comment back my mongo conf
#security:
#authorization: enabledsudo service mongod restart
and boom.. i can see my database status at control panel.
I use this setup for fist install nodebb:
mongo --shell
use admin;
db.createUser({ user: "mongobos", pwd: "password", roles: ["userAdminAnyDatabase"] });
use nodebb;
db.createUser({ user: "userxxx", pwd: "password", roles: ["readWrite"] });
exit;Hope this help. I'm just newbie.
-
The action "serverStatus" requires the role "clusterMonitor" on the admin db, see https://docs.mongodb.org/manual/reference/built-in-roles/
Proper fix for this error without giving up security (tested on MongoDB 3.2.1):
use <NodeBB-DB> db.grantRolesToUser("<NodeBB-User>",[{ role: "clusterMonitor", db: "admin" }]);
Validate by
> db.getUser("<NodeBB-User>") { "_id" : "<NodeBB-DB>.<NodeBB-User>", "user" : "<NodeBB-User>", "db" : "<NodeBB-DB>", "roles" : [ { "role" : "readWrite", "db" : "<NodeBB-DB>" }, { "role" : "clusterMonitor", "db" : "admin" } ] }
-
@BlackBerry-Alamsyah said in Database status?:
@humanmadeaccount @lullerhaus . Sorry me English is bad..
I've some problem to. I use mongodb v.3.2.1But I remove or comment back my mongo conf
#security:
#authorization: enabledI had the same problem and found this solution on searching. Though it worked, what are the security implications of this ? Is there a better way to make database status work ? If it helps, i had installed nodebb as per the instructions in thier official docs -
https://docs.nodebb.org/en/latest/installing/os/ubuntu.html
https://docs.nodebb.org/en/latest/configuring/databases/mongo.html -
@connectkushal According to the docs, it turns off Role-based authorization, meaning that anyone who successfully logs into the database can do anything.
You should not do that, and instead assign the correct Roles as @twig suggested.
-
Guys,
Sorry for bring back from the tomb a mostly dead topic... but I am really struggling with this.
I had the same issue @humanmadeaccount had, I fix it performing @twig recommendation.
But now a new thing appears:
Internal Error.
Oops! Looks like something went wrong!
/api/admin/advanced/database
not authorize on nodebb to execute command { collStats: "system.users" }And its weird because according to https://docs.mongodb.org/manual/reference/built-in-roles if I give an user in ANY db the privilege clusterMonitor for db: admin I should be able to read the system.users from admin via collStats.
Am I missing something here?
Your help and recommendation its greatly appreciated.
Mongo DB 3.4.6
NodeBB v1.4.6.Note: Try updating it to 1.5.X but for some reason that broke down the new post and new replies ability.
-
This is my actual users set up.
> show users; { "_id" : "admin.super", "user" : "super", "db" : "admin", "roles" : [ { "role" : "root", "db" : "admin" } ] } { "_id" : "admin.nodebb", "user" : "nodebb", "db" : "admin", "roles" : [ { "role" : "clusterMonitor", "db" : "admin" } ] } > use nodebb switched to db nodebb > show users; { "_id" : "nodebb.nodebb", "user" : "nodebb", "db" : "nodebb", "roles" : [ { "role" : "clusterMonitor", "db" : "admin" }, { "role" : "readWrite", "db" : "nodebb" } ] }