このチュートリアルでは、 Atlas 設定コマンドを使用して次の操作を行う方法を説明します。
Atlas プロジェクトに 1 つのクラスターを作成します。
Load sample data into your Atlas cluster.
IP アドレスをプロジェクトの IP アクセス リストに追加します。
Atlas クラスターの MongoDB ユーザーを作成します。
Connect to your new cluster using the MongoDB Shell,
mongosh.
新しい Atlas アカウントの作成中にこれらのすべての手順を実行するには、「 Atlas を使い始める 」を参照してください。
構成ファイルを使用してクラスターを作成するには、atlas setup ではなく --file オプションを指定して、 Atlasクラスター作成コマンドを実行します。 Atlas クラスターの構成ファイルの詳細については、「クラスター構成ファイル 」を参照してください。
また、 atlas setupを使用して Atlas アカウントを作成し、Atlas で認証することもできます。 詳細については、 「 Atlas の使用 」を参照してください。
前提条件
始める前に、次のタスクを完了してください。
Atlas 組織の作成
Atlas クラスターの構成
Atlas でM0クラスターを作成するには、 atlas setupコマンドを使用します。 M0クラスターには運用上の制限がいくつかあります。
このコマンドは、次の方法で実行できます。
デフォルト設定モード: コマンドは、デフォルト設定を持つサンプル共有階層クラスターを作成します。
対話モード: コマンドはクラスター設定を要求し、デフォルト値を提供します。
非対話型モード: オプションを指定して コマンドを実行します。
[] タブをクリックすると、ご希望モードのコマンドが表示されます。
コマンドは、次のデフォルト設定を持つサンプル共有階層クラスターを作成します。
クラスター名:
Cluster<number>サービスプロバイダー:
AWSプロバイダー リージョン:
US_EAST_1クラスター階層:
M0ディスクサイズ:
0.5GBデータベースユーザー名:
Cluster<number>データベースユーザー パスワード:
abcdef12345IP アドレス からの接続を許可します。
<YourIPAddress>サンプル データのロード:
Yesshell開きます:
No
注意
パスワードは自動生成されたランダムな値です。 abcdef12345はサンプル値です。
atlas setup --force
We are deploying Cluster9876543... Please store your database authentication access details in a secure location Database User Username: Cluster9876543 Database User Password: abcdef12345 Creating your cluster... [Its safe to 'Ctrl + C'] Cluster created. Your connection string: mongodb+srv://cluster9876543.example.mongodb.net Loading sample data into your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your Atlas cluster with: mongosh -u Cluster9876543 -p abcdef12345 mongodb+srv://cluster9876543.example.mongodb.net
コマンドはクラスター設定を要求し、デフォルト オプションを提供します。 プロンプトが表示されたら、 Yを押し、次にEnterを押してデフォルト設定を受け入れます。
atlas setup
Press [Enter] to use the default values. Enter [?] on any option to get help. [Default Settings] Cluster Name: Cluster9876543 Cloud Provider and Region: AWS - US_EAST_1 Database User Username: Cluster9876543 Load sample data: Yes Allow connections from (IP Address): <your-IP> ? Do you want to set up your first free database in Atlas with default settings (it's free forever)? Yes We are deploying Quickstart-9876543... Please store your database authentication access details in a secure location: Database User Username: Cluster9876543 Database User Password: abcdef12345 Creating your cluster... [Its safe to 'Ctrl + C'] Cluster created. Your connection string: mongodb+srv://cluster9876543.example.mongodb.net Loading sample data into your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your Atlas cluster with: mongosh -u Cluster9876543 -p abcdef12345 mongodb+srv://cluster9876543.example.mongodb.net
コマンドは、次の設定を持つサンプル共有階層クラスターを作成します。
クラスター名:
getStartedサービスプロバイダー:
AWSプロバイダー リージョン:
US_EAST-1クラスター階層:
M0ディスクサイズ:
2GBMongoDB バージョン:
5.0レプリカセット ノード
3
atlas setup --clusterName getStarted --provider AWS --region US_EAST_1 --username testUser --password changeMe --accessListIp 192.0.2.15 --skipSampleData --force
We are deploying getStarted... Please store your database authentication access details in a secure location: Database User Username: testUser Database User Password: changeMe Creating your cluster... [Its safe to 'Ctrl + C'] Now you can connect to your |service| cluster with: mongosh -u testUser -p changeMe mongodb+srv://getStarted.example.mongodb.net
次のステップへ進む
成功します。 データをホストするためのクラスターが正常に作成されました。
Use the connection string to connect to your cluster through mongosh or your application.
クラスターのステータスを表示する には、以下を行います。
Atlas CLI で
atlas clustersコマンドを実行します。