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

部署独立的 MongoDB 实例

注意

对于此页面上提到的所有 Ops Manager,您都可以将其替换为 Cloud Manager

重要

  • 您可以使用 Kubernetes Operator 通过 Cloud Manager 和 Ops Manager 6.0.x 版或更高版本来部署 MongoDB 资源。

  • 可以使用 Atlas Operator 将 MongoDB 资源部署到 Atlas。

您可以部署一个独立 MongoDB 实例供 Ops Manager 管理。使用独立运行的实例进行测试和开发。不要将这些部署用于生产系统,因为它们缺乏复制和高可用性。对于所有生产部署,请使用副本集。要了解副本集,请参阅部署副本集

要使用某个对象部署独立版本,您必须:

注意

为避免在单集群Kubernetes部署中存储密钥,您可以将所有密钥迁移到密钥存储工具。多个Kubernetes集群上的部署不支持将密钥存储在密钥存储工具中,例如 HashiCorp Vault

1

如果您尚未执行,请运行以下命令,执行所创建命名空间的所有 kubectl 命令。

注意

MongoDB Ops Manager如果要在多 Kubernetes 集群 部署中部署MongoDB 资源:

  • context 设置为操作符集群的名称,例如:kubectl config set context "$MDB_CENTRAL_CLUSTER_FULL_NAME"

  • --namespace设置为您用于多 Kubernetes 集群 MongoDB 部署的相同范围,例如: kubectl config --namespace "mongodb"

kubectl config set-context $(kubectl config current-context) --namespace=<metadata.namespace>
2

这是一个 YAML 文件,您可以根据所需配置进行修改。 更改突出显示的设置,以匹配所需的独立运行配置。

---
apiVersion: mongodb.com/v1
kind: MongoDB
metadata:
name: <my-standalone>
spec:
version: "8.0.0"
opsManager:
configMapRef:
name: <configMap.metadata.name>
# Must match metadata.name in ConfigMap file
credentials: <mycredentials>
type: Standalone
persistent: true
...
3
4
类型
说明
例子

字符串

此 Kubernetes 独立对象的标签。

资源名称必须少于或等于 44 个字符。

要学习;了解详情,请参阅 和有关metadata.name 名称的 Kubernetes文档。

my-project

字符串

在此单机上安装的 MongoDB 版本。

Community 版的格式应为 X.Y.Z,Enterprise 版的格式应为 X.Y.Z-ent

重要提示:确保选择兼容的MongoDB Server版本。 兼容版本因MongoDB 数据库资源使用的基础映像而异。

要了解有关 MongoDB 版本控制的更多信息,请参阅 MongoDB 手册中的 MongoDB 版本控制

For best results, use the latest available enterprise MongoDB version that is compatible with your Ops Manager version.

字符串

Name of the ConfigMap with the Ops Manager connection configuration. The spec.cloudManager.configMapRef.name setting is an alias for this setting and can be used in its place.

此值必须与待创建的资源位于同一命名空间。

<myproject>

字符串

创建的 Secret 名称,其将作为 Ops Manager API 身份验证凭证,以便 Kubernetes Operator 与 Ops Manager 进行通信。

持有凭证的 Ops Manager Kubernetes Secret 对象必须与您要创建的资源位于同一个命名空间中。

重要提示:Kubernetes Operator 会跟踪该 Secret 的任何更改并协调 MongoDB 资源的状态。

<mycredentials>

字符串

要创建的 MongoDB 资源的类型。

Standalone

字符串

可选。

如果该值为 true,则 spec.podSpec.persistence.single 设置为默认值 16Gi

要更改持久卷声明配置,请配置以下集合以满足部署要求:

WARNING: Grant your containers permission to write to your Persistent Volume. The Kubernetes Operator sets fsGroup = 2000, runAsUser = 2000, and runAsNonRoot = true in securityContext. Kubernetes Operator sets fsgroup equal to runAsUser to make the volume writable for a user that runs the main process in the container. To learn more, see Configure a Security Context for a Pod or Container and the related discussion in the Kubernetes documentation. If redeploying the resource doesn't fix issues with your Persistent Volume, contact MongoDB Support.

If you do not use Persistent Volumes, the Disk Usage and Disk IOPS charts cannot be displayed in either the Processes tab on the Deployment page or in the Metrics page when reviewing the data for this deployment.

true

6
7

调用以下 Kubernetes 命令,创建独立运行部署:

kubectl apply -f <standalone-conf>.yaml
8

要检查 MongoDB 资源的状态,请使用以下命令:

kubectl get mdb <resource-name> -o yaml -w

设置 -w (观看) 标志后,当配置更改时,输出将立即刷新,直到状态阶段达到 Running 状态。要了解有关资源部署状态的详情,请参阅 Kubernetes Operator 故障排除

要排查分片集群,请参阅:

给本页内容打分

在此页面上