我尝试使用语法连接到 MongoDB Atlas 集群srv
,但不起作用。所以我做了以下事情:
- 将我的
mongo
客户端更新到最新版本(v4.0.11)。然后每次我运行mongo
,它都说找不到libcrypto.so.1.1
。 - 按照以下答案安装 OpenSSL v1.1.1这个问题。
现在它输出以下内容:
$ mongo "mongodb+srv://cluster0-<redacted>.mongodb.net/test" --username <redacted>
MongoDB shell version v4.0.11
Enter password:
connecting to: mongodb://cluster0-shard-00-00-<redacted>.mongodb.net.:27017,cluster0-shard-00-01-<redacted>.mongodb.net.:27017,cluster0-shard-00-02-<redacted>.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2019-08-03T17:42:56.502-0500 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-<redacted>.mongodb.net.:27017,cluster0-shard-00-01-<redacted>.mongodb.net.:27017,cluster0-shard-00-02-<redacted>.mongodb.net.:27017
2019-08-03T17:42:56.736-0500 E NETWORK [ReplicaSetMonitor-TaskExecutor] SSL peer certificate validation failed: unable to get local issuer certificate
2019-08-03T17:42:56.834-0500 E NETWORK [js] SSL peer certificate validation failed: unable to get local issuer certificate
2019-08-03T17:42:57.169-0500 E NETWORK [ReplicaSetMonitor-TaskExecutor] SSL peer certificate validation failed: unable to get local issuer certificate
2019-08-03T17:42:57.169-0500 W NETWORK [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Cluster0-shard-0
2019-08-03T17:42:57.173-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2019-08-03T17:42:58.096-0500 E NETWORK [js] SSL peer certificate validation failed: unable to get local issuer certificate
并且它不断尝试连接并失败。即使我运行完全一样命令(使用旧的 MongoDB 连接格式)我可以在更新mongo
和 OpenSSL 之前运行,因此它必须与更新相关。在互联网上搜索只会返回一堆具有自签名证书的人,但我没有这样做,因为我使用的是 MongoDB Atlas。
任何建议将不胜感激。