我在google cloud中创建了一个集群,使用帮助部署mongodb:
helm install my-release
--set auth.rootPassword=password,auth.databases[0]="database",auth.usernames[0]="root",architecture=replicaset,auth.replicaSetKey="keykfjhewq",auth.enabled=true
bitnami/mongodb
一切就绪,但是当我执行到pod并执行rs.status()
时,我得到:
{
"ok" : 0,
"errmsg" : "command replSetGetStatus requires authentication",
"code" : 13,
"codeName" : "Unauthorized",
"$clusterTime" : {
"clusterTime" : Timestamp(1653254244, 1),
"signature" : {
"hash" : BinData(0,"EZ4IdSOklvKSvSmWVYU6Rr/VcaM="),
"keyId" : NumberLong("7100667090272518150")
}
},
"operationTime" : Timestamp(1653254244, 1)
}
我做错了什么?
此错误表示一切正常运行,但是为了访问副本集,您需要首先进行身份验证(您告诉它在--set
值和auth.enabled=true
中使用auth)。要验证身份,您需要告诉mongo使用管理员权限,并使用您设置的用户名和密码登录:
use admin
db.auth(username, password)
这将使您获得身份验证并允许使用shell。