Skip to content

Commit

Permalink
[CE-78] Support fabric 1.0 start and stop
Browse files Browse the repository at this point in the history
This patchset fix the process to support starting and stopping fabric
1.0 network on docker host.

The docker-compose files and related scripts are also updated.

Change-Id: Ib87dfe965c1591b94b13e8f71b281deaa5066baf
Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
  • Loading branch information
yeasy committed Jul 5, 2017
1 parent 3a5c642 commit 274bee8
Show file tree
Hide file tree
Showing 23 changed files with 228 additions and 148 deletions.
9 changes: 9 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ $ docker pull hyperledger/fabric-peer:x86_64-0.6.1-preview \
&& docker tag hyperledger/fabric-membersrvc:x86_64-0.6.1-preview hyperledger/fabric-membersrvc
```


### Artifacts Preparation

Copy required artifacts to the `/opt/cello`, e.g.,

```bash
$ cp -r src/agent/docker/_compose_files/fabric-1.0 /opt/cello
```

### Firewall Setup
Make sure ip forward is enabled, you can simply run the follow command.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ services:
service: orderer-base
container_name: orderer.example.com
hostname: orderer.example.com
ports:
- "7050:7050"
expose:
- "7050"
volumes:
- ./channel-artifacts/orderer.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
- ${COMPOSE_PROJECT_PATH}/channel-artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block
- ${COMPOSE_PROJECT_PATH}/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
- ${COMPOSE_PROJECT_PATH}/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
command: orderer start

peer0.org1.example.com:
Expand All @@ -38,12 +38,12 @@ services:
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 7051:7051
- 7052:7052
- 7053:7053
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
expose:
- 7051
- 7052
- 7053
command: peer node start

peer1.org1.example.com:
Expand All @@ -60,12 +60,12 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 8051:7051
- 8052:7052
- 8053:7053
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
expose:
- 7051
- 7052
- 7053
command: peer node start

peer0.org2.example.com:
Expand All @@ -82,12 +82,12 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
volumes:
- ./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 9051:7051
- 9052:7052
- 9053:7053
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
expose:
- 7051
- 7052
- 7053
command: peer node start

peer1.org2.example.com:
Expand All @@ -104,10 +104,10 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
volumes:
- ./crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ./crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 10051:7051
- 10052:7052
- 10053:7053
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
expose:
- 7051
- 7052
- 7053
command: peer node start
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,45 @@ version: '2.0'
services:
ca:
image: hyperledger/fabric-ca
container_name: fabric-ca
container_name: ${COMPOSE_PROJECT_NAME}_fabric-ca
hostname: ca
# command: /go/src/github.com/hyperledger/fabric-ca/bin/ca server start -ca testdata/ec.pem -ca-key testdata/ec-key.pem -config testdata/testconfig.json
ports:
- "7054:7054"
command: fabric-ca-server start -b admin:adminpw

orderer.example.com: # There can be multiple orderers
container_name: ${COMPOSE_PROJECT_NAME}_orderer # mongo does not allow dot in name
extends:
file: docker-compose-base.yaml
service: orderer.example.com

peer0.org1.example.com:
container_name: ${COMPOSE_PROJECT_NAME}_peer0-org1
extends:
file: docker-compose-base.yaml
service: peer0.org1.example.com

peer1.org1.example.com:
container_name: ${COMPOSE_PROJECT_NAME}_peer1-org1
extends:
file: docker-compose-base.yaml
service: peer1.org1.example.com

peer0.org2.example.com:
container_name: ${COMPOSE_PROJECT_NAME}_peer0-org2
extends:
file: docker-compose-base.yaml
service: peer0.org2.example.com

peer1.org2.example.com:
container_name: ${COMPOSE_PROJECT_NAME}_peer1-org2
extends:
file: docker-compose-base.yaml
service: peer1.org2.example.com

cli:
container_name: fabric-cli
container_name: ${COMPOSE_PROJECT_NAME}_fabric-cli
hostname: fabric-cli
image: hyperledger/fabric-tools
tty: true
Expand All @@ -52,18 +57,18 @@ services:
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051 # default to operate on peer0.org1
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=true # to enable TLS, change to true
- CORE_PEER_TLS_ENABLED=false # to enable TLS, change to true
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
volumes:
#- ./e2e_cli/examples:/opt/gopath/src/github.com/hyperledger/fabric/examples
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
- ./configtx.yaml:/etc/hyperledger/fabric/configtx.yaml
- ./crypto-config.yaml:/etc/hyperledger/fabric/crypto-config.yaml
#- ${COMPOSE_PROJECT_PATH}/e2e_cli/examples:/opt/gopath/src/github.com/hyperledger/fabric/examples
- ${COMPOSE_PROJECT_PATH}/crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ${COMPOSE_PROJECT_PATH}/scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ${COMPOSE_PROJECT_PATH}/channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
#- ${COMPOSE_PROJECT_PATH}/configtx.yaml:/etc/hyperledger/fabric/configtx.yaml
#- ${COMPOSE_PROJECT_PATH}/crypto-config.yaml:/etc/hyperledger/fabric/crypto-config.yaml
depends_on:
- orderer.example.com
- peer0.org1.example.com
Expand All @@ -79,7 +84,7 @@ services:
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: bash -c 'while true; do sleep 20170504; done'

#networks:
# default:
# external:
# name: hyperledger_fabric
networks:
default:
external:
name: ${CLUSTER_NETWORK}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- ORDERER_GENERAL_LISTENPORT=7050
#- ORDERER_RAMLEDGER_HISTORY_SIZE=100 #only useful when use ram ledger
# enabled TLS
- ORDERER_GENERAL_TLS_ENABLED=true
- ORDERER_GENERAL_TLS_ENABLED=false
- 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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to false
- CORE_PEER_PROFILE_ENABLED=false
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_ENABLED=false
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ echo " ==========initialize businesschannel========== "
echo " ============================================== "
echo

if [ -f ./header.sh ]; then
source ./header.sh
elif [ -f scripts/header.sh ]; then
source scripts/header.sh
else
alias echo_r="echo"
alias echo_g="echo"
alias echo_b="echo"
fi

CHANNEL_NAME="$1"
: ${CHANNEL_NAME:="businesschannel"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/bash

if [ -f ./header.sh ]; then
source ./header.sh
elif [ -f scripts/header.sh ]; then
source scripts/header.sh
else
alias echo_r="echo"
alias echo_g="echo"
alias echo_b="echo"
fi

echo
echo " ______ __ __ _ _____ ____ _ ______ ______ ______ _____ "
Expand Down
5 changes: 3 additions & 2 deletions src/agent/docker/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from agent import compose_up, compose_clean, compose_start, compose_stop, \
compose_restart

from common import NETWORK_TYPES, CONSENSUS_PLUGINS, \
from common import NETWORK_TYPES, CONSENSUS_PLUGINS_FABRIC_V1, \
CONSENSUS_MODES, NETWORK_SIZE_FABRIC_PRE_V1

from ..cluster_base import ClusterBase
Expand Down Expand Up @@ -55,11 +55,12 @@ def create(self, cid, mapped_ports, host, user_id="",
logger.debug("Start compose project with name={}".format(cid))
containers = compose_up(name=cid, mapped_ports=mapped_ports, host=host,
network_type=network_type, config=config)
if not containers or len(containers) != config.size:
if not containers:
logger.warning("failed to create cluster, with container={}"
.format(containers))
return []
else:
logger.debug("Created containers={}".format(containers))
return containers

def delete(self, id, worker_api, network_type, config):
Expand Down
Loading

0 comments on commit 274bee8

Please sign in to comment.