对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

从 Kubernetes 内部连接到 MongoDB 数据库资源

以下过程描述如何从 Kubernetes 集群内部连接到 Kubernetes 部署的 MongoDB 资源。

You must be able to connect to the host and port where you deployed your Kubernetes resource. To learn more about connecting to your deployment, see Connect to a MongoDB Process.

检索并运行部署的连接命令。您可以从Ops Manager或Cloud Manager应用程序检索连接命令,具体取决于集群的托管位置。您还可以从Kubernetes密钥中检索连接命令,该密钥是在您使用SCRAM身份验证或 X509 添加MongoDB用户时Kubernetes Operator 自动创建的。

连接 MongoDB 数据库资源的过程视您想要检索连接字符串的方式而有所不同:

在 Ops Manager 或 Cloud Manager 应用程序中执行以下步骤,具体取决于托管集群的位置:

1

单击左侧导航栏中的 Deployment。

2
3
4
5

例子

要连接到名为 shardedcluster 的分片集群资源,可以使用以下连接字符串:

mongosh --host shardedcluster-mongos-0.shardedcluster-svc.mongodb.svc.cluster.local \
--port 27017

从 Kubernetes 内部连接到资源时,您连接的主机名具有以下形式:

<k8s-pod-name>.<k8s-internal-service-name>.<k8s-namespace>.<cluster-name>
给本页内容打分