Database status?



  • I'm using mongo 3.0.6

    There's always error on my ACP database status.

    Internal error.
    Oops! Looks like something went wrong!
    /api/admin/advanced/database
    not authorized on testdatabase to execute command { serverStatus: 1 }


  • @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.1

    But I remove or comment back my mongo conf
    #security:
    #authorization: enabled

    sudo service mongod restart

    and boom.. i can see my database status at control panel. :smile:

    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.1

    But I remove or comment back my mongo conf
    #security:
    #authorization: enabled

    I 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


  • Community Rep

    @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.



  • oops.. should have read the whole thing. :expressionless: thanx for pointing it out @yariplus :)


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.