使用 helm 部署 mongodb:“命令 replSetGetStatus 需要身份验证”?

问题描述 投票:0回答:1

我在谷歌云中创建了一个集群,使用帮助部署了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)
}

我做错了什么?

mongodb kubernetes kubernetes-helm replicaset
1个回答
3
投票

此错误表明一切运行正常,但是为了访问副本集,您需要首先进行身份验证(您告诉它在

--set
值中使用
auth.enabled=true
进行身份验证)。要进行身份验证,您需要告诉 mongo 使用管理员权限并使用您设置的用户名和密码登录:

use admin
db.auth(username, password)

这将使您获得身份验证并允许使用 shell。

© www.soinside.com 2019 - 2024. All rights reserved.