在更多尝试之后修改这个问题:
我第一次在 Galaxy 上部署 Meteor 应用程序,但无法连接到 MongoDB Atlas。
我可以使用以下方法通过 Mongo Shell 连接到 MongoDb:
mongo "mongodb://host1:27017,host2:27017,host3:27017/<db_name>?replicaSet=<replica_set_name>" --ssl --authenticationDatabase admin --username <username> --password <password>
我尝试了 Mongo URL 的等效项settings.json
:
mongodb://<username>:<password>@host1:27017,host2:27017,host3:27017/<db_name>?authSource=admin&replicaSet=<replace_set_name>
但是当我部署我的应用程序时,我得到:
Error: Could not locate any valid servers in initial seed list
.
我也尝试过使用 Atlas 提供的连接字符串:
mongodb+srv://<username>:<password>@<host>/<db_name>?retryWrites=true&w=majority
但这只是返回:
Error: URL must be in the format mongodb://user:pass@host:port/dbname
我已经尝试了所有我能想到的组合,但没有运气。
在 MONGODB ATLAS 支持的帮助下解决:“MONGO_URL”:“mongodb://:@host1:27017,host2:27017,host3:27017/?ssl=true&replicaSet=&authSource=admin&retryWrites=true&w=majority”,