

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 尋找叢集的端點
<a name="db-cluster-endpoints-find"></a>

您可以使用 Amazon DocumentDB 主控台或 尋找叢集的叢集端點和讀取器端點 AWS CLI。

------
#### [ Using the AWS 管理主控台 ]

**若要使用主控台尋找叢集的端點：**

1. 登入 AWS 管理主控台，並在 [https://console.aws.amazon.com/docdb](https://console.aws.amazon.com/docdb)：// 開啟 Amazon DocumentDB 主控台。

1. 在導覽窗格中，選擇**叢集**。

1. 從叢集清單中選擇您有興趣之叢集的名稱。

1. 在叢集詳細資訊頁面上，選取**組態**索引標籤。在**組態和狀態**區段中，您會找到**叢集端點**和**讀取器端點**。  
![\[顯示叢集和讀取器端點的組態和狀態區段。\]](http://docs.aws.amazon.com/zh_tw/documentdb/latest/developerguide/images/db-cluster-endpoints.png)

1. 若要連線至此叢集，請選取**連線與安全**索引標籤。找到 `mongo` Shell 的連線字串，以及可用於應用程式程式碼的連線字串，以連接至您的叢集。  
![\[連線區段顯示使用 mongo shell 連線到執行個體的字串，以及使用 應用程式連線到叢集的字串。\]](http://docs.aws.amazon.com/zh_tw/documentdb/latest/developerguide/images/cluster-connection-strings.png)

------
#### [ Using the AWS CLI ]

若要使用 尋找叢集的叢集和讀取器端點 AWS CLI，請使用這些參數執行 `describe-db-clusters`命令。

**參數**
+ **--db-cluster-identifier**- 選用。指定要傳回其端點的叢集。如果省略，則最多會傳回您的 100 個叢集的端點。
+ **--query**- 選用。指定顯示的欄位。有助於減少您尋找端點時需要檢視的資料量。如果省略，將會傳回叢集的所有資訊。
+ **--region**- 選用。使用 `--region` 參數來指定您要套用命令的區域。若省略，則使用您的預設區域。

**Example**  
以下範例傳回 `sample-cluster` 的 `DBClusterIdentifier`、端點 (叢集端點)，以及 `ReaderEndpoint`。  
若為 Linux、macOS 或 Unix：  

```
aws docdb describe-db-clusters \
   --region us-east-1 \
   --db-cluster-identifier sample-cluster \
   --query 'DBClusters[*].[DBClusterIdentifier,Port,Endpoint,ReaderEndpoint]'
```
針對 Windows：  

```
aws docdb describe-db-clusters ^
   --region us-east-1 ^
   --db-cluster-identifier sample-cluster ^
   --query 'DBClusters[*].[DBClusterIdentifier,Port,Endpoint,ReaderEndpoint]'
```
此操作的輸出將會如下所示 (JSON 格式)。  

```
[
  [
     "sample-cluster",
     27017,
     "sample-cluster.cluster-corlsfccjozr.us-east-1.docdb.amazonaws.com",
     "sample-cluster.cluster-ro-corlsfccjozr.us-east-1.docdb.amazonaws.com"
  ]
]
```

現在，有了叢集端點，您可以使用 `mongo` 或 `mongodb` 連接至該叢集。如需詳細資訊，請參閱[連線至端點](endpoints-connecting.md)。

------