Rocketchat连接到安全的MongoDB

时间:2019-06-01 11:30:23

标签: mongodb authentication rocket.chat

我正在尝试确保mongodb添加具有特权的火箭聊天用户,这是查询结果:

rs01:PRIMARY> use admin
rs01:PRIMARY> show users
{
        "_id" : "admin.rocketchatuser",
        "user" : "rocketchatuser",
        "db" : "admin",
        "customData" : {

        },
        "roles" : [
                {
                        "role" : "readWrite",
                        "db" : "admin"
                },
                {
                        "role" : "readWrite",
                        "db" : "local"
                },
                {
                        "role" : "dbOwner",
                        "db" : "rocketchat"
                }
        ]
}

这是我的连接字符串:

MONGO_OPLOG_URL=mongodb://rocketchatuser:mypassword@localhost:27017/local?authSource=admin&replSet=rs01
MONGO_URL=mongodb://rocketchatuser:mypassword@localhost:27017/rocketchat?authSource=admin

这是mongodb日志:

Unauthorized: not authorized on rocketchat to execute command

但是仍然获得连接拒绝错误。

有什么主意吗?

1 个答案:

答案 0 :(得分:0)

最后,在重新遵循this guide中的说明并启用Rocket.Chat服务的日志记录后,我发现了问题,并看到它需要授予Rocketuser在管理数据库上具有clusterMonitor角色:

db.runCommand({ grantRolesToUser: "rocketchatuser" , roles: [{role: "clusterMonitor", db: "admin"}]})

在授予用户权限后,它已连接并开始成功运行。