Docker中的Corda OutOfMemoryError:Java堆空间

时间:2019-07-09 15:49:57

标签: docker docker-compose corda

当我使用docker-compose启动Docker容器时,出现以下错误:

partyb     | Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
partyb     |    at java.util.Arrays.copyOf(Arrays.java:3236)
partyb     |    at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:191)
partyb     |    at kotlin.io.ByteStreamsKt.readBytes(IOStreams.kt:123)
partyb     |    at kotlin.io.ByteStreamsKt.readBytes$default(IOStreams.kt:120)
partyb     |    at net.corda.core.internal.InternalUtils.readFully(InternalUtils.kt:122)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader.getJarHash(JarScanningCordappLoader.kt:224)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader.toCordapp(JarScanningCordappLoader.kt:151)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader.loadCordapps(JarScanningCordappLoader.kt:104)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader.access$loadCordapps(JarScanningCordappLoader.kt:42)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader$cordapps$2.invoke(JarScanningCordappLoader.kt:54)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader$cordapps$2.invoke(JarScanningCordappLoader.kt:42)
partyb     |    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
partyb     |    at net.corda.node.internal.cordapp.JarScanningCordappLoader.getCordapps(JarScanningCordappLoader.kt)
partyb     |    at net.corda.node.internal.cordapp.CordappLoaderTemplate$cordappSchemas$2.invoke(JarScanningCordappLoader.kt:400)
partyb     |    at net.corda.node.internal.cordapp.CordappLoaderTemplate$cordappSchemas$2.invoke(JarScanningCordappLoader.kt:386)
partyb     |    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
partyb     |    at net.corda.node.internal.cordapp.CordappLoaderTemplate.getCordappSchemas(JarScanningCordappLoader.kt)
partyb     |    at net.corda.node.internal.AbstractNode.<init>(AbstractNode.kt:153)
partyb     |    at net.corda.node.internal.AbstractNode.<init>(AbstractNode.kt:126)
partyb     |    at net.corda.node.internal.Node.<init>(Node.kt:97)
partyb     |    at net.corda.node.internal.Node.<init>(Node.kt:96)
partyb     |    at net.corda.node.internal.NodeStartup.createNode(NodeStartup.kt:170)
partyb     |    at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:162)
partyb     |    at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:117)
partyb     |    at net.corda.node.internal.NodeStartupLogging$DefaultImpls.attempt(NodeStartup.kt:450)
partyb     |    at net.corda.node.internal.NodeStartup.attempt(NodeStartup.kt:117)
partyb     |    at net.corda.node.internal.NodeStartup.initialiseAndRun(NodeStartup.kt:160)
partyb     |    at net.corda.node.internal.NodeStartupCli.runProgram(NodeStartup.kt:108)
partyb     |    at net.corda.cliutils.CordaCliWrapper.call(CordaCliWrapper.kt:184)
partyb     |    at net.corda.cliutils.CordaCliWrapper.call(CordaCliWrapper.kt:152)
partyb     |    at picocli.CommandLine.execute(CommandLine.java:1056)
partyb     |    at picocli.CommandLine.access$900(CommandLine.java:142)

(该错误显示为partyb,但对于除公证人以外的所有节点都是相同的错误)。显然我的CorDapp太大了。

我在docker容器中阅读了Java上的一些articles,并尝试相应地对其进行配置,但到目前为止仍未成功。

我尝试访问Java选项 UseCGroupMemoryLimitForHeap ,并初始化了docker swarm以使用 resources 配置,但是没有成功。

这是撰写文件,没有任何配置:

version: '3.7'
services:
  notary:
    image: corda/corda-zulu-4.0:latest
    container_name: notary
    networks:
      - corda
    volumes:
      - ./nodes/notary_node.conf:/etc/corda/node.conf
      - ./nodes/notary/certificates:/opt/corda/certificates
      - ./nodes/notary/network-parameters:/opt/corda/network-parameters
      - ./nodes/notary/additional-node-infos:/opt/corda/additional-node-infos

  partya:
    image: corda/corda-zulu-4.0:latest
    container_name: partya
    networks:
      - corda
    volumes:
      - ./nodes/partya_node.conf:/etc/corda/node.conf
      - ./nodes/partya/certificates:/opt/corda/certificates
      - ./nodes/partya/network-parameters:/opt/corda/network-parameters
      - ./build/libs/:/opt/corda/cordapps
      - ./nodes/partya/additional-node-infos:/opt/corda/additional-node-infos

  partyb:
    image: corda/corda-zulu-4.0:latest
    container_name: partyb
    networks:
      - corda
    volumes:
      - ./nodes/partyb_node.conf:/etc/corda/node.conf
      - ./nodes/partyb/certificates:/opt/corda/certificates
      - ./nodes/partyb/network-parameters:/opt/corda/network-parameters
      - ./build/libs/:/opt/corda/cordapps
      - ./nodes/partyb/additional-node-infos:/opt/corda/additional-node-infos

  oracle:
    image: corda/corda-zulu-4.0:latest
    container_name: oracle
    networks:
      - corda
    volumes:
      - ./nodes/oracle_node.conf:/etc/corda/node.conf
      - ./nodes/oracle/certificates:/opt/corda/certificates
      - ./nodes/oracle/network-parameters:/opt/corda/network-parameters
      - ./build/libs/:/opt/corda/cordapps
      - ./nodes/oracle/additional-node-infos:/opt/corda/additional-node-infos

  clientA:
    image: cordaclient:latest
    networks:
      - corda
    container_name: clientA
    environment:
      - USER=XXX
      - PASSWORD=XXX
      - NETWORK_HOST_AND_RPC_ADDRESS=XXX
    depends_on:
      - partya
    ports:
      - "8090:8080"

  clientB:
    image: cordaclient:latest
    networks:
      - corda
    container_name: clientB
    environment:
      - USER=XXX
      - PASSWORD=XXX
      - NETWORK_HOST_AND_RPC_ADDRESS=XXX
    depends_on:
      - partyb
    ports:
      - "8070:8080"

networks:
  corda:

在此先感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您的计算机有多少内存? Corda在新版本中变得越来越渴望资源。您的计算机很可能没有足够的内存。

除非,docker可能会将可用内存限制在每个节点上。在node.conf中增加堆大小或增加堆大小可能会有所帮助-https://docs.corda.net/head/corda-configuration-file.html#overriding-values-from-node-conf