|
| 1 | +.. _atlas-cli-create-cluster-from-config-file: |
| 2 | + |
| 3 | +====================================================== |
| 4 | +Create an |service| Cluster Using a Configuration File |
| 5 | +====================================================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 2 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +This tutorial demonstrates how to use {+atlas-cli+} commands to create |
| 16 | +a new |service| cluster from a configuration file. Specifically, it |
| 17 | +demonstrates how to: |
| 18 | + |
| 19 | +1. Get the configuration settings of an :ref:`existing Atlas cluster |
| 20 | + <atlas-clusters-create>` and save the settings to a |
| 21 | + configuration file using the :ref:`atlas-clusters-describe` command. |
| 22 | +#. Create an |service| {+cluster+} from the configuration file using the |
| 23 | + :ref:`atlas-clusters-create` command. |
| 24 | + |
| 25 | +.. _atlas-cli-create-cluster-from-config-file-reqs: |
| 26 | + |
| 27 | +Prerequisites |
| 28 | +------------- |
| 29 | + |
| 30 | +Before you begin, you must have the following: |
| 31 | + |
| 32 | +- :ref:`An Atlas cluster <atlas-clusters-create>` |
| 33 | +- :ref:`Atlas CLI <install-atlas-cli>` |
| 34 | +- :ref:`A profile <atlas-cli-profiles>` that contains the IDs of the |
| 35 | + |service| organization and project from where you wish to retrieve |
| 36 | + existing cluster settings and where you wish to create the new |
| 37 | + {+cluster+}. |
| 38 | + |
| 39 | +.. _atlas-cli-create-cluster-from-config-file-procedure: |
| 40 | + |
| 41 | +Create an |service| Cluster From a Configuration File |
| 42 | +----------------------------------------------------- |
| 43 | + |
| 44 | +You can use the procedures in this section to easily create a new |
| 45 | +{+cluster+} by exporting settings from an existing {+cluster+} instead |
| 46 | +of manually creating a configuration file yourself. |
| 47 | + |
| 48 | +Export Existing Cluster Configuration Settings to a File |
| 49 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 50 | + |
| 51 | +.. procedure:: |
| 52 | + :style: normal |
| 53 | + |
| 54 | + .. step:: Connect to your |service| account for programmatic access if you haven't connected yet. |
| 55 | + |
| 56 | + To learn more, see :ref:`connect-atlas-cli`. |
| 57 | + |
| 58 | + .. step:: Run the following command to export the details of an existing cluster to a |json| configuration file named ``myCluster``. |
| 59 | + |
| 60 | + .. code-block:: shell |
| 61 | + :copyable: true |
| 62 | + |
| 63 | + atlas clusters describe <cluster-name> --output json > myCluster.json |
| 64 | + |
| 65 | + Replace <cluster-name> in the preceding command with the name of |
| 66 | + the existing {+cluster+} that you wish to clone. |
| 67 | + |
| 68 | +(Optional) Edit the Configuration File for the new Cluster |
| 69 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 70 | + |
| 71 | +.. procedure:: |
| 72 | + :style: normal |
| 73 | + |
| 74 | + .. step:: Open the |json| file in a text editor to view the configuration settings. |
| 75 | + |
| 76 | + .. example:: |
| 77 | + |
| 78 | + The following example uses the ``vi`` editor to view the |
| 79 | + replica set settings for an ``M10`` cluster named |
| 80 | + ``mySandbox`` in the ``myCluster.json`` file. |
| 81 | + |
| 82 | + .. io-code-block:: |
| 83 | + :copyable: false |
| 84 | + |
| 85 | + .. input:: |
| 86 | + :language: shell |
| 87 | + |
| 88 | + vi myCluster.json |
| 89 | + |
| 90 | + .. output:: |
| 91 | + :language: json |
| 92 | + :linenos: |
| 93 | + |
| 94 | + { |
| 95 | + "backupEnabled": true, |
| 96 | + "biConnector": { |
| 97 | + "enabled": false, |
| 98 | + "readPreference": "secondary" |
| 99 | + }, |
| 100 | + "clusterType": "REPLICASET", |
| 101 | + "connectionStrings": { |
| 102 | + "standard": "<connection-string>" |
| 103 | + }, |
| 104 | + "diskSizeGB": 10, |
| 105 | + "encryptionAtRestProvider": "NONE", |
| 106 | + "groupId": "<group-id>", |
| 107 | + "id": "<64403dd1f2a6b45e71527d5a>", |
| 108 | + "mongoDBMajorVersion": "6.0", |
| 109 | + "mongoDBVersion": "6.0.5", |
| 110 | + "name": "mySandbox", |
| 111 | + "paused": false, |
| 112 | + "pitEnabled": true, |
| 113 | + "stateName": "IDLE", |
| 114 | + "replicationSpecs": [ |
| 115 | + { |
| 116 | + "numShards": 1, |
| 117 | + "id": "64403dbb0a052449df3d04ae", |
| 118 | + "zoneName": "Zone 1", |
| 119 | + "regionConfigs": [ |
| 120 | + { |
| 121 | + "analyticsAutoScaling": { |
| 122 | + "diskGB": { |
| 123 | + "enabled": true |
| 124 | + }, |
| 125 | + "compute": { |
| 126 | + "enabled": true, |
| 127 | + "scaleDownEnabled": true, |
| 128 | + "minInstanceSize": "M10", |
| 129 | + "maxInstanceSize": "M40" |
| 130 | + } |
| 131 | + }, |
| 132 | + "analyticsSpecs": { |
| 133 | + "diskIOPS": 3000, |
| 134 | + "ebsVolumeType": "STANDARD", |
| 135 | + "instanceSize": "M10", |
| 136 | + "nodeCount": 0 |
| 137 | + }, |
| 138 | + "electableSpecs": { |
| 139 | + "diskIOPS": 3000, |
| 140 | + "ebsVolumeType": "STANDARD", |
| 141 | + "instanceSize": "M10", |
| 142 | + "nodeCount": 3 |
| 143 | + }, |
| 144 | + "readOnlySpecs": { |
| 145 | + "diskIOPS": 3000, |
| 146 | + "ebsVolumeType": "STANDARD", |
| 147 | + "instanceSize": "M10", |
| 148 | + "nodeCount": 0 |
| 149 | + }, |
| 150 | + "autoScaling": { |
| 151 | + "diskGB": { |
| 152 | + "enabled": true |
| 153 | + }, |
| 154 | + "compute": { |
| 155 | + "enabled": true, |
| 156 | + "scaleDownEnabled": true, |
| 157 | + "minInstanceSize": "M10", |
| 158 | + "maxInstanceSize": "M40" |
| 159 | + } |
| 160 | + }, |
| 161 | + "priority": 7, |
| 162 | + "providerName": "AWS", |
| 163 | + "regionName": "US_EAST_1" |
| 164 | + } |
| 165 | + ] |
| 166 | + } |
| 167 | + ], |
| 168 | + "createDate": "2023-04-19T19:15:29Z", |
| 169 | + "rootCertType": "ISRGROOTX1", |
| 170 | + "versionReleaseSystem": "LTS", |
| 171 | + "terminationProtectionEnabled": false |
| 172 | + } |
| 173 | + |
| 174 | + .. step:: (Optional) Make changes to the settings in the configuration file as needed. |
| 175 | + |
| 176 | + To learn more about the optional and required settings, see |
| 177 | + :ref:`atlas-cli-cluster-config-file`. |
| 178 | + |
| 179 | + .. step:: Save and close the configuration file. |
| 180 | + |
| 181 | +Create a New Cluster Using the Configuration File |
| 182 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 183 | + |
| 184 | +.. procedure:: |
| 185 | + :style: normal |
| 186 | + |
| 187 | + .. step:: Connect to your |service| account for programmatic access if you aren't already connected to your |service| account. |
| 188 | + |
| 189 | + To learn more, see :ref:`connect-atlas-cli`. |
| 190 | + |
| 191 | + .. step:: Run the following command to create an |service| cluster using the configuration file. |
| 192 | + |
| 193 | + .. code-block:: |
| 194 | + :copyable: true |
| 195 | + |
| 196 | + atlas clusters create <new-cluster-name> -f myCluster.json |
| 197 | + |
| 198 | + Replace ``<new-cluster-name>`` in the preceding command with the |
| 199 | + name of the new {+cluster+} you wish to create. |
| 200 | + |
| 201 | + .. step:: Run the following command to check the status of the {+cluster+}. |
| 202 | + |
| 203 | + .. code-block:: shell |
| 204 | + :copyable: true |
| 205 | + |
| 206 | + atlas clusters watch <new-cluster-name> |
| 207 | + |
| 208 | + Replace <new-cluster-name> in the preceding command with the name |
| 209 | + of the new {+cluster+}. |
| 210 | + |
| 211 | + This command checks the {+cluster+}\'s status periodically until |
| 212 | + it reaches an ``IDLE`` state. Once the {+cluster+} reaches the |
| 213 | + expected state, the command prints "Cluster available." |
0 commit comments