Bha*_*hah 3 amazon-ec2 amazon-web-services mongodb-compass aws-documentdb-mongoapi
AWS DocumentDB是我们要迁移到的相对较新的服务。要从VPC外部进行连接,必须创建到现有实例的隧道。
例如:
ssh -i "ec2Access.pem" -L 27017:sample-cluster.cluster-cu52jq5kfddg.us-east-1.docdb.amazonaws.com:27017 ubuntu@ec2-34-229-221-164.compute-1.amazonaws.com -N
Run Code Online (Sandbox Code Playgroud)
然后您可以从mongo shell用以下命令连接:
mongo --sslAllowInvalidHostnames --ssl --sslCAFile rds-combined-ca-bundle.pem --username <yourUsername> --password <yourPassword>
Run Code Online (Sandbox Code Playgroud)
您可以在以下位置查看此信息:https : //docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html
实际上,我可以按照上述说明将shell放入document db,但无法使用MongoDB指南针连接到它。我们需要能够为我们的非开发人员团队做到这一点。
我仅使用MongoDB Compass(社区,版本1.16.4)进行了此操作,而没有通过外部工具创建隧道。
首先,从以下网址下载AWS的证书:https : //s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem。我从以下网址获得了此链接:https : //docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html
还要确保您可以从EC2实例访问DocDB集群。为此,请查看为您的DocDB群集指定的安全组设置。鉴于您能够使用mongo shell进行访问,因此您应该拥有它。
然后在MongoDB Compass的连接屏幕上指定以下内容(您的凭据用作示例):
小智 6
同样,我能够通过 mongosh 连接到我的隧道 DocumentDB 实例,但不能使用 MongoDB Compass。我注意到 mongosh 输出连接字符串,所以我将其复制到 Compass 中并且它起作用了。
mongodb://<credentials>@localhost:27017/?directConnection=true&tls=true&tlsAllowInvalidHostnames=true&tlsCAFile=<path_to_pem>
Run Code Online (Sandbox Code Playgroud)
看来我缺少的部分是
直接连接=true
| 归档时间: |
|
| 查看次数: |
1830 次 |
| 最近记录: |