使用 CNAME 记录使用 mongoDB atlas 创建自定义域

Create custom domain with mongoDB atlas using CNAME record

我正在 mongoDB atlas 上设置一个 mongoDB 集群。

要连接到集群,您会得到一个 URL,例如 cluster-01.mongodb.net。出于方便的原因,我尝试在 AWS Route53 上设置一条 CNAME 记录,从 cluster-01.my-company.co 指向上面的 mongoDB 云 URL。

连接到集群时:

mongo "mongodb+srv://mongo-01.my-company.co/test" --username user

但我收到以下错误:

DNSHostNotFound: Failed to look up service "_mongodb._tcp.mongo-01.my-company.co": Undefined error: 0

有没有人有为 mongoDB 云集群设置 CNAME 记录的经验?

这是不可能的。请参阅 https://jira.mongodb.org/browse/CDRIVER-2556 and in particular this commit https://github.com/mongodb/specifications/commit/3c1ff124ce47fa7b5d97b336028e575efd0e3d1e ,其中明确禁止将 CNAME 与 mongo+srv.

一起使用

目前,mongo atlas 没有这样的功能。如果您的要求是更新您的集群名称并且可以有一点停机时间,请使用 mongo atlas 实时迁移服务使用以下 link 将其迁移到不同的集群(使用新名称) ], 迁移完成后切换停止迁移并使用新集群。

https://docs.atlas.mongodb.com/import/live-import/

以防万一,如果您想在即将发布的 mongo atlas 中使用此功能,请在 mongo 反馈门户中请求此功能。 https://feedback.mongodb.com/forums/924145-atlas/suggestions/40474783-allow-custom-dns-hostnames-to-be-added-to-cluster

此外,此实时迁移服务支持升级 atlas 中的 mongo 集群版本,停机时间最短。