【问题标题】:Meteor oplog for Mongo 2.6Mongo 2.6 的流星 oplog
【发布时间】:2014-09-06 02:08:15
【问题描述】:

当我从https://github.com/meteor/meteor/wiki/Oplog-Observe-Driver 运行线路时,我得到了

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

因为它是为 Mongo 2.4 创建的。有人设法让它在 Mongo 2.6.1 上运行吗? 如果没有,我需要降级到 2.4 吗?如果是,我怎样才能轻松做到?

【问题讨论】:

    标签: mongodb meteor


    【解决方案1】:

    以这种方式创建您的用户,确保您已通过身份验证并在管理员 (docs) 数据库中:

    1. 创建用户oplogger (docs)

      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 尽管它仍然非常有用。

    【讨论】:

    • { "ok" : 0, "errmsg" : "不能授予不存在的角色 find@local", "code" : 31 }
    • 我让它看起来工作了,但是当我添加 MONGO_OPLOG_URL 时,应用程序无法启动
    • 从 MongoDB 3.* 需要将 roles:[{role:'find'}...] 更改为 roles:[{role:'read'}],完整字符串:db.runCommand({ createRole: "oplogger", privileges: [{ resource: { db: 'local', collection: 'system.replset'}, actions: ['find']}], roles: [{role: 'read', db: 'local'}] })
    猜你喜欢
    • 1970-01-01
    • 2013-09-03
    • 1970-01-01
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多