Corda节点无法连接到外部DB-K8S

时间:2020-06-30 13:17:14

标签: postgresql containers corda

使用k8s部署Corda网络时遇到的问题。Node无法连接到外部DB。 数据库容器已启动并正在运行。下面是配置

Node.conf

dataSourceProperties  {
        dataSourceClassName = "org.postgresql.ds.PGSimpleDataSource"
        dataSource  {
                url = "jdbc:postgresql://xx.xx.xx.xx:5432/notarydb"
                user = user1
                password = "test"
        }
}

database {
    transactionIsolationLevel=READ_COMMITTED
    initialiseSchema=true
    runMigration=true
}

错误

[ERROR] 17:56:26+0530 [main] postgresql.Driver. - Connection error:  [errorCode=zmhrwq, moreInformationAt=https://errors.corda.net/ENT/4.4/zmhrwq]
[ERROR] 17:56:26+0530 [main] common.BaseDataSource. - Failed to create a Non-Pooling DataSource from PostgreSQL JDBC Driver 42.1.4 for admin at jdbc:postgresql://1xx.xx.xx.xx:5432/notarydb?prepareThreshold=5&preparedStatementCacheQueries=256&preparedStatementCacheSizeMiB=5&databaseMetadataCacheFields=65536&databaseMetadataCacheFieldsMiB=5&defaultRowFetchSize=0&binaryTransfer=true&readOnly=false&binaryTransferEnable=&binaryTransferDisable=&unknownLength=2147483647&logUnclosedConnections=false&disableColumnSanitiser=false&tcpKeepAlive=false&loginTimeout=30&connectTimeout=10&socketTimeout=0&cancelSignalTimeout=10&receiveBufferSize=-1&sendBufferSize=-1&ApplicationName=PostgreSQL JDBC Driver&useSpnego=false&gsslib=auto&sspiServiceClass=POSTGRES&allowEncodingChanges=false&targetServerType=any&loadBalanceHosts=false&hostRecheckSeconds=10&preferQueryMode=extended&autosave=never&reWriteBatchedInserts=false: org.postgresql.util.PSQLException: The connection attempt failed.
[ERROR] 17:56:26+0530 [main] pool.HikariPool. - HikariPool-1 - Exception during pool initialization. [errorCode=zmhrwq, moreInformationAt=https://errors.corda.net/ENT/4.4/zmhrwq]
[ERROR] 17:56:26+0530 [main] internal.NodeStartupLogging. - Exception during node registration: Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database. [errorCode=18t70u2, moreInformationAt=https://errors.corda.net/ENT/4.4/18t70u2]
[ERROR] 17:56:26+0530 [main] internal.NodeStartupLogging. - Could not connect to the database. Please check your JDBC connection URL, or the connectivity to the database.

2 个答案:

答案 0 :(得分:0)

以下内容已经讨论

  1. Dinesh的团队不是掌舵人。
  2. 它们具有每种服务的直接模板。
  3. 他们的psql版本是9.6。
  4. 他们已将此部署设置在内部部署而不是云上。
  5. 他们可以远程登录数据库容器。
  6. 数据库位于集群内部。他们可以从群集进行telnet,但是需要一些时间,例如4-5秒。 (理想情况下,这应该不会花费太多时间)
  7. 他们创建了Freebird VM。所有这些都是集群的一部分,CENM服务已经能够连接到数据库容器。问题仅在于连接到节点。

很少提出建议

  1. 在与节点相同的名称空间中,部署一个busybox容器
  2. 将Kubectl exec插入该busybox实例,并使用与节点使用的IP /服务名称相同的IP /服务名称“ ping”数据库
  3. 检查来自ping的响应

他们尝试了上述建议,但仍然需要40秒左右,然后再给出sockettimeoutexception超时。 他们甚至尝试增加超时时间,例如jdbc:postgresql://10.96.0.50:5432 / partyadb?loginTimeout = 60000&connectTimeout = 60000&socketTimeout = 60000&cancelSignalTimeout = 1200,但还是没有运气。

我们的结论

如果仅需要4-5秒钟即可与VM通信-corda将永远无法正常工作。 这是他们Kubernetes部署的问题,我们无能为力。如果要花费40秒的时间来ping,则与corda无关。

答案 1 :(得分:0)

  1. 部署节点数据库并为每个参与者运行迁移脚本(tools-database-manager-4.4.jar)
  2. 为数据库使用群集IP,这为所有参与者提供了使用标准端口的自由
  3. 确保在具有不同群集IP或两者的组合的同一VM上没有运行两个Pod。

在我们的例子中,我们在同一台VM上运行corda节点和DB,节点使用NodePort,而DB使用ClusterIP。这是混合设置,其中由于NodePort和ClusterIP的混合,集群中的容器需要时间来定位地址