2014-09-06 102 views
2

当我从https://github.com/meteor/meteor/wiki/Oplog-Observe-Driver运行线,我得到流星OPLOG为蒙戈2.6

WARNING: The 'addUser' shell helper is DEPRECATED. Please use 'createUser' instead 
2014-09-05T20:51:35.483-0400 Error: couldn't add user: "otherDBRoles" is not a valid argument to createUser at src/mongo/shell/db.js:1004 

因为它是为蒙戈2.4创建的。有人设法使其在Mongo 2.6.1上工作? 如果不是,我是否需要降级到2.4?如果是的话,我怎么能轻松做到这一点?

回答

4

创建您的用户这样,请确保您进行身份验证,并在管理(docs)数据库:

  1. 创建用户oploggerdocs

    db.createUser({ user: "<name>", 
        pwd: "<cleartext password>", 
        roles: [] 
    }); 
    
  2. 创建oplogger作用(docs

    db.runCommand({ createRole: "oplogger", privileges: [ { resource: { db: 'local', collection: 'system.replset'}, actions: ['find']}, ], roles: [{role: 'find', db: 'local'}] }) 
    
  3. 角色授予用户(docs

    db.runCommand({ grantRolesToUser: 'oplogger', roles: ['oplogger']}) 
    
  4. 使用MONGO_OPLOG_URL作为环境变量。不要忘记authSource=admin参数或它不会工作。 (docs

    MONGO_OPLOG_URL=mongodb://oplogger:<password>@server_ip/local?authSource=admin 
    

也有2.6的一些问题还未被解决:https://github.com/meteor/meteor/issues/2121 & https://github.com/meteor/meteor/issues/2278但它仍然是非常有用的。

+2

{ \t “OK”:0, \t “ERRMSG”: “不能授予不存在的角色找到@地方”, \t “代码”:31 } – 2014-09-06 10:51:08

+0

我做了它的工作似乎,但是当我加' MONGO_OPLOG_URL',应用程序不会启动 – 2014-09-06 13:34:41

+1

__来自MongoDB 3. * __你需要改变角色:[{role:'find'} ...] full string:'db.runCommand({createRole:“oplogger”,privileges:[{resource:{db:'local',collection:'system.replset'},actions:['find']}],roles:[ {role:'read',db:'local'}]})' – 2016-07-02 09:02:02