命令失败,错误 13(未授权):'未授权

时间:2021-06-23 16:15:49

标签: java mongodb apache-beam dataflow

我正在尝试通过 Java Apachebeam MongoDbIO 连接器连接到 MongoDB,但出现“未授权”错误。

相同的连接细节适用于 Python 并且能够检索数据。

任何建议都会有帮助

错误:

021-06-23 17:59:09.041 来自工作人员的 CESTError 消息:com.mongodb.MongoCommandException:命令失败,错误 13(未授权):'未在 test-direkt-dev 上授权执行命令 { splitVector: "test -direkt-dev.taskLog", keyPattern: { _id: 1 }, force: false, maxChunkSize: 21, $db: "test-direkt-dev", $clusterTime: { clusterTime: Timestamp(1624463948, 23), 签名: { hash: BinData(0, C92C5EEC1265B01EDB9B51DFC24BAB98D85EAE0D), keyId: 6911535624117813250 } }, lsid: { id: UUID("05eedc7a-f75-f719,$c530D"P757-300000000000000000000000000000000000}"服务器 172.29.156.26:27017。完整的响应是 { "operationTime" : { "$timestamp" : { "t" : 1624463948, "i" : 31 } }, "ok" : 0.0, "errmsg" : "notauthorized on test-direkt-dev执行命令 { splitVector: "test-direkt-dev.taskLog", keyPattern: { _id: 1 }, force: false, maxChunkSize: 21, $db: "test-direkt-dev", $clusterTime: { clusterTime: Timestamp( 1624463948, 23), 签名: { hash: BinData(0, C92C5EEC1265B01EDB9B51DFC24BAB98D85EAE0D), keyId: 6911535624117813250 } }, lsid: {"25c5c5c7dc5dc7d-7dc7d-7dc17d-7dc7d-7dc7d-7dc7d-7dc17d-7dc7d-7dc7d "primaryPreferred" } }", "code" : 13, "codeName" : "Unauthorized", "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1624463948, "i" : 31 } }, "signature" : { "hash" : { "$binary" : "ySxe7BJlsB7bm1HfwkurmNherg0=", "$type" : "00" }, "keyId" : { "$numberLong" : "691153562411781}250" } } /p>

代码:

return pipeline.apply(MongoDbIO.read()
                       .withUri("mongodb://testuser:testpass1@88.200.92.195:27017")
                               .withDatabase("test-direkt-dev")
                               .withCollection("taskLog"));

感谢您的更新。

根据文档, https://beam.apache.org/releases/javadoc/2.13.0/org/apache/beam/sdk/io/mongodb/MongoDbIO.Read.html
如果使用 username:password@ 语法,则需要传递数据库名称“/database name”。

  return pipeline.apply(MongoDbIO.read()
        .withUri("mongodb://testuser:testpass1@88.200.92.195:27017/test-direkt-dev")
    .withDatabase("test-direkt-dev")
    .withCollection("taskLog"));

这一次,我收到以下错误:

"org.apache.beam.sdk.io.mongodb.MongoDbIO$BoundedMongoDbSource.$closeResource(MongoDbIO.java:407) at org.apache.beam.sdk.io.mongodb.MongoDbIO$BoundedMongoDbSource.split(MongoDbIO. java:537) ... 15 多个原因:com.mongodb.MongoCommandException:命令失败,错误 18(AuthenticationFailed):“身份验证失败。”在服务器 88.200.92.195:27017 上。完整响应是 { "operationTime" : { "$timestamp" : { "t" : 1624636024, "i" : 24 } }, "ok" : 0.0, "errmsg" : "Authentication失败。”,“代码”:18,“代码名称”:“AuthenticationFailed”,“$clusterTime”:{“clusterTime”:{“$timestamp”:{“t”:1624636024,“i”:24}},“签名”:{“哈希”:{“$binary”:“8a1nBS/Wmd5z1SHqhLKnW7Y/g7I=”,“$type”:“00”},“keyId”:{“$numberLong”:“6911535624117813}250”}}在”

2 个答案:

答案 0 :(得分:0)

如果相同的细节在 Python SDK 中起作用,我建议提交一个包含重现问题步骤的错误。我没有找到any existing bug for Java's MongoDbIO。有关如何提交错误的信息,请参阅 https://beam.apache.org/community/contact-us/

答案 1 :(得分:0)

splitVector 是 MongoDB 内部命令,不应从驱动程序调用。