如何在多机环境下为Hyperledger Composer网络新增Peer节点
Hey there! Let's walk through how to add a new Peer node on a separate machine to your existing Hyperledger Composer blockchain network. Since you mentioned the multi-org tutorial relies on Docker, I’ll break this down into actionable steps that work whether your original setup uses Docker or not (we’ll cover both scenarios where relevant):
Step 1: Prep the New Machine’s Environment
- First, install matching versions of all required tools on the new machine—version mismatches are one of the biggest headaches here:
- Hyperledger Fabric binaries and Docker images (if using containerized peers): Use the official Fabric install script, substituting your network’s exact versions:
curl -sSL https://bit.ly/2ysbOFE | bash -s -- <fabric-version> <ca-version> <thirdparty-version> - Hyperledger Composer CLI: Install via npm with the same version as your existing network:
npm install -g composer-cli@<your-composer-version>
- Hyperledger Fabric binaries and Docker images (if using containerized peers): Use the official Fabric install script, substituting your network’s exact versions:
- Ensure the new machine can reach your existing network’s orderer and at least one peer (check firewall rules for ports 7050, 7051, and 7054).
Step 2: Configure the New Peer Node
- Copy crypto material from your existing network’s Certificate Authority (CA) to the new machine:
- Transfer the CA’s root certificate (
ca-cert.pem) to~/crypto-config/peerOrganizations/<your-org>/ca/on the new machine. - Generate a unique identity for the new peer using your existing CA:
composer identity request -c admin@<your-network-name> -u peer-new -s <peer-secret> -d peer-new
- Transfer the CA’s root certificate (
- Set up the peer configuration:
- If using Docker: Create a
docker-compose.yamlservice for the new peer, mapping ports, mounting crypto material volumes, and setting environment variables to match your existing network (e.g.,CORE_PEER_ID=peer-new.org1.example.com,CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051). - If using a native peer: Edit the
core.yamlfile to set a uniquepeer.id, pointpeer.networkIdto your network’s ID, and setpeer.gossip.bootstrapto the address of an existing peer in your network.
- If using Docker: Create a
Step 3: Join the Peer to Your Channel
- Fetch the channel genesis block from an existing peer on your network (run this on the new machine):
peer channel fetch 0 <your-channel-name>.block -o <orderer-address>:7050 -c <your-channel-name> --tls --cafile <path-to-orderer-ca-cert> - Join the new peer to the channel:
peer channel join -b <your-channel-name>.block - Verify the join was successful with:
You should see your channel listed in the output.peer channel list
Step 4: Sync the Business Network Definition
- On your original machine, package your business network if you don’t have the
.bnafile handy:composer archive create -t dir -n <path-to-your-business-network> - Copy the generated
.bnafile to the new machine, then install the business network on the new peer:composer network install -c PeerAdmin@<your-network-name> -a <your-network-name>.bna - Confirm the chaincode is installed with:
peer chaincode list --installed
Step 5: Update Your REST Server (Optional)
- If you want the new peer to be used by your existing
composer-rest-server, update your connection profile JSON file on the server machine:- Add the new peer’s address, crypto paths, and TLS settings to the profile.
- Restart the REST server with the updated profile:
composer-rest-server -c <updated-connection-profile> -n <network-name> -i <admin-username> -s <admin-secret> -N never
Quick Troubleshooting Tips
- If the peer can’t join the channel: Double-check the gossip bootstrap address and ensure firewall rules allow inbound/outbound traffic on peer ports.
- If chaincode sync fails: Reinstall the business network on the new peer and verify the chaincode container (if using Docker) is running.
- Always validate versions: Cross-check that Composer, Fabric, and CA versions are identical across all nodes in the network.
内容的提问来源于stack exchange,提问作者peterDalis. st
相关产品推荐
相关产品推荐

