2014-09-06 244 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