CORDA公证节点创建方法及多节点配置方案咨询
Hey there! Let's break down your questions about setting up Corda notary nodes clearly:
Is the config you provided the only necessary step?
The snippet you shared is a core part of defining a notary node, but it’s not the only required step to get a working notary. Let’s break down what each line does, plus what’s missing:
First, your existing config:
name "O=NetworkMapAndNotary,L=London,C=GB": Sets the node’s X.500 identity, which is mandatory for all Corda nodes (notaries included) to establish trust.notary = [validating : true]: This is the critical line that marks the node as a validating notary (set tofalsefor a non-validating one). Without this, the node won’t function as a notary.p2pPort 10002: Assigns a unique P2P port for node-to-node communication (prevents port conflicts).cordapps = []: Notaries typically don’t need business-specific CordApps, so an empty list is fine here.
Missing necessary steps:
- Corda Gradle Plugins: Your project must include the Corda node plugin in the root
build.gradleto enable thedeployNodestask. Example snippet:
buildscript { repositories { mavenCentral() maven { url 'https://software.r3.com/artifactory/corda-releases' } } dependencies { classpath "net.corda.plugins:node:${corda_version}" // Replace with your Corda version } }
- Generate & Start the Node: After configuring
deployNodes, run./gradlew deployNodes(orgradlew.bat deployNodeson Windows) to generate the node’s directory structure. Then navigate to the generated node folder and runrun.sh/run.batto start the node.
How to configure multiple notary nodes
Corda supports multiple notaries for fault tolerance or partitioned workflows. Here’s how to set them up and connect them:
1. Add multiple node blocks in deployNodes
Each notary needs its own configuration block with unique ports and identity. Example:
deployNodes { // First validating notary node { name "O=Notary1,L=London,C=GB" notary = [validating: true] p2pPort 10002 rpcSettings { address("localhost:10003") adminAddress("localhost:10043") } cordapps = [] } // Second non-validating notary node { name "O=Notary2,L=New York,C=US" notary = [validating: false] p2pPort 10005 rpcSettings { address("localhost:10006") adminAddress("localhost:10046") } cordapps = [] } // Add your business nodes here... }
⚠️ Important: Ensure all p2pPort, rpcSettings.address, and adminAddress values are unique across nodes to avoid port conflicts.
2. Connect notaries to the Network Map
Corda uses a Network Map service to track all nodes in the network. When you run deployNodes, it automatically creates a Network Map node (if not explicitly defined) and registers all nodes (including notaries) to it.
For manual distributed deployments, each notary’s node.conf needs to reference the Network Map service:
networkMapService { address = "localhost:10002" // Replace with your Network Map's P2P address legalName = "O=NetworkMapService,L=London,C=GB" }
This ensures other nodes in the network can discover and use the notaries.
3. Select a notary in your flows
When building transactions, your business flows can specify which notary to use. You can either look up available notaries or target a specific one by its X.500 name:
// Fetch a specific notary by name val targetNotary = serviceHub.networkMapCache.getNotary(CordaX500Name.parse("O=Notary1,L=London,C=GB")) // Build transaction with the selected notary val txBuilder = TransactionBuilder(targetNotary)
Quick Tips
- Validating notaries check transaction validity (contract rules, signatures), while non-validating ones only timestamp transactions—choose based on your security needs.
- In production, deploy each notary on a separate server for high availability.
- Multiple notaries don’t need explicit syncing; the Network Map service maintains their state for the network.
内容的提问来源于stack exchange,提问作者Mahesh Govind

