mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
FAB-12762 Add etcd/raft consensus option to BYFN
Augment the fabric-samples first-network sample to include an option to choose etcd/raft as consensus-type. Extend the -o flag so that it allows users to choose between the solo, kafka, or etcdraft consensus-type for the ordering service. Use three orderer nodes. Change-Id: Ibc4c3564220466aef0a87baee4a2d594e5554a62 Signed-off-by: Yoav Tock <tock@il.ibm.com>
This commit is contained in:
parent
026aa9ec01
commit
83fe6c32df
7 changed files with 144 additions and 27 deletions
|
|
@ -9,28 +9,14 @@ services:
|
|||
|
||||
orderer.example.com:
|
||||
container_name: orderer.example.com
|
||||
image: hyperledger/fabric-orderer:$IMAGE_TAG
|
||||
environment:
|
||||
- FABRIC_LOGGING_SPEC=INFO
|
||||
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
|
||||
- ORDERER_GENERAL_GENESISMETHOD=file
|
||||
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
|
||||
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
|
||||
# enabled TLS
|
||||
- ORDERER_GENERAL_TLS_ENABLED=true
|
||||
- ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
|
||||
- ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
|
||||
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
|
||||
- ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1
|
||||
- ORDERER_KAFKA_VERBOSE=true
|
||||
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
|
||||
command: orderer
|
||||
extends:
|
||||
file: peer-base.yaml
|
||||
service: orderer-base
|
||||
volumes:
|
||||
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
|
||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
|
||||
- orderer.example.com:/var/hyperledger/production/orderer
|
||||
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
|
||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
|
||||
- orderer.example.com:/var/hyperledger/production/orderer
|
||||
ports:
|
||||
- 7050:7050
|
||||
|
||||
|
|
|
|||
|
|
@ -25,3 +25,26 @@ services:
|
|||
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
|
||||
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
|
||||
command: peer node start
|
||||
|
||||
orderer-base:
|
||||
image: hyperledger/fabric-orderer:$IMAGE_TAG
|
||||
environment:
|
||||
- FABRIC_LOGGING_SPEC=INFO
|
||||
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
|
||||
- ORDERER_GENERAL_GENESISMETHOD=file
|
||||
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
|
||||
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
|
||||
# enabled TLS
|
||||
- ORDERER_GENERAL_TLS_ENABLED=true
|
||||
- ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
|
||||
- ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
|
||||
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
|
||||
- ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1
|
||||
- ORDERER_KAFKA_VERBOSE=true
|
||||
- ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
|
||||
- ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
|
||||
- ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
|
||||
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
|
||||
command: orderer
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ function printHelp() {
|
|||
echo " -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)"
|
||||
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
|
||||
echo " -l <language> - the chaincode language: golang (default) or node"
|
||||
echo " -o <consensus-type> - the consensus-type of the ordering service: solo (default) or kafka"
|
||||
echo " -o <consensus-type> - the consensus-type of the ordering service: solo (default), kafka, or etcdraft"
|
||||
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
|
||||
echo " -v - verbose mode"
|
||||
echo " byfn.sh -h (print this message)"
|
||||
|
|
@ -159,12 +159,16 @@ function networkUp() {
|
|||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||
else
|
||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||
fi
|
||||
else
|
||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA up -d 2>&1
|
||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 up -d 2>&1
|
||||
else
|
||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||
fi
|
||||
|
|
@ -176,10 +180,16 @@ function networkUp() {
|
|||
|
||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||
sleep 1
|
||||
echo "Sleeping 10s to allow kafka cluster to complete booting"
|
||||
echo "Sleeping 10s to allow $CONSENSUS_TYPE cluster to complete booting"
|
||||
sleep 9
|
||||
fi
|
||||
|
||||
if [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||
sleep 1
|
||||
echo "Sleeping 15s to allow $CONSENSUS_TYPE cluster to complete booting"
|
||||
sleep 14
|
||||
fi
|
||||
|
||||
# now run the end to end script
|
||||
docker exec cli scripts/script.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE
|
||||
if [ $? -ne 0 ]; then
|
||||
|
|
@ -208,12 +218,16 @@ function upgradeNetwork() {
|
|||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH"
|
||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH"
|
||||
else
|
||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH"
|
||||
fi
|
||||
else
|
||||
if [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA"
|
||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2"
|
||||
else
|
||||
COMPOSE_FILES="-f $COMPOSE_FILE"
|
||||
fi
|
||||
|
|
@ -263,7 +277,7 @@ function upgradeNetwork() {
|
|||
function networkDown() {
|
||||
# stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3
|
||||
# stop kafka and zookeeper containers in case we're running with kafka consensus-type
|
||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans
|
||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans
|
||||
|
||||
# Don't remove the generated artifacts -- note, the ledgers are always removed
|
||||
if [ "$MODE" != "restart" ]; then
|
||||
|
|
@ -413,6 +427,8 @@ function generateChannelArtifacts() {
|
|||
configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
|
||||
elif [ "$CONSENSUS_TYPE" == "kafka" ]; then
|
||||
configtxgen -profile SampleDevModeKafka -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
|
||||
elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then
|
||||
configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
|
||||
else
|
||||
set +x
|
||||
echo "unrecognized CONSESUS_TYPE='$CONSENSUS_TYPE'. exiting"
|
||||
|
|
@ -484,6 +500,8 @@ COMPOSE_FILE_COUCH=docker-compose-couch.yaml
|
|||
COMPOSE_FILE_ORG3=docker-compose-org3.yaml
|
||||
# kafka and zookeeper compose file
|
||||
COMPOSE_FILE_KAFKA=docker-compose-kafka.yaml
|
||||
# two additional etcd/raft orderers
|
||||
COMPOSE_FILE_RAFT2=docker-compose-etcdraft2.yaml
|
||||
#
|
||||
# use golang as the default language for chaincode
|
||||
LANGUAGE=golang
|
||||
|
|
@ -540,7 +558,7 @@ while getopts "h?c:t:d:f:s:l:i:o:v" opt; do
|
|||
i)
|
||||
IMAGETAG=$(go env GOARCH)"-"$OPTARG
|
||||
;;
|
||||
o)
|
||||
o)
|
||||
CONSENSUS_TYPE=$OPTARG
|
||||
;;
|
||||
v)
|
||||
|
|
|
|||
|
|
@ -314,6 +314,7 @@ Profiles:
|
|||
- *Org2
|
||||
TwoOrgsChannel:
|
||||
Consortium: SampleConsortium
|
||||
<<: *ChannelDefaults
|
||||
Application:
|
||||
<<: *ApplicationDefaults
|
||||
Organizations:
|
||||
|
|
@ -345,4 +346,44 @@ Profiles:
|
|||
SampleConsortium:
|
||||
Organizations:
|
||||
- *Org1
|
||||
- *Org2
|
||||
- *Org2
|
||||
|
||||
SampleMultiNodeEtcdRaft:
|
||||
<<: *ChannelDefaults
|
||||
Capabilities:
|
||||
<<: *ChannelCapabilities
|
||||
Orderer:
|
||||
<<: *OrdererDefaults
|
||||
OrdererType: etcdraft
|
||||
EtcdRaft:
|
||||
Consenters:
|
||||
- Host: orderer.example.com
|
||||
Port: 7050
|
||||
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
|
||||
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
|
||||
- Host: orderer2.example.com
|
||||
Port: 7050
|
||||
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
|
||||
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
|
||||
- Host: orderer3.example.com
|
||||
Port: 7050
|
||||
ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
|
||||
ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
|
||||
Addresses:
|
||||
- orderer.example.com:7050
|
||||
- orderer2.example.com:7050
|
||||
- orderer3.example.com:7050
|
||||
|
||||
Organizations:
|
||||
- *OrdererOrg
|
||||
Capabilities:
|
||||
<<: *OrdererCapabilities
|
||||
Application:
|
||||
<<: *ApplicationDefaults
|
||||
Organizations:
|
||||
- <<: *OrdererOrg
|
||||
Consortiums:
|
||||
SampleConsortium:
|
||||
Organizations:
|
||||
- *Org1
|
||||
- *Org2
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ OrdererOrgs:
|
|||
# ---------------------------------------------------------------------------
|
||||
Specs:
|
||||
- Hostname: orderer
|
||||
- Hostname: orderer2
|
||||
- Hostname: orderer3
|
||||
# ---------------------------------------------------------------------------
|
||||
# "PeerOrgs" - Definition of organizations managing peer nodes
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
45
first-network/docker-compose-etcdraft2.yaml
Normal file
45
first-network/docker-compose-etcdraft2.yaml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright IBM Corp. All Rights Reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
version: '2'
|
||||
|
||||
volumes:
|
||||
orderer2.example.com:
|
||||
orderer3.example.com:
|
||||
|
||||
networks:
|
||||
byfn:
|
||||
|
||||
services:
|
||||
|
||||
orderer2.example.com:
|
||||
extends:
|
||||
file: base/peer-base.yaml
|
||||
service: orderer-base
|
||||
container_name: orderer2.example.com
|
||||
networks:
|
||||
- byfn
|
||||
volumes:
|
||||
- ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp:/var/hyperledger/orderer/msp
|
||||
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/:/var/hyperledger/orderer/tls
|
||||
- orderer2.example.com:/var/hyperledger/production/orderer
|
||||
ports:
|
||||
- 8050:7050
|
||||
|
||||
orderer3.example.com:
|
||||
extends:
|
||||
file: base/peer-base.yaml
|
||||
service: orderer-base
|
||||
container_name: orderer3.example.com
|
||||
networks:
|
||||
- byfn
|
||||
volumes:
|
||||
- ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/msp:/var/hyperledger/orderer/msp
|
||||
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/:/var/hyperledger/orderer/tls
|
||||
- orderer3.example.com:/var/hyperledger/production/orderer
|
||||
ports:
|
||||
- 9050:7050
|
||||
|
|
@ -136,7 +136,7 @@ function networkUp () {
|
|||
|
||||
# Tear down running network
|
||||
function networkDown () {
|
||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes --remove-orphans
|
||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes --remove-orphans
|
||||
# Don't remove containers, images, etc if restarting
|
||||
if [ "$MODE" != "restart" ]; then
|
||||
#Cleanup the chaincode containers
|
||||
|
|
@ -247,6 +247,8 @@ COMPOSE_FILE_ORG3=docker-compose-org3.yaml
|
|||
COMPOSE_FILE_COUCH_ORG3=docker-compose-couch-org3.yaml
|
||||
# kafka and zookeeper compose file
|
||||
COMPOSE_FILE_KAFKA=docker-compose-kafka.yaml
|
||||
# two additional etcd/raft orderers
|
||||
COMPOSE_FILE_RAFT2=docker-compose-etcdraft2.yaml
|
||||
# use golang as the default language for chaincode
|
||||
LANGUAGE=golang
|
||||
# default image tag
|
||||
|
|
|
|||
Loading…
Reference in a new issue