【问题标题】:mongodump error "Failed: can't create session: could not connect to server:"mongodump 错误“失败:无法创建会话:无法连接到服务器:”
【发布时间】:2022-07-20 14:32:40
【问题描述】:

我可以使用自签名证书在本地成功连接我的 mongodb。 mongo 配置下的安全授权设置为“禁用”,并启用了 TLS。在本地使用mongodump 命令

mongodump --ssl --authenticationDatabase admin --host=127.0.0.1 --port=27017 -u=admin -p=8ewuyuiuw3! --sslPEMKeyFile=/etc/ssl/mongodb.pem --sslCAFile=/etc/ssl/rootCA.pem --archive=/home/backups/mongodump.gz --gzip

尽管我禁用了授权,但管理员用户仍然存在。如果没有凭据,我也会遇到同样的错误。

我总是得到错误:

2021-12-03T14:58:29.420+0200    Failed: can't create session: could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: 127.0.0.1:27017, Type: Unknown, Last error: connection() error occured during connection handshake: x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs }, ] }

我也尝试使用export GODEBUG=x509ignoreCN=0,但没有成功。有什么解决办法吗?

【问题讨论】:

  • 你解决了吗?
  • @Ermal 是的,你有同样的问题吗?
  • 是的。我不知道是否需要配置 --ssl 或其他任何东西。但我也无法通过命令行连接。 (mongodb://localhost:27017/novi_dedicated --ssl --authenticationDatabase admin )。你能回答你自己的问题吗?如果它可以解决我的问题,我将设置为已回答。
  • @Ermal 是的,我明天会做,目前我不在办公室

标签: mongodb mongodb-query mongodump


【解决方案1】:

我终于设法使它与以下两个命令一起工作。看来是需要参数--tlsInsecure

mongodump --ssl  --host=127.0.0.1 --port=27017  --sslPEMKeyFile=/etc/ssl/mongoCer/mongodb.pem --sslCAFile=/etc/ssl/mongoCer/rootCA.pem --archive=./mongo-daily-backups/mongodump-date_2020-11-16_time_20-37-11.gz --gzip --tlsInsecure

mongodump --ssl  --host=127.0.0.1 --port=27017 --archive=./mongo-daily-backups/mongodump-date_2020-11-16_time_20-37-11.gz --gzip --tlsInsecure

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-22
    • 2017-07-22
    • 2016-04-05
    • 1970-01-01
    • 2019-10-08
    • 1970-01-01
    • 2021-10-10
    • 2018-05-27
    相关资源
    最近更新 更多