To use multiple anchor peers, you need to configure it with configtx.yaml. You should add new anchor peers as shown
below:
Organizations:
- &Org1
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org1MSP
# ID to load the MSP definition as
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.example.com/msp
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.org1.example.com
Port: 7051
- Host: peer1.org1.example.com
Port: 7051
- &Org2
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org2MSP
# ID to load the MSP definition as
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/org2.example.com/msp
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.org2.example.com
Port: 7051
- Host: peer1.org2.example.com
Port: 7051
The above code will define two anchor peers in each organization. Now, you have to use configtxgen to produce config update by using the following:
configtxgen -profile TwoOrgsChannel -channelID mychannel -outputAnchorPeersUpdate=Org1MSPanchors.tx -asOrg=Org1MSP
configtxgen -profile TwoOrgsChannel -channelID mychannel -outputAnchorPeersUpdate=Org2MSPanchors.tx -asOrg=Org2MSP
Now run the following code to update your channel:
# updating anchors for Org1
CORE_PEER_ADDRESS=peer0.org.example.com peer channel update -f Org1MSPanchors.tx -c mychannel -o orderer.example.com:7050