Docs 菜单
Docs 主页
/ /
Atlas CLI
/

使用配置文件创建 Atlas 集群

在此页面上

  • 先决条件
  • 从配置文件创建 Atlas 集群
  • 将现有集群配置设置导出到文件
  • (可选)编辑新集群的配置文件
  • 使用配置文件创建新集群

本教程演示如何使用 Atlas CLI 命令从配置文件创建新的 Atlas 集群。具体来说,它演示了如何:

  1. 获取现有 Atlas 集群的配置设置,并使用atlas clusters describe命令将设置保存到配置文件中。

  2. Atlas使用Atlas clusters create 命令从配置文件创建 集群。

在开始之前,您必须具备以下条件:

您可以使用本节中的流程轻松创建新集群,方法是从现有集群导出设置,无需手动创建配置文件。

1

要了解详情,请参阅从 Atlas CLI 连接

2
atlas clusters describe <cluster-name> --output json > myCluster.json

将前面命令中的 <cluster-name> 替换为要克隆的现有集群的名称。

1

例子

以下示例使用vi编辑器查看myCluster.json文件中名为mySandboxM10集群的副本集设置。

vi myCluster.json
1{
2 "backupEnabled": true,
3 "biConnector": {
4 "enabled": false,
5 "readPreference": "secondary"
6 },
7 "clusterType": "REPLICASET",
8 "connectionStrings": {
9 "standard": "<connection-string>"
10 },
11 "diskSizeGB": 10,
12 "encryptionAtRestProvider": "NONE",
13 "groupId": "<group-id>",
14 "id": "<64403dd1f2a6b45e71527d5a>",
15 "mongoDBMajorVersion": "6.0",
16 "mongoDBVersion": "6.0.5",
17 "name": "mySandbox",
18 "paused": false,
19 "pitEnabled": true,
20 "stateName": "IDLE",
21 "replicationSpecs": [
22 {
23 "numShards": 1,
24 "id": "64403dbb0a052449df3d04ae",
25 "zoneName": "Zone 1",
26 "regionConfigs": [
27 {
28 "analyticsAutoScaling": {
29 "diskGB": {
30 "enabled": true
31 },
32 "compute": {
33 "enabled": true,
34 "scaleDownEnabled": true,
35 "minInstanceSize": "M10",
36 "maxInstanceSize": "M40"
37 }
38 },
39 "analyticsSpecs": {
40 "diskIOPS": 3000,
41 "ebsVolumeType": "STANDARD",
42 "instanceSize": "M10",
43 "nodeCount": 0
44 },
45 "electableSpecs": {
46 "diskIOPS": 3000,
47 "ebsVolumeType": "STANDARD",
48 "instanceSize": "M10",
49 "nodeCount": 3
50 },
51 "readOnlySpecs": {
52 "diskIOPS": 3000,
53 "ebsVolumeType": "STANDARD",
54 "instanceSize": "M10",
55 "nodeCount": 0
56 },
57 "autoScaling": {
58 "diskGB": {
59 "enabled": true
60 },
61 "compute": {
62 "enabled": true,
63 "scaleDownEnabled": true,
64 "minInstanceSize": "M10",
65 "maxInstanceSize": "M40"
66 }
67 },
68 "priority": 7,
69 "providerName": "AWS",
70 "regionName": "US_EAST_1"
71 }
72 ]
73 }
74 ],
75 "createDate": "2023-04-19T19:15:29Z",
76 "rootCertType": "ISRGROOTX1",
77 "versionReleaseSystem": "LTS",
78 "terminationProtectionEnabled": false
79}
2

要了解有关可选和必需设置的更多信息,请参阅集群配置文件。

3
1

要了解详情,请参阅从 Atlas CLI 连接

2
atlas clusters create <new-cluster-name> -f myCluster.json

将前面命令中的<new-cluster-name>替换为要创建的新集群的名称。

3
atlas clusters watch <new-cluster-name>

将前面命令中的 <new-cluster-name> 替换为新集群的名称。

此命令会定期检查集群的状态,直到达到IDLE状态。 一旦集群达到预期状态,该命令就会输出“Cluster available”。

后退

创建和配置集群