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

部署 Ops Manager 资源

您可以使用 Kubernetes 操作符将 Ops Manager 作为资源部署在 Kubernetes container中。

以下注意事项适用:

配置 Ops Manager 部署时,必须选择是通过HTTPS还是HTTP运行连接。

以下HTTPS过程:

  • 建立与 Ops Manager 应用程序之间的TLS加密连接。

  • 在应用程序数据库的副本集成员之间建立TLS加密连接。

  • TLS 加密需要有效证书。

以下HTTP过程:

  • 不对与 Ops Manager 应用程序之间的连接进行加密。

  • 不加密应用程序数据库副本集成员之间的连接。

  • 设置要求较少。

When running over HTTPS, Ops Manager runs on port 8443 by default.

根据您是否要使用TLS加密 Ops Manager 和应用程序数据库连接,选择相应的标签页。

  • Create one TLS certificate for the Application Database's replica set.

    TLS证书需要以下属性:

    DNS 名称

    Ensure that you add SANs or Subject Names for each Pod that hosts a member of the Application Database replica set. The SAN for each pod must use the following format:

    <opsmgr-metadata.name>-db-<index>.<opsmgr-metadata.name>-db-svc.<namespace>.svc.cluster.local

    密钥用法

    确保 TLS 证书包含以下密钥用法 (5280):

    • "服务器 auth"

    • "client auth"

重要

Kubernetes Operator 使用 kubernetes.io/tls secrets 来存储Ops Manager和MongoDB资源的 TLS 证书和私钥。从Kubernetes Operator 版本 1.17.0 开始, Kubernetes Operator 不支持存储为不透明密钥的连接 PEM 文件。

在部署MongoDB Ops Manager资源之前,请确保对MongoDB Ops Manager Ops Manager资源进行规划:

此过程适用于在单个MongoDB Ops Manager Kubernetes集群中部署 实例,以及在多集群部署中的MongoDB Ops Manager Operator 集群上部署 。如果要在多个MongoDB Ops Manager KubernetesKubernetesMongoDB Ops Manager 集群上部署 MongoDB Ops 的多个实例,请参阅在多个Kubernetes 集群 部署 资源。

请按照以下步骤部署 Ops Manager 资源以通过HTTPS运行,并使用TLS保护应用程序数据库。

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

如果您使用 HashiCorp Vault 作为您的 Secret 存储工具,则可以创建 Vault Secret

要了解有关 Secret 存储的选项,请参阅配置 Secret 存储。

  1. 获得 TLS 证书和私钥后,运行以下命令以创建 MongoDB Ops Manager密钥 存储 的 TLS 证书:

    kubectl create secret tls <prefix>-<metadata.name>-cert \
    --cert=<om-tls-cert> \
    --key=<om-tls-key>
  2. 运行以下命令以创建新 密钥 存储应用程序数据库的 TLS 证书:

    kubectl create secret tls <prefix>-<metadata.name>-db-cert \
    --cert=<appdb-tls-cert> \
    --key=<appdb-tls-key>
3

If your Ops Manager TLS certificate is signed by a custom CA, the CA certificate must also contain additional certificates that allow Ops Manager Backup Daemon to download MongoDB binaries from the Internet. To create the TLS certificate(s), create a ConfigMap to hold the CA certificate:

重要

Kubernetes 操作符要求 Ops Manager 证书在 ConfigMap 中命名为mms-ca.crt

  1. Obtain the entire TLS certificate chain for Ops Manager from downloads.mongodb.com. The following openssl command outputs the certificate in the chain to your current working directory, in .crt format:

    openssl s_client -showcerts -verify 2 \
    -connect downloads.mongodb.com:443 -servername downloads.mongodb.com < /dev/null \
    | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; out="cert"a".crt"; print >out}'
  2. Concatenate your CA's certificate file for Ops Manager with the entire TLS certificate chain from downloads.mongodb.com that you obtained in the previous step:

    cat <custom_ca_cert.pem> cert2.crt cert3.crt cert4.crt >> mms-ca.crt

    注意

    • 将占位符 <custom_ca_cert.pem> 替换为您的自定义 CA 证书 PEM文件。

    • 请勿包含 cert1.crt文件,因为不应包含来自MongoDB的服务器证书。

  3. 为MongoDB Ops Manager创建 ConfigMap:

    kubectl create configmap om-http-cert-ca --from-file="mms-ca.crt"
