2

我正在运行一个 siddhi 应用程序,它监听事件并将它们写入远程机器上运行的 mongodb 实例。mongo db 实例具有基本的身份验证设置(用户名、密码)。我尝试连接到 mongodb 实例并将事件写入集合,在日志中我可以看到 wso2 可以连接到远程实例

[2019-05-17 12:30:25,753]  INFO {org.mongodb.driver.cluster} - Cluster created with settings {hosts=[10.x.x.xxx:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[2019-05-17 12:30:25,763]  INFO {org.mongodb.driver.cluster} - Cluster created with settings {hosts=[10.x.x.xxx:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[2019-05-17 12:30:25,765]  INFO {org.wso2.carbon.siddhi.editor.core.internal.WorkspaceDeployer} - Siddhi App xxxxxxxxxx successfully deployed.
[2019-05-17 12:30:26,017]  INFO {org.mongodb.driver.connection} - Opened connection [connectionId{localValue:430, serverValue:1009}] to 10.x.x.xxx:27017
[2019-05-17 12:30:26,018]  INFO {org.mongodb.driver.connection} - Opened connection [connectionId{localValue:432, serverValue:1010}] to 10.x.x.xxx:27017

当我尝试写入 mongodb 时,出现以下错误

[2019-05-17 12:30:35,334] ERROR {org.wso2.siddhi.core.SiddhiAppRuntime} - Error starting Siddhi App 'IntegrationTesting', triggering shutdown process. Error on 'IntegrationTesting'. Error in retrieving collection names from the database 'IntegrationTesting' : Command failed with error 13: 'command listCollections requires authentication' on server 10.x.x.xxx:27017. The full response is { "ok" : 0.0, "errmsg" : "command listCollections requires authentication", "code" : 13, "codeName" : "Unauthorized" }

我尝试在 siddhi 应用程序 @store() 中添加用户名和密码,并尝试在 /conf/worker/deployment.yaml 中添加数据源。在这两种情况下,我都会遇到相同的错误。

请协助。

问候和感谢,

柴塔尼亚·库马尔

数据科学家 - Koinearth

4

1 回答 1

1

您是如何配置凭据的,MongoDB 扩展需要将用户名和密码插入 URI。

@Store(type="mongodb",mongodb.uri="mongodb://admin:admin@localhost/Foo")

https://siddhi-io.github.io/siddhi-store-mongodb/api/1.1.0/

更新:需要对 adminDB 的读取权限和写入权限

于 2019-05-19T20:47:49.497 回答