MongoDB - grantRolesToUser 回滚了吗?
MongoDB - grantRolesToUser is rolled back?
Replicaset - Mongo 版本 3.2.4,我使用 bash 脚本在某些情况下更新 mongo 权限,例如:
mongo <<EOF
db["grantRolesToUser"]("someone", ["readWriteAnyDatabase"]);
print(JSON.stringify(db.getUsers()));
EOF
基本上,将 readWriteAnyDatabase 角色添加到 "someone"。
有效,打印显示具有新角色的用户。
然而,2-3秒后。它不见了!!
对可能导致此问题的原因有任何想法吗?
此问题与 MMS/OpsManager 跨副本集的用户自动同步有关。
来自 OpsManager 手册:
If you want Ops Manager to ensure that all deployments in a group have the same database users, use only the Ops Manager interface to manage users.
If you want certain deployments in a group to possess users not set at the group level, you can add them through direct connection to the MongoDB instances.
因此您可以在 OpsManager 中或从 mongo shell 本身控制用户,但不能同时控制两者。
Replicaset - Mongo 版本 3.2.4,我使用 bash 脚本在某些情况下更新 mongo 权限,例如:
mongo <<EOF
db["grantRolesToUser"]("someone", ["readWriteAnyDatabase"]);
print(JSON.stringify(db.getUsers()));
EOF
基本上,将 readWriteAnyDatabase 角色添加到 "someone"。
有效,打印显示具有新角色的用户。 然而,2-3秒后。它不见了!!
对可能导致此问题的原因有任何想法吗?
此问题与 MMS/OpsManager 跨副本集的用户自动同步有关。
来自 OpsManager 手册:
If you want Ops Manager to ensure that all deployments in a group have the same database users, use only the Ops Manager interface to manage users.
If you want certain deployments in a group to possess users not set at the group level, you can add them through direct connection to the MongoDB instances.
因此您可以在 OpsManager 中或从 mongo shell 本身控制用户,但不能同时控制两者。