4

更改设置以匹配您的 Ops Manager 和应用程序数据库配置。

1---
2apiVersion: mongodb.com/v1
3kind: MongoDBOpsManager
4metadata:
5 name: <myopsmanager>
6spec:
7 replicas: 1
8 version: <opsmanagerversion>
9 adminCredentials: <adminusercredentials> # Should match metadata.name
10 # in the Kubernetes secret
11 # for the admin user
12
13 externalConnectivity:
14 type: LoadBalancer
15 security:
16 certsSecretPrefix: <prefix> # Required. Text to prefix
17 # the name of the secret that contains
18 # Ops Manager's TLS certificate.
19 tls:
20 ca: "om-http-cert-ca" # Optional. Name of the ConfigMap file
21 # containing the certificate authority that
22 # signs the certificates used by the Ops
23 # Manager custom resource.
24
25 applicationDatabase:
26 topology: SingleCluster
27 members: 3
28 version: "8.0.0-ubi8"
29 security:
30 certsSecretPrefix: <prefix> # Required. Text to prefix to the
31 # name of the secret that contains the Application
32 # Database's TLS certificate. Name the secret
33 # <prefix>-<metadata.name>-db-cert.
34 tls:
35 ca: "appdb-ca" # Optional, unless enabling TLS for |mms|.
36 # Name of the ConfigMap file
37 # containing the certicate authority that
38 # signs the certificates used by the
39 # application database.
40
41...
1---
2apiVersion: mongodb.com/v1
3kind: MongoDBOpsManager
4metadata:
5 name: <myopsmanager>
6spec:
7 replicas: 1
8 version: <opsmanagerversion>
9 adminCredentials: <adminusercredentials> # Should match metadata.name
10 # in the Kubernetes secret
11 # for the admin user
12
13 externalConnectivity:
14 type: LoadBalancer
15 security:
16 certsSecretPrefix: <prefix> # Required. Text to prefix
17 # the name of the secret that contains
18 # Ops Manager's TLS certificate.
19 tls:
20 ca: "om-http-cert-ca" # Optional. Name of the ConfigMap file
21 # containing the certificate authority that
22 # signs the certificates used by the Ops
23 # Manager custom resource.
24
25 applicationDatabase:
26 topology: MultiCluster
27 clusterSpecList:
28 - clusterName: cluster1.example.com
29 members: 4
30 - clusterName: cluster2.example.com
31 members: 3
32 - clusterName: cluster3.example.com
33 members: 2
34 version: "8.0.0-ubi8"
35 security:
36 certsSecretPrefix: <prefix> # Required. Text to prefix to the
37 # name of the secret that contains the Application
38 # Database's TLS certificate. Name the secret
39 # <prefix>-<metadata.name>-db-cert.
40 tls:
41 ca: "appdb-ca" # Optional, unless enabling TLS for |mms|.
42 # Name of the ConfigMap file
43 # containing the certicate authority that
44 # signs the certificates used by the
45 # application database.
46
47...
5
6
类型
说明
例子

字符串

Kubernetes MongoDB Ops Manager对象的名称。

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

metadata.name另请参阅有关名称的 和Kubernetes文档。

om

数字

要并行运行的 Ops Manager 实例的数量。

最小有效值为1 。 如果您在spec.topology设置中指定MultiCluster ,则此字段将被忽略。

1

字符串

要安装的 Ops Manager 版本。

格式应为 XYZ 。要查看可用的MongoDB Ops Manager版本,请查看容器注册表。

8.0.0

字符串

Name of the secret you created for the Ops Manager admin user. Configure the secret to use the same namespace as the Ops Manager resource.

om-admin-secret

spec
.security
.certsSecretPrefix

字符串

必需

包含 Ops Manager TLS证书的密钥名称前缀的文本。

om-prod

spec
.security
.tls
.ca

字符串

Name of the ConfigMap you created to verify your Ops Manager TLS certificates signed using a custom CA. This field is required if you signed your Ops Manager TLS certificates using a custom CA.

om-http-cert-ca

spec
.externalConnectivity
.type

字符串

