【问题标题】:Mongo shell connects but exit at first commandMongo shell 连接但在第一个命令时退出
【发布时间】:2019-03-02 03:02:46
【问题描述】:

我有一个 mongo 副本集容器和一个 mongo 客户端容器。

当我尝试从 mongo shell 客户端连接时,它可以连接但在第一个命令它停止并退出而没有错误消息?!其他“非 shell 客户端”没有这个问题。 未找到锁定文件。有什么想法吗?

root@mongoclient-b8b6c4cff-2k5hg:~# mongo mongodb://root:xxx@mongodb:27017/db?authSource=admin&replicaSet=rs0
[12] 401
root@mongoclient-b8b6c4cff-2k5hg:~# MongoDB shell version v4.0.6
connecting to: mongodb://mongodb:27017/db?authSource=admin&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("5b6daf02-fc3b-4995-9819-728810c9011a") }
MongoDB server version: 4.0.3
Server has startup warnings: 
2019-02-22T09:12:54.186+0000 I STORAGE  [initandlisten] 
2019-02-22T09:12:54.186+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-02-22T09:12:54.186+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-02-22T09:12:55.199+0000 W CONTROL  [initandlisten] 
2019-02-22T09:12:55.199+0000 W CONTROL  [initandlisten] 
2019-02-22T09:12:55.199+0000 I CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---



[12]+  Stopped                 mongo mongodb://root:xxx@mongodb:27017/db?authSource=admin
root@mongoclient-b8b6c4cff-2k5hg:~#  

【问题讨论】:

标签: mongodb shell client


【解决方案1】:

这是因为& 是 shell 中的一个特殊字符,而您的 URL 中有一个未转义的字符。

您可以简单地引用 URL,这样 shell 就不会尝试解释它:

mongo "mongodb://root:xxx@mongodb:27017/db?authSource=admin&replicaSet=rs0"

【讨论】:

【解决方案2】:

好吧..我找到了解决方案,事实证明删除url中的replicaset参数有效!?

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2012-02-17
  • 2017-06-04
  • 1970-01-01
  • 1970-01-01
  • 2019-05-12
  • 1970-01-01
  • 2013-05-05
  • 1970-01-01
相关资源
最近更新 更多