简体   繁体   English

如何连接到作为副本分片集群成员的mongodb身份验证实例?

[英]How to connect to mongodb authentication instance which is one member of replica shard cluster?

Why the account create from mongos, can not be use at replica instance? 为什么从mongos创建帐户,不能在副本实例上使用?
the log : 日志:

[conn165] SCRAM-SHA-1 authentication failed for wuyg on admin from client 127.0.0.1 ; UserNotFound: Could not find user wuyg@admin  

the user wuyg has these roles: 用户wuyg具有以下角色:

"roles" : [ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "dbOwner", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" } ]  

and I can use the wuyg account when I connect from mongos. 从mongos连接时,我可以使用wuyg帐户。

My mongodb cluster has 3 config instance, and 1 shard which is a 3 members replica cluster. 我的mongodb集群有3个配置实例和1个分片,这是3个成员的副本集群。 version:3.2.8 版本:3.2.8

thanks. 谢谢。

In mongoDB users are kept in admin.system.users collections. 在mongoDB中,用户保留在admin.system.users集合中。 You can list users using commands: 您可以使用以下命令列出用户:

use admin
db.system.users.find()

Each ReplicaSet instance has it's own admin database with separate system.users collection. 每个ReplicaSet实例都有其自己的管理数据库,带有单独的system.users集合。

Mongos (shardedCluster) use admin database which is kept on config servers. Mongos (shardedCluster)使用管理数据库,该数据库保存在配置服务器上。

If you want to connect to mongos and replicaSet using the same user you have to create this user on replicaSet s and mongos separately 如果要使用同一用户连接到mongos和copySet,则必须分别在copySetmongos上创建此用户。

BTW It's better to use simple replicaSet configuration if you have only one shard. 顺便说一句,如果只有一个分片,最好使用简单的copysetSet配置。 You can convert it to shardedCluster when you need additional capacity https://docs.mongodb.com/manual/tutorial/convert-replica-set-to-replicated-shard-cluster/ . 当您需要更多容量https://docs.mongodb.com/manual/tutorial/convert-replica-set-to-replicated-shard-cluster/时,可以将其转换为shardedCluster。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM