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

Ubuntu虚拟机部署Corda 3+1节点及配套Spring Boot API技术咨询

Hey there! Let's walk through exactly how to deploy your 3 regular Corda nodes + 1 notary node to Ubuntu VMs, along with your Spring Boot RPC REST server. I'll break this down into actionable, step-by-step sections so you can follow along easily.

1. Pre-Deployment Prep

First, make sure your Ubuntu VMs are ready:

  • Java Version: Install the correct Java version matching your Corda release (most Corda versions use Java 8 or 11). Run sudo apt install openjdk-11-jdk (adjust version as needed) and verify with java -version.
  • Network Connectivity: Ensure all VMs can communicate with each other. Open these ports in Ubuntu's firewall (sudo ufw allow <port>/tcp):
    • Corda P2P port (default: 10002)
    • Corda RPC port (default: 10003)
    • Spring Boot port (default: 8080)
  • User Permissions: Create dedicated users for Corda and Spring Boot (e.g., corda and spring) to run services securely, instead of using root.
2. Cross-Machine Corda Node Deployment

You're already using the deployNodes Gradle task locally—here's how to take those generated nodes to your Ubuntu VMs:

Step 2.1: Generate Nodes Locally

Run the Gradle task as usual to generate all node folders:

./gradlew deployNodes

This creates a build/nodes directory containing subfolders for each node (e.g., PartyA, PartyB, PartyC, Notary).

Step 2.2: Package & Transfer Nodes to VMs

For each node:

  1. Package the node folder into a compressed archive (tar.gz works well for Linux):
    cd build/nodes
    tar -czf partya-node.tar.gz PartyA/
    
  2. Transfer the archive to your target Ubuntu VM using scp:
    scp partya-node.tar.gz corda@<vm-ip-address>:/opt/corda/nodes/
    

Repeat this for all 4 nodes, sending each to its respective VM (or same VM if you're colocating nodes—just use separate directories).

Step 2.3: Configure Nodes on Ubuntu

On each VM:

  1. Unpack the node archive:
    cd /opt/corda/nodes
    tar -xzf partya-node.tar.gz
    
  2. Edit the node.conf file (in the node's root directory) to update network settings:
    • Set the p2pAddress to the VM's public/private IP and P2P port:
      p2pAddress="192.168.1.101:10002"
      
    • Update the rpcSettings.address to the VM's IP and RPC port:
      rpcSettings {
          address="192.168.1.101:10003"
          adminAddress="192.168.1.101:10043"
      }
      
    • Set networkMapAddress to the IP/P2P port of one of your nodes (usually the node you want acting as the network map—e.g., PartyA):
      networkMapAddress="192.168.1.101:10002"
      
    • Verify the rpcUsers section matches the credentials you'll use in your Spring Boot app.

Step 2.4: Start Corda Nodes

You can start nodes directly or set them up as system services for reliability:

Option A: Manual Start (for testing)

cd /opt/corda/nodes/PartyA
nohup ./runnode &

Check logs to confirm the node started successfully:

tail -f logs/node-PartyA.log

Look for messages indicating the node connected to the network map and other peers.

Option B: Systemd Service (for production)

Create a systemd service file (e.g., /etc/systemd/system/corda-partya.service):

[Unit]
Description=Corda PartyA Node
After=network.target

[Service]
User=corda
WorkingDirectory=/opt/corda/nodes/PartyA
ExecStart=/opt/corda/nodes/PartyA/runnode
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable corda-partya
sudo systemctl start corda-partya

Repeat this for all nodes.

3. Deploy Spring Boot RPC Server

Now let's get your Spring Boot app up and running on Ubuntu:

Step 3.1: Prepare the Spring Boot JAR

Locally, build your Spring Boot project to generate an executable JAR:

./gradlew bootJar

The JAR will be in build/libs/ (e.g., corda-rpc-server-0.0.1-SNAPSHOT.jar).

Step 3.2: Transfer & Run the JAR

  1. Copy the JAR to your Ubuntu VM (can be the same VM as one of the Corda nodes or a separate VM):
    scp build/libs/corda-rpc-server-0.0.1-SNAPSHOT.jar spring@<vm-ip-address>:/opt/spring-boot/
    
  2. Run the JAR (manual test first):
    cd /opt/spring-boot
    nohup java -jar corda-rpc-server-0.0.1-SNAPSHOT.jar &
    

Check logs with tail -f nohup.out to confirm the server started and connected to the Corda node's RPC endpoint.

Step 3.3: Systemd Service for Spring Boot (production)

Create a service file (e.g., /etc/systemd/system/spring-corda-rpc.service):

[Unit]
Description=Corda Spring Boot RPC Server
After=network.target corda-partya.service

[Service]
User=spring
WorkingDirectory=/opt/spring-boot
ExecStart=/usr/bin/java -jar corda-rpc-server-0.0.1-SNAPSHOT.jar
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable spring-corda-rpc
sudo systemctl start spring-corda-rpc

Step 3.4: Optional: Reverse Proxy with Nginx

To make your Spring Boot API accessible on standard ports (e.g., 80/443), set up Nginx:

  1. Install Nginx: sudo apt install nginx
  2. Create a config file (e.g., /etc/nginx/sites-available/corda-rpc):
    server {
        listen 80;
        server_name your-domain-or-ip;
    
        location / {
            proxy_pass http://localhost:8080;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }
    
  3. Enable the site and restart Nginx:
    sudo ln -s /etc/nginx/sites-available/corda-rpc /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx
    
4. Verify Deployment
  • Check Corda Node Health: Use the Corda shell to connect to a node and verify peer connectivity:
    cd /opt/corda/nodes/PartyA
    ./cordash
    # Run command: run networkMapSnapshot
    
    You should see all 4 nodes listed.
  • Test Spring Boot API: Use curl or Postman to hit your API endpoints:
    curl http://<spring-boot-vm-ip>:8080/api/your-endpoint
    
    Confirm you get valid responses from the Corda ledger.
Key Notes
  • Version Consistency: Ensure your Spring Boot app's Corda RPC client version matches the Corda node version—mismatches cause compatibility issues.
  • Security: In production, enable SSL for Corda RPC and Spring Boot, use strong credentials for RPC users, and restrict firewall access to trusted IPs only.
  • Logging: For easier monitoring, configure both Corda nodes and Spring Boot to write logs to dedicated files (instead of nohup.out) and set up log rotation.

内容的提问来源于stack exchange,提问作者SrikanthVarma A

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:36:52