You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现跨计算机部署R3 Corda节点并完成节点间通信?

Hey there! I’ve set up multi-machine Corda networks a bunch of times, so let’s walk through exactly how to get two local nodes and two remote nodes talking to each other. Here’s a step-by-step guide that should cover everything you need:

1. Prerequisites First

Make sure you have these sorted on both local and remote machines:

  • JDK 8: Corda 4.x (the most common stable version) requires this—avoid newer JDKs unless you’re using a newer Corda release.
  • Corda Distribution: Grab the Corda JAR or use the official Corda CLI tool. You can also use the Corda Node Template to speed up setup.
  • Network Access: The local and remote machines must be able to reach each other. If the remote machine is on the internet, ensure it has a public IP and you’ve port-forwarded the necessary P2P ports through its router/firewall. For local networks, just confirm they’re on the same subnet or can route to each other.
  • Firewall Rules: Open TCP ports for P2P communication (we’ll use ports starting at 10002, one per node) on both machines.
2. Generate Shared Network Parameters

All nodes in a Corda network must use identical network parameters. Do this once on your local machine:

  1. Use the Corda CLI to generate parameters:
    corda-cli network parameters generate --output config/network-parameters.json
    
  2. Copy this network-parameters.json file to the config directory of every node (both local and remote). This ensures all nodes agree on rules like minimum platform version and notary settings.
3. Set Up Your Local Nodes

Let’s create two nodes on your local machine:

  1. Duplicate the Corda Node Template folder twice, naming them local-node1 and local-node2.
  2. For each node, edit config/node.conf with these key changes:
    • Unique Legal Name: e.g., myLegalName="O=LocalNode1, L=London, C=GB" and myLegalName="O=LocalNode2, L=London, C=GB"
    • P2P Address: Use your local machine’s IP (e.g., 192.168.1.100:10002 for node1, 192.168.1.100:10003 for node2—pick unique ports)
    • RPC Settings: Assign unique ports for RPC and admin access, e.g.:
      rpcSettings {
          address="192.168.1.100:10005"
          adminAddress="192.168.1.100:10007"
      }
      
    • Network Parameters Path: Point to the shared file: networkParametersPath="config/network-parameters.json"
    • Dev Mode (for testing): Add devMode=true to skip network map server dependencies.
  3. Generate node certificates for each local node:
    cd local-node1
    java -jar corda.jar initial-registration --network-root-truststore-password trustpass
    
    Repeat this for local-node2.
4. Configure Remote Nodes

Now set up the two nodes on your remote machine:

  1. Copy the Corda Node Template twice to the remote machine, naming them remote-node1 and remote-node2.
  2. Edit config/node.conf for each remote node:
    • Unique Legal Name: e.g., myLegalName="O=RemoteNode1, L=New York, C=US" and myLegalName="O=RemoteNode2, L=New York, C=US"
    • P2P Address: Use the remote machine’s public/lan IP (e.g., 203.0.113.5:10002 for node1, 203.0.113.5:10003 for node2—ensure these ports are open in the firewall/security group)
    • RPC Settings: Assign unique ports, e.g.:
      rpcSettings {
          address="203.0.113.5:10005"
          adminAddress="203.0.113.5:10007"
      }
      
    • Network Parameters Path: Point to the copied network-parameters.json file.
    • Dev Mode: Add devMode=true.
  3. Generate certificates for each remote node, same as the local nodes.
5. Peer Discovery: Tell Nodes About Each Other

In dev mode, nodes don’t use a network map server, so you need to explicitly list all peers in each node’s node.conf. For example:

  • In local-node1’s node.conf, add:
    peers = [
        { address="192.168.1.100:10003", legalName="O=LocalNode2, L=London, C=GB" },
        { address="203.0.113.5:10002", legalName="O=RemoteNode1, L=New York, C=US" },
        { address="203.0.113.5:10003", legalName="O=RemoteNode2, L=New York, C=US" }
    ]
    
  • Repeat this for all four nodes, updating the peers list to include the other three nodes’ addresses and legal names.
6. Verify Connectivity

Before starting nodes, confirm the network works:

  • Ping the remote machine from your local machine (and vice versa) to ensure basic connectivity.
  • Test port access with nc (netcat):
    # Local machine testing remote P2P port
    nc -zv 203.0.113.5 10002
    # Remote machine testing local P2P port
    nc -zv 192.168.1.100 10002
    

If these commands succeed, your ports are open.

7. Start All Nodes
  • Local Nodes: Navigate to each node’s folder and run:
    java -jar corda.jar
    
  • Remote Nodes: Do the same on the remote machine.
    Check the logs/node.log file for each node—look for lines like Connected to peer O=RemoteNode1... to confirm successful connections.
8. Test Communication

To make sure nodes are talking:

  1. Open the Corda Shell for any node (e.g., local-node1):
    java -jar corda-shell.jar --rpc-host 192.168.1.100 --rpc-port 10005 --user admin --password admin
    
  2. Run the network map snapshot command:
    run networkMapSnapshot
    

You should see all four nodes listed in the output.

  1. For a deeper test, deploy a simple flow (like an IOU transaction) to all nodes, then initiate a flow from a local node to a remote node. Check the remote node’s vault to confirm the transaction was recorded:
    # In remote node's shell
    run vaultQuery contractStateType=com.example.IOUState
    
Troubleshooting Tips
  • Connection Refused: Double-check firewall rules and port forwarding. Ensure the remote node’s P2P port is open to your local machine’s IP.
  • Mismatched Network Parameters: All nodes must use the exact same network-parameters.json—check the hash in each node’s startup logs to confirm they match.
  • Certificate Errors: Make sure you ran the initial registration command for every node, and the network root truststore is consistent.
  • Peer Not Found: Verify the peers list in node.conf has the correct legal names and addresses (case-sensitive!).

内容的提问来源于stack exchange,提问作者Pranamika Hariprasad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:22:40