首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么mongodb连接url不兼容shell和驱动程序?

为什么mongodb连接url不兼容shell和驱动程序?
EN

Stack Overflow用户
提问于 2017-04-10 02:40:28
回答 1查看 873关注 0票数 0

我使用这个连接url通过drivermongodb://localhost:27017?ssl=true连接mongodb实例,它工作得很好。但是相同的url不能在mongo上工作,我必须取出ssl=true参数并使用mongo mongodb://localhost:27017 --ssl命令。他们为什么不能互相兼容?这两种类型的连接都有通用的url吗?

EDIT1

我试过芒果3.4.3和3.4.2。两个版本都有相同的问题。

下面是我得到的详细命令和输出:

代码语言:javascript
复制
mongo mongodb://host-1:27017,host-2:27017,host3:27017/admin?replicaSet=Cluster0-shard-0&ssl=true --username admin --password 123456

以下是产出:

代码语言:javascript
复制
    connecting to: mongodb://host-1:27017,host-2:27017,host-3:27017/admin?replicaSet=Cluster0-shard-0
    2017-04-10T20:52:09.345+1000 I NETWORK  [thread1] Starting new replica set monitor for Cluster0-shard-0/host-1:27017,host-2:27017,host-3:27017
    2017-04-10T20:52:09.416+1000 I NETWORK  [thread1] Socket recv() Connection reset by peer 13.54.24.198:27017
    2017-04-10T20:52:09.416+1000 I NETWORK  [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [13.54.24.198:27017]
    2017-04-10T20:52:09.416+1000 W NETWORK  [thread1] No primary detected for set Cluster0-shard-0
    2017-04-10T20:52:09.416+1000 I NETWORK  [thread1] All nodes for set Cluster0-shard-0 are down. This has happened for 1 checks in a row.
    2017-04-10T20:52:09.987+1000 I NETWORK  [thread1] Socket recv() Connection reset by peer 13.54.31.109:27017
    2017-04-10T20:52:09.987+1000 I NETWORK  [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [13.54.31.109:27017]
    2017-04-10T20:52:10.019+1000 W NETWORK  [thread1] No primary detected for set Cluster0-shard-0
    2017-04-10T20:52:10.019+1000 I NETWORK  [thread1] All nodes for set Cluster0-sha
    rd-0 are down. This has happened for 2 checks in a row.
    2017-04-10T20:52:10.558+1000 I NETWORK  [thread1] Socket recv() Connection reset
...
2017-04-10T20:53:44.940+1000 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [13.54.31.109:27017]
EN

回答 1

Stack Overflow用户

发布于 2017-04-10 03:24:15

如果您使用mongo版本>= 3.4,则应该对此进行修正。

假设使用3.4shell进行连接,则命令行和输出如下所示:

代码语言:javascript
复制
mongo "mongodb://localhost:27017/test?ssl=true" --authenticationDatabase admin --username xxx --password xxx
MongoDB shell version v3.4.3
connecting to: mongodb://localhost:27017/test?ssl=true
MongoDB server version: 3.4.3
>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43314231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档