查找实例的终端节点
您可使用 Amazon DocumentDB控制台或 AWS CLI. 查找实例的终端节点。
使用控制台
使用控制台查找实例的终端节点
通过以下网址登录 AWS 管理控制台并打开 Amazon DocumentDB 控制台:https://console.aws.amazon.com/docdb。
在导航窗格中,选择 Clusters.
提示
如果您在屏幕左侧没有看到导航窗格,请在页面左上角选择菜单图标 (
)。在“Clusters (集群)”导航窗格中,您将看到 Cluster Identifier (集群标识符) 列。您的实例将在集群下列出,与以下屏幕截图类似。

选中您感兴趣的实例左侧的框。
向下滚动到 Details (详细信息) 部分,然后找到实例终端节点。

要连接到此实例,请向上滚动到 Connect (连接) 部分。找到
mongoshell 的连接字符串和可在应用程序代码中使用以连接到实例的连接字符串。
使用 AWS CLI
要使用 AWS CLI 查找实例终端节点,请运行带有以下参数的命令。
Arguments
--db-instance-identifier—可选。指定要为其返回终端节点的实例。如果省略,则返回最多 100 个实例的终端节点。--query—可选。指定要显示的字段。通过减少您需要查看以查找终端节点的数据量很有用。如果省略,则返回有关实例的所有信息。字段有三个成员,因此在查询中列出它,如以下示例所示返回所有三个成员。Endpoint如果您只对部分Endpoint成员感兴趣,请将查询中的Endpoint替换为您感兴趣的成员,如第二个示例中所示。--region—可选。使用--region参数指定要将命令应用到的区域。如果省略,则使用默认区域。
对于 Linux、macOS 或 Unix:
aws docdb describe-db-instances \--regionus-east-1\--db-instance-identifiersample-cluster-instance\--query 'DBInstances[*].[DBInstanceIdentifier,Endpoint]'
对于 Windows:
aws docdb describe-db-instances ^--regionus-east-1^--db-instance-identifiersample-cluster-instance^--query 'DBInstances[*].[DBInstanceIdentifier,Endpoint]'
此操作的输出将类似于下文(JSON 格式)。
[["sample-cluster-instance",{"Port": 27017,"Address": "sample-cluster-instance.corcjozrlsfc.us-east-1.docdb.amazonaws.com","HostedZoneId": "Z2R2ITUGPM61AM"}]]
减少输出以消除终端节点的 HostedZoneId,可通过指定 Endpoint.Port 和 Endpoint.Address. 来修改查询。
对于 Linux、macOS 或 Unix:
aws docdb describe-db-instances \--regionus-east-1\--db-instance-identifiersample-cluster-instance\--query 'DBInstances[*].[DBInstanceIdentifier,Endpoint.Port,Endpoint.Address]'
对于 Windows:
aws docdb describe-db-instances ^--regionus-east-1^--db-instance-identifiersample-cluster-instance^--query 'DBInstances[*].[DBInstanceIdentifier,Endpoint.Port,Endpoint.Address]'
此操作的输出将类似于下文(JSON 格式)。
[["sample-cluster-instance",27017,"sample-cluster-instance.corcjozrlsfc.us-east-1.docdb.amazonaws.com"]]
现在您已拥有实例终端节点,可以使用 mongo 或 mongodb 连接到实例。有关更多信息,请参阅 连接到 终端节点.
