为什么帐户是从mongos创建的,不能在副本实例中使用?
日志:
[conn165] SCRAM-SHA-1 authentication failed for wuyg on admin from client 127.0.0.1 ; UserNotFound: Could not find user wuyg@admin
用户wuyg具有以下角色:
"roles" : [ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "dbOwner", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" } ]
当我从mongos连接时,我可以使用wuyg帐户。
我的mongodb群集有3个配置实例,1个shard是3个成员副本群集。 版本:3.2.8
感谢。
答案 0 :(得分:2)
在mongoDB中,用户保存在admin.system.users集合中。 您可以使用命令列出用户:
use admin
db.system.users.find()
每个 ReplicaSet 实例都拥有自己的管理数据库,其中包含单独的 system.users 集合。
Mongos (shardedCluster)使用保存在配置服务器上的 admin 数据库。
如果要使用同一用户连接到mongos和replicaSet,则必须分别在 replicaSet 和 mongos 上创建此用户
如果你只有一个分片,那么使用简单的replicaSet配置会更好。当您需要额外容量https://docs.mongodb.com/manual/tutorial/convert-replica-set-to-replicated-shard-cluster/时,可以将其转换为shardedCluster。