Overview
To connect to MongoDB, retrieve the hostname and port information from Cloud Manager and then use a MongoDB client, such as mongosh or a MongoDB client library, to connect. To connect to a cluster, retrieve the hostname and port for the mongos process. To connect to a replica set or standalone process, retrieve the hostname and port for the mongod processes.
ファイアウォール ルール
ファイアウォール ルールとユーザー認証は MongoDB へのアクセスに影響します。MongoDB プロセスのサーバーとポートにアクセス権がある必要があります。MongoDB を実行しているサーバーのファイアウォールについて詳しくは、MongoDB マニュアルのネットワーク セキュリティ ドキュメントのファイアウォール情報を参照してください。
MongoDB インスタンスがAmazon Web Services (AWS) で実行されている場合、AWS サーバーに関連付けられたセキュリティグループもアクセス権に影響します。AWS のセキュリティグループは、関連付けられたサーバーへのインバウンドとアウトバウンドのトラフィックを制御します。
手順
MongoDBインスタンスに接続するためのshellコマンドを検索するか、特定のMongoDBプロセスのホストとポート番号を検索し、 shellまたはMongoDBクライアントライブラリのいずれかを使用して接続用の独自コマンドを作成することができます。
MongoDB インスタンスに接続するためのシェルコマンドの取得
MongoDB Cloud ManagerGoProcessesMongoDB Cloud Managerで、プロジェクトの ページにGoします。
まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー
まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。
サイドバーで、 Database見出しの下のProcessesをクリックします。
[プロセス ]ページが表示されます。
クラスター、レプリカセット、またはプロセスをリストする行で、省略記号アイコンをクリックし、Connect to this instance を選択します。
Cloud Manager provides a mongo command that you can use to connect to the MongoDB process.
MongoDB プロセスのホストとポートの取得
MongoDB Cloud ManagerGoProcessesMongoDB Cloud Managerで、プロジェクトの ページにGoします。
まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー
まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。
サイドバーで、 Database見出しの下のProcessesをクリックします。
[プロセス ]ページが表示されます。
(任意)シャーディングされたクラスターでは、どのプロセス タイプが表示されるかをフィルタリングします。
4 つのボタンは、左から右に Shards、Configs、Mongos、BIs の順に並んでいます。
プロセス | 表示 |
|---|---|
Shards |
|
Configs |
|
Mongos |
|
BIs | シャーディングされたクラスター内のデータにアクセスする BI プロセス。 |
を使用した配置への接続 mongosh
Get the host and port using the previous procedure. From a shell, run mongosh and specify the host and port. For example:
mongosh --username <user> --password <pass> --host <host> --port <port>
MongoDBクライアント ライブラリを使用した配置への接続
上記の手順を使用してホストとポートを取得します。ホスト名とポートを指定する 接続文字列 を作成する方法については、 手順 を参照してください。
For sharded clusters, you specify the hostname and port of the mongos instance. For a replica set, you specify a seed list of all hosts in the replica set. Your client library will automatically connect to the primary. For example:
mongodb://[<username>:<password>@]hostname0<:port>[,hostname1:<port1>][,hostname2:<port2>][...][,hostnameN:<portN>]