如何实现跨计算机部署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:
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.
All nodes in a Corda network must use identical network parameters. Do this once on your local machine:
- Use the Corda CLI to generate parameters:
corda-cli network parameters generate --output config/network-parameters.json - Copy this
network-parameters.jsonfile to theconfigdirectory of every node (both local and remote). This ensures all nodes agree on rules like minimum platform version and notary settings.
Let’s create two nodes on your local machine:
- Duplicate the Corda Node Template folder twice, naming them
local-node1andlocal-node2. - For each node, edit
config/node.confwith these key changes:- Unique Legal Name: e.g.,
myLegalName="O=LocalNode1, L=London, C=GB"andmyLegalName="O=LocalNode2, L=London, C=GB" - P2P Address: Use your local machine’s IP (e.g.,
192.168.1.100:10002for node1,192.168.1.100:10003for 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=trueto skip network map server dependencies.
- Unique Legal Name: e.g.,
- Generate node certificates for each local node:
Repeat this forcd local-node1 java -jar corda.jar initial-registration --network-root-truststore-password trustpasslocal-node2.
Now set up the two nodes on your remote machine:
- Copy the Corda Node Template twice to the remote machine, naming them
remote-node1andremote-node2. - Edit
config/node.conffor each remote node:- Unique Legal Name: e.g.,
myLegalName="O=RemoteNode1, L=New York, C=US"andmyLegalName="O=RemoteNode2, L=New York, C=US" - P2P Address: Use the remote machine’s public/lan IP (e.g.,
203.0.113.5:10002for node1,203.0.113.5:10003for 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.jsonfile. - Dev Mode: Add
devMode=true.
- Unique Legal Name: e.g.,
- Generate certificates for each remote node, same as the local nodes.
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’snode.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
peerslist to include the other three nodes’ addresses and legal names.
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.
- Local Nodes: Navigate to each node’s folder and run:
java -jar corda.jar - Remote Nodes: Do the same on the remote machine.
Check thelogs/node.logfile for each node—look for lines likeConnected to peer O=RemoteNode1...to confirm successful connections.
To make sure nodes are talking:
- 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 - Run the network map snapshot command:
run networkMapSnapshot
You should see all four nodes listed in the output.
- 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
- 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
peerslist innode.confhas the correct legal names and addresses (case-sensitive!).
内容的提问来源于stack exchange,提问作者Pranamika Hariprasad