在Kubernetes外部公开Ops Managerspec.externalConnectivity 的Kubernetes服务 ServiceType。如果不希望Kubernetes Operator 创建Kubernetes服务以将外部流量路由到Ops Manager应用程序,请排除 设置及其子设置。

LoadBalancer

spec
.applicationDatabase
.members

整型

Ops Manager Application Database副本集的成员数。

3

spec
.applicationDatabase
.version

字符串

必需

MongoDBOps Manager Application Database应运行的 版本。

X.Y.Z-ubi8对于 Enterprise 版,格式应为 X.Y.Z;对于 Community 版,格式应为 。请勿将-ubi8 标签后缀添加到社区版映像,因为Kubernetes Operator 会自动添加标签后缀。

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

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

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

spec
.applicationDatabase
.topology

字符串

可选

应用程序数据库的 Kubernetes 部署类型。 如果省略,则默认值为SingleCluster

如果您指定MultiCluster ,Kubernetes 操作符 将忽略您为spec.applicationDatabase.members字段设置的值(如果已指定)。相反,您必须指定clusterSpecList ,并在其中包含要部署应用程序数据库的每个选定 Kubernetes 成员集群的clusterName ,以及每个 Kubernetes 集群中members (MongoDB 节点)的数量。

您无法通过修改 CRD 中的clusterSpecListtopology设置将单集群MongoDB Ops Manager 实例转换为多 Kubernetes集群 部署实例。MongoDB

另请参阅资源规范的示例。

MultiCluster

spec
.applicationDatabase
.security
.certsSecretPrefix

字符串

必需

包含应用程序数据库的TLS证书的密钥名称前缀的文本。

appdb-prod

spec
.applicationDatabase
.security
.tls
.ca

字符串

Name of the ConfigMap you created to verify your application database TLS certificates signed using a custom CA. This field is required if you signed your application database TLS certificates using a custom CA.

ca

The Kubernetes Operator mounts the CA you add using the spec.applicationDatabase.security.tls.ca setting to both the Ops Manager and the Application Database Pods.

7

要配置备份,必须启用备份,然后:

类型
说明
例子

spec
.backup
.enabled

布尔

指示备份已启用的标志。 您必须指定spec.backup.enabled: true才能配置头部数据库、oplog 存储和快照存储的设置。

true

spec
.backup
.headDB

集合

头部数据库配置设置的集合。有关集合中各个设置的说明,请参阅spec.backup.headDB

spec
.backup
.opLogStores
.name

字符串

oplog 存储的名称。

oplog1

spec
.backup
.s3OpLogStores
.name

字符串

S3 oplog存储的名称。

my-s3-oplog-store

spec
.backup
.opLogStores
.mongodbResourceRef
.name

字符串

oplog 存储的MongoDB资源或MongoDBMultiCluster资源的名称。 资源的metadata.name必须与此名称匹配。

my-oplog-db

spec
.backup
.s3OpLogStores
.mongodbResourceRef
.name

字符串

S3 oplog存储的 MongoDB资源或 MongoDBMultiCluster资源的名称。资源的 metadata.name 必须与此名称匹配。

my-s3-oplog-db

您还必须配置 S3 快照存储或块存储。

如果同时部署S3 快照存储和块存储, Ops Manager会随机选择一个用于备份。

要配置快照存储,请配置以下设置:

类型
说明
例子

spec
.backup
.s3Stores
.name

字符串

S3快照存储的名称。

s3store1

spec
.backup
.s3Stores
.s3SecretRef
.name

字符串

包含 accessKeysecretKey 字段的密钥名称。备份守护程序服务使用这些字段的值作为凭证来访问权限S3 S3 兼容存储桶。

my-s3-credentials

spec
.backup
.s3Stores
.s3BucketEndpoint

字符串

存储数据库备份快照的 S3S3 兼容存储桶的URL 。

s3.us-east-1.amazonaws.com

spec
.backup
.s3Stores
.s3BucketName

字符串

存储数据库备份快照的 S3 S3 兼容存储桶的名称。

my-bucket

要配置块存储,请配置以下设置:

类型
说明
例子

spec
.backup
.blockStores
.name

字符串

块存储的名称。

blockStore1

spec
.backup
.blockStores
.mongodbResourceRef
.name

字符串

您为块存储创建的MongoDB资源的名称。 您必须将此数据库资源部署在与 Ops Manager 资源相同的命名空间中。

my-mongodb-blockstore

8

将要应用部署的任何可选备份设置添加到对象规范文件中。示例,对于每种类型的备份存储和Ops Manager备份守护进程进程,您可以分配标签,将特定备份存储或备份守护进程进程与特定项目关联起来。使用spec.backup.[*].assignmentLabels OpsManager 资源的 元素。

9

将要应用部署的任何可选设置添加到对象规范文件中。

10
11

在 Ops Manager 资源定义的文件名上运行以下kubectl命令:

kubectl apply -f <opsmgr-resource>.yaml

注意

MongoDB Ops Manager如果要在多 Kubernetes集群 部署上部署MongoDB 资源,请运行:

kubectl apply \
--context "$MDB_CENTRAL_CLUSTER_FULL_NAME" \
--namespace "mongodb"
-f https://raw.githubusercontent.com/mongodb/mongodb-kubernetes/master/public/samples/ops-manager/ops-manager-external.yaml
12

要检查 Ops Manager 资源的状态,请调用以下命令:

kubectl get om -o yaml -w

部署资源时,该命令会在status字段下返回类似于以下内容的输出:

status:
applicationDatabase:
lastTransition: "2022-04-01T09:49:22Z"
message: AppDB Statefulset is not ready yet
phase: Pending
type: ""
version: ""
backup:
phase: ""
opsManager:
phase: ""

Kubernetes Operator 按以下顺序协调资源:

  1. 应用程序数据库。

  2. Ops Manager。

  3. 备份。

在前一个资源进入Running阶段之前,Kubernetes 操作符 不会协调某一资源。

在 Ops Manager 经理完成Pending阶段后,如果启用了备份,该命令会在status字段下返回类似于以下内容的输出:

status:
applicationDatabase:
lastTransition: "2022-04-01T09:50:20Z"
members: 3
phase: Running
type: ReplicaSet
version: "8.0.0-ubi8"
backup:
lastTransition: "2022-04-01T09:57:42Z"
message: The MongoDB object <namespace>/<oplogresourcename>
doesn't exist
phase: Pending
opsManager:
lastTransition: "2023-04-01T09:57:40Z"
phase: Running
replicas: 1
url: https://om-svc.cloudqa.svc.cluster.local:8443
version: "8.0.0"

在配置备份数据库之前,备份将保持Pending状态。

提示

status.opsManager.url字段说明资源的连接URL 。 使用此URL ,您可以从MongoDB Ops Manager Kubernetes集群内部访问 或 使用 ConfigMap 创建项目。

资源完成Pending阶段后,该命令会在status字段下返回类似于以下内容的输出:

status:
applicationDatabase:
lastTransition: "2022-12-06T18:23:22Z"
members: 3
phase: Running
type: ReplicaSet
version: "8.0.0-ubi8"
opsManager:
lastTransition: "2022-12-06T18:23:26Z"
message: The MongoDB object namespace/oplogdbname doesn't exist
phase: Pending
url: https://om-svc.dev.svc.cluster.local:8443
version: ""

在配置备份数据库之前,备份将保持Pending状态。

提示

status.opsManager.url字段说明资源的连接URL 。 使用此URL ,您可以从MongoDB Ops Manager Kubernetes集群内部访问 或 使用 ConfigMap 创建项目。

13

根据您在 Kubernetes 中将流量路由到 Ops Manager 应用程序的方式,您采取的步骤会有所不同。如果已配置 Kubernetes 操作符 来为您创建 Kubernetes 服务,或者您手动创建了 Kubernetes 服务,请使用以下方法之一访问 Ops Manager 应用程序:

  1. 查询您的云提供商以获取负载均衡器服务的FQDN 。 有关详细信息,请参阅云提供商的文档。

  2. 打开浏览器窗口,使用负载负载均衡器服务的MongoDB Ops Manager FQDN 和端口号导航到 应用程序。

    https://ops.example.com:8443
  3. 使用管理员用户凭证登录 Ops Manager。

  1. 将防火墙规则设置为允许从互联网访问权限运行Kubernetes集群的托管上的spec.externalConnectivity. port

  2. Open a browser window and navigate to the Ops Manager application using the FQDN and the spec.externalConnectivity.port.

    https://ops.example.com:30036
  3. 使用管理员用户凭证登录 Ops Manager。

要了解如何使用第三方服务访问 Ops Manager 应用程序,请参阅您的解决方案的文档。

14

要配置凭证,您必须创建MongoDB Ops Manager组织、生成编程API密钥并创建密钥。这些活动遵循“为Kubernetes Operator 创建凭证”页面上的先决条件和过程。

15

要创建项目,请遵循使用 ConfigMap 为每个MongoDB部署创建一个项目页面上的前提条件和步骤。

在项目 ConfigMap 中设置以下字段:

  • 将 ConfigMap 中的data.baseUrl设置为 Ops Manager 应用程序的URL 。 要查找此URL ,请调用以下命令:

    kubectl get om -o yaml -w

    该命令在status.opsManager.url字段中返回 Ops Manager 应用程序的 URL,与以下示例类似:

    status:
    applicationDatabase:
    lastTransition: "2022-12-06T18:23:22Z"
    members: 3
    phase: Running
    type: ReplicaSet
    version: "8.0.0-ubi8"
    opsManager:
    lastTransition: "2022-12-06T18:23:26Z"
    message: The MongoDB object namespace/oplogdbname doesn't exist
    phase: Pending
    url: https://om-svc.dev.svc.cluster.local:8443
    version: ""

    重要

    如果将 Ops Manager 与 Kubernetes Operator 一起部署,且 Ops Manager 将管理部署在 Kubernetes 集群外部的 MongoDB 数据库资源,则必须将 data.baseUrl 设置为与 Ops Manager 资源规范中的 spec.configuration.mms.centralUrl 设置相同的值。

    要学习;了解更多信息,请参阅管理外部MongoDB部署。

  • Set data.sslMMSCAConfigMap to the name of your ConfigMap containing the root CA certificate used to sign the Ops Manager host's certificate. The Kubernetes Operator requires that you name this Ops Manager resource's certificate mms-ca.crt in the ConfigMap.

16

默认, MongoDB Ops Manager启用备份。 为oplog和快照存储创建MongoDB 数据库资源以完成配置。

  1. 在与 Ops Manager 资源相同的命名空间中为 oplog 存储部署MongoDB database资源。

    注意

    创建此数据库作为三成员副本集。

    将资源的metadata.name与您在 Ops Manager 资源定义中指定的spec.backup.opLogStores.mongodbResourceRef.name进行匹配。

  2. 在与Ops Manager资源相同的命名空间中为 S3快照存储部署MongoDB 数据库资源。

    注意

    创建 S3快照存储作为副本集。

    将资源的metadata.name与您在 Ops Manager 资源定义中指定的spec.backup.s3Stores.mongodbResourceRef.name进行匹配。

17

要检查 Ops Manager 资源的状态,请调用以下命令:

kubectl get om -o yaml -w

当 Ops Manager 运行时,该命令会在status字段下返回类似于以下内容的输出:

status:
applicationDatabase:
lastTransition: "2022-12-06T17:46:15Z"
members: 3
phase: Running
type: ReplicaSet
version: "8.0.0-ubi8"
opsManager:
lastTransition: "2022-12-06T17:46:32Z"
phase: Running
replicas: 1
url: https://om-backup-svc.dev.svc.cluster.local:8443
version: "8.0.0"

有关资源部署状态的信息,请参阅排除 Kubernetes 操作符故障

请按照以下步骤部署MongoDB Ops Manager资源以通过HTTP运行:

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

更改设置以匹配您的MongoDB Ops Manager配置。

1---
2apiVersion: mongodb.com/v1
3kind: MongoDBOpsManager
4metadata:
5 name: <myopsmanager>
6spec:
7 replicas: 1
8 version: <opsmanagerversion>
9 adminCredentials: <adminusercredentials> # Should match metadata.name
10 # in the secret
11 # for the admin user
12 externalConnectivity:
13 type: LoadBalancer
14
15 applicationDatabase:
16 topology: SingleCluster
17 members: 3
18 version: <mongodbversion>
19...
1---
2apiVersion: mongodb.com/v1
3kind: MongoDBOpsManager
4metadata:
5 name: <myopsmanager>
6spec:
7 replicas: 1
8 version: <opsmanagerversion>
9 adminCredentials: <adminusercredentials> # Should match metadata.name
10 # in the Kubernetes secret
11 # for the admin user
12
13 externalConnectivity:
14 type: LoadBalancer
15
16 applicationDatabase:
17 topology: MultiCluster
18 clusterSpecList:
19 - clusterName: cluster1.example.com
20 members: 4
21 - clusterName: cluster2.example.com
22 members: 3
23 - clusterName: cluster3.example.com
24 members: 2
25 version: "8.0.0-ubi8"
26
27...
3
4
类型
说明
例子

字符串

Kubernetes MongoDB Ops Manager对象的名称。

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

要学习;了解更多信息,请参阅 和有关metadata.name 名称的 Kubernetes文档。

om

数字

要并行运行的 Ops Manager 实例的数量。

最小有效值为1 。 如果您在spec.topology设置中指定MultiCluster ,则此字段将被忽略。

1

字符串

要安装的 Ops Manager 版本。

格式应为XYZ 。 有关可用MongoDB Ops Manager 版本的列表,请查看 容器注册表。

8.0.0

字符串

您为 管理员用户 创建 的密钥的名称。MongoDB Ops Manager

配置密钥以使用相同的 命名空间 作为MongoDB Ops Manager 资源。

om-admin-secret

spec
.externalConnectivity
.type

字符串

可选

在Kubernetes之外公开MongoDB Ops Manager 的Kubernetes服务 ServiceType。

如果不希望 Kubernetes Operator 创建 Kubernetes 服务以将外部流量路由到 Ops Manager 应用程序,请排除spec. externalConnectivity设置及其子设置。

LoadBalancer

spec
.applicationDatabase
.members

整型

Ops Manager Application Database副本集的成员数。

3

spec
.applicationDatabase
.version

字符串

必需

MongoDBOps Manager Application Database应运行的 版本。

对于 MongoDB Community Edition,格式应为X.Y.Z ;对于Enterprise Edition,格式应为X.Y.Z-ubi8

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

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

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

spec
.applicationDatabase
.topology

字符串

可选

应用程序数据库的 Kubernetes 部署类型。 如果省略,则默认值为SingleCluster

如果您指定MultiCluster ,Kubernetes Operator 将忽略您为spec.applicationDatabase.members字段设置的值(如果已指定)。

相反,您必须指定clusterSpecList ,并在其中包含要部署应用程序数据库的每个选定Kubernetes成员集群的clusterName ,以及每个Kubernetes集群中members ( MongoDB节点)的数量。

您无法通过修改 CRD 中的clusterSpecListtopology设置将单集群MongoDB Ops Manager 实例转换为多 Kubernetes集群 部署实例。MongoDB

另请参阅资源规范的示例。

MultiCluster

5

要配置备份,必须启用备份,然后:

  • Choose to configure an S3 snapshot store or a blockstore. If you deploy both an S3 snapshot store and a blockstore, Ops Manager randomly choses one to use for backup.

  • Choose to configure an oplog store or an S3 oplog store. If you deploy both an oplog store and an S3 oplog store, Ops Manager randomly choses one of them to use for the oplog backup.

类型
说明
例子

spec
.backup
.enabled

布尔

指示备份已启用的标志。您必须指定 spec.backup.enabled: true 来配置头部数据库、 oplog存储、 S3 oplog存储和快照存储的设置。

true

spec
.backup
.headDB

集合

头部数据库配置设置的集合。有关集合中各个设置的说明,请参阅spec.backup.headDB

spec
.backup
.opLogStores
.name

字符串

oplog 存储的名称。

oplog1

spec
.backup
.s3OpLogStores
.name

字符串

Name of the S3 oplog store.

my-s3-oplog-store

spec
.backup
.opLogStores
.mongodbResourceRef
.name

字符串

oplog 存储的MongoDB资源或MongoDBMultiCluster资源的名称。 资源的metadata.name必须与此名称匹配。

my-oplog-db

spec
.backup
.s3OpLogStores
.mongodbResourceRef
.name

字符串

S3 oplog存储的MongoDB 数据库资源名称。

my-s3-oplog-db

您还必须配置 S3快照存储或块存储。如果同时部署S3快照存储和块存储, Ops Manager会随机选择一个用于备份。

要配置 S3快照存储,请配置以下设置:

类型
说明
例子

spec
.backup
.s3Stores
.name

字符串

Name of the S3 snapshot store.

s3store1

spec
.backup
.s3Stores
.s3SecretRef
.name

字符串

包含 accessKeysecretKey 字段的密钥名称。备份守护程序服务使用这些字段的值作为凭证来访问权限S3 S3 兼容存储桶。

my-s3-credentials

spec
.backup
.s3Stores
.s3BucketEndpoint

字符串

存储数据库备份快照的 S3S3 兼容存储桶的URL 。

s3.us-east-1.amazonaws.com

spec
.backup
.s3Stores
.s3BucketName

字符串

存储数据库备份快照的 S3 S3 兼容存储桶的名称。

my-bucket

spec
.backup
.s3Stores
.s3RegionOverride

字符串

S3 兼容存储桶所在的区域。仅当 S3 商店的 s3BucketEndpoint 的URL中不包含地区时,才使用此字段。请勿将此字段与 AWS S3 存储桶一起使用。

us-east-1

要配置块存储,请配置以下设置:

类型
说明
例子

spec
.backup
.blockStores
.name

字符串

块存储的名称。

blockStore1

spec
.backup
.blockStores
.mongodbResourceRef
.name

字符串

您为块存储创建的MongoDB资源的块存储。 您必须将此数据库资源部署在与MongoDB Ops Manager资源相同的命名空间中。 资源的metadata.name必须与此名称匹配。

my-mongodb-blockstore

6

Add any optional settings for backups that you want to apply to your deployment to the object specification file. For example, for each type of backup store, and for Ops Manager backup daemon processes, you can assign labels to associate particular backup backup stores or backup daemon processes with specific projects. Use spec.backup.[*].assignmentLabels elements of the OpsManager resources.

7

将要应用部署的任何可选设置添加到对象规范文件中。

8
9

在 Ops Manager 资源定义的文件名上运行以下kubectl命令:

kubectl apply -f <opsmgr-resource>.yaml

注意

MongoDB Ops Manager如果要在多 Kubernetes集群 部署上部署MongoDB 资源,请运行:

kubectl apply \
--context "$MDB_CENTRAL_CLUSTER_FULL_NAME" \
--namespace "mongodb"
-f https://raw.githubusercontent.com/mongodb/mongodb-kubernetes/master/public/samples/ops-manager/ops-manager-external.yaml
10

要检查 Ops Manager 资源的状态,请调用以下命令:

kubectl get om -o yaml -w

部署资源时,该命令会在status字段下返回类似于以下内容的输出:

status:
applicationDatabase:
lastTransition: "2023-04-01T09:49:22Z"
message: AppDB Statefulset is not ready yet
phase: Pending
type: ""
version: ""
backup:
phase: ""
opsManager:
phase: ""

Kubernetes Operator 按以下顺序协调资源:

  1. 应用程序数据库。

  2. Ops Manager。

  3. 备份。

在前一个资源进入Running阶段之前,Kubernetes 操作符 不会协调某一资源。

在MongoDB Ops Manager资源完成 Pending 阶段后,如果启用了备份,该命令会在 status 字段下返回类似于以下内容的输出:

status:
applicationDatabase:
lastTransition: "2023-04-01T09:50:20Z"
members: 3
phase: Running
type: ReplicaSet
version: "8.0.0-ubi8"
backup:
lastTransition: "2022-04-01T09:57:42Z"
message: The MongoDB object <namespace>/<oplogresourcename>
doesn't exist
phase: Pending
opsManager:
lastTransition: "2022-04-01T09:57:40Z"
phase: Running
replicas: 1
url: http://om-svc.cloudqa.svc.cluster.local:8080
version: "8.0.0"

在配置备份数据库之前,备份将保持Pending状态。

提示

status.opsManager.url字段说明资源的连接URL 。 使用此URL ,您可以从MongoDB Ops Manager Kubernetes集群内部访问 或 使用 ConfigMap 创建项目。

11

根据您在 Kubernetes 中将流量路由到 Ops Manager 应用程序的方式,您采取的步骤会有所不同。如果已配置 Kubernetes 操作符 来为您创建 Kubernetes 服务,或者您手动创建了 Kubernetes 服务,请使用以下方法之一访问 Ops Manager 应用程序:

  1. 查询您的云提供商以获取负载均衡器服务的FQDN 。 有关详细信息,请参阅云提供商的文档。

  2. 打开浏览器窗口,使用负载负载均衡器服务的MongoDB Ops Manager FQDN 和端口号导航到 应用程序。

    http://ops.example.com:8080
  3. 使用管理员用户凭证登录 Ops Manager。

  1. 将防火墙规则设置为允许从互联网访问权限运行Kubernetes集群的托管上的spec.externalConnectivity. port

  2. Open a browser window and navigate to the Ops Manager application using the FQDN and the spec.externalConnectivity.port.

    http://ops.example.com:30036
  3. 使用管理员用户凭证登录 Ops Manager。

要了解如何使用第三方服务访问 Ops Manager 应用程序,请参阅您的解决方案的文档。

12

如果启用了备份,则必须创建MongoDB Ops Manager组织,生成编程API密钥,并在secret-storage-tool中创建密钥。 这些活动遵循“为Kubernetes Operator 创建凭证”页面上的先决条件和过程。

13

如果已启用备份,请按照使用 ConfigMap 为每个MongoDB部署创建一个项目页面上的先决条件和过程创建项目。

您必须设立ConfigMap 中的 data.baseUrl 设置为MongoDB Ops Manager应用程序的URL 。 要查找此URL ,请调用以下命令:

kubectl get om -o yaml -w

该命令在status.opsManager.url字段中返回 Ops Manager 应用程序的 URL,与以下示例类似:

status:
applicationDatabase:
lastTransition: "2022-04-01T10:00:32Z"
members: 3
phase: Running
type: ReplicaSet
version: "8.0.0-ubi8"
backup:
lastTransition: "2022-04-01T09:57:42Z"
message: The MongoDB object <namespace>/<oplogresourcename>
doesn't exist
phase: Pending
opsManager:
lastTransition: "2022-04-01T09:57:40Z"
phase: Running
replicas: 1
url: http://om-svc.cloudqa.svc.cluster.local:8080
version: "8.0.0"

重要

如果将 Ops Manager 与 Kubernetes Operator 一起部署,且 Ops Manager 将管理部署在 Kubernetes 集群外部的 MongoDB 数据库资源,则必须将 data.baseUrl 设置为与 Ops Manager 资源规范中的 spec.configuration.mms.centralUrl 设置相同的值。

要学习;了解更多信息,请参阅管理外部MongoDB部署。

14

如果已启用 备份 ,请为 和快照存储创建MongoDB database oplog资源以完成配置。

  1. 在与 Ops Manager 资源相同的命名空间中为 oplog 存储部署MongoDB database资源。

    注意

    创建此数据库作为副本集。

    将资源的metadata.name与您在 Ops Manager 资源定义中指定的spec.backup.opLogStores.mongodbResourceRef.name进行匹配。

  2. 选择以下选项之一:

    1. 在与MongoDB database 资源相同的命名空间中部署块存储的MongoDB Ops Manager 资源。

      将资源的metadata.name与您在 Ops Manager 资源定义中指定的spec.backup.blockStores.mongodbResourceRef.name进行匹配。

    2. 配置 S3 存储桶以用作 S3快照存储。

      确保您可以使用Ops Manager资源定义中指定的详细信息访问权限S3 存储桶。

15

如果已启用备份,请通过调用以下命令检查MongoDB Ops Manager资源的状态:

kubectl get om -o yaml -w

当MongoDB Ops Manager正在运行时,该命令会在 status字段下返回以下输出:

status:
applicationDatabase:
lastTransition: "2022-04-01T10:00:32Z"
members: 3
phase: Running
type: ReplicaSet
version: "8.0.0-ubi8"
backup:
lastTransition: "2022-04-01T10:00:53Z"
phase: Running
version: "8.0.0-ubi8"
opsManager:
lastTransition: "2022-04-01T10:00:34Z"
phase: Running
replicas: 1
url: http://om-svc.cloudqa.svc.cluster.local:8080
version: "8.0.0"

有关资源部署状态的信息,请参阅排除 Kubernetes 操作符故障

给本页内容打分

在此页面上