Merge pull request #1 from yeasy/master

Update from origin
pull/3/head
Chang CHEN 2016-08-04 14:31:26 +08:00 committed by GitHub
commit 955a48b597
10 changed files with 329 additions and 78 deletions

View File

@ -29,26 +29,9 @@ docker-compose scale es=3
A simple haproxy and web applications cluster.
## [hyperledger](hyperledger)
Quickly bootup a hyperledger cluster with several validator nodes, without vagrant or any local configuration.
Quickly bootup a hyperledger cluster with several validator nodes, without vagrant or any manual configuration. By default, the cluster enables PBFT as the consensus.
Note, currently you should manually create an `openblockchain/baseimage:latest` first. The
easiest way to do so is:
```sh
$ docker pull yeasy/hyperledger:latest
$ docker tag yeasy/hyperledger:latest openblockchain/baseimage:latest
$ docker pull yeasy/hyperledger-peer:latest
$ docker pull yeasy/hyperledger-membersrvc:latest
```
Then you can start a 4 nodes hyperledger cluster with
```sh
$ docker-compose up
```
After the cluster is synced, you can validate by deploying, invoking or querying chaincode from the container or from the
host. See [hyperledger-peer](https://github .com/yeasy/docker-hyperledger-peer) if you've not familiar on that.
This refers the example from the [hyperledger](https://github.com/hyperledger/fabric/tree/master/consensus/docker-compose-files) project.
See [hyperledger](hyperledger) for more details.
## [mongo_cluster](mongo_cluster)
Start 3 mongo instance to make a replica set.

View File

@ -0,0 +1,39 @@
# Hyperledger fabric
You can use the following script to install docker and start PBFT cluster in one instruction.
```sh
$ bash setupPbft.sh
```
If you want to start it manually, follow the steps:
First, pull an `openblockchain/baseimage:latest` first.
```sh
$ docker pull yeasy/hyperledger:latest && docker tag yeasy/hyperledger:latest hyperledger/fabric-baseimage:latest
$ docker pull yeasy/hyperledger-peer:latest
$ docker pull yeasy/hyperledger-membersrvc:latest
```
Then go into the specific consensus directory, then you can start a 4 nodes hyperledger cluster.
E.g., for pbft consensus, use
```sh
$ cd pbft; docker-compose up
```
After the cluster is synced, you can validate by deploying, invoking or querying chaincode from the container or from the host.
See [hyperledger-peer](https://github.com/yeasy/docker-hyperledger-peer) if you've not familiar on that.
This refers the example from the [hyperledger](https://github.com/hyperledger/fabric/tree/master/consensus/docker-compose-files) project.
## noops
Use the noops as consensus, i.e., no consensus.
## pbft
Use pbft as consensus.

View File

@ -0,0 +1,22 @@
# This compose file will start a cluster with 4 hyperledger peer nodes
# vp0: validating node as root
# vp1: validating node as peer
# vp2: validating node as peer
# vp3: validating node as peer
# https://github.com/yeasy/docker-compose-files
# validating node as the root
# vp0 will also be used for client interactive operations
# If you want to run fabric command on the host, then map 7051:7051 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr.
vp0:
extends:
file: peer-noops.yml
service: vp
hostname: vp0
environment:
- CORE_PEER_ID=vp0
ports:
- "7050:7050"
#- "7051:7051"

View File

@ -5,10 +5,22 @@
# vp3: validating node as peer
# https://github.com/yeasy/docker-compose-files
membersrvc:
image: yeasy/hyperledger-membersrvc:latest
restart: unless-stopped
expose:
- "7054"
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
command: membersrvc # this repeats the default cmd to make sure
# validating node as the root
# vp0 will also be used for client interactive operations
# If you want to run fabric command on the host, then map 7051:7051 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr.
vp0:
extends:
file: compose-defaults.yml
file: peer-noops.yml
service: vp
hostname: vp0
environment:
@ -16,79 +28,65 @@ vp0:
- CORE_SECURITY_ENABLED=true
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
- CORE_PEER_PKI_ECA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
ports:
- "7050:7050"
#- "7051:7051"
links:
- membersrvc
vp1:
extends:
file: compose-defaults.yml
file: peer-noops.yml
service: vp
hostname: vp1
environment:
- CORE_PEER_ID=vp1
- CORE_SECURITY_ENABLED=true
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:30303
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_SECURITY_ENROLLID=test_vp1
- CORE_SECURITY_ENROLLSECRET=5wgHK9qqYaPy
- CORE_PEER_PKI_ECA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
links:
- membersrvc
- vp0
vp2:
extends:
file: compose-defaults.yml
file: peer-noops.yml
service: vp
hostname: vp2
environment:
- CORE_PEER_ID=vp2
- CORE_SECURITY_ENABLED=true
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:30303
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_SECURITY_ENROLLID=test_vp2
- CORE_SECURITY_ENROLLSECRET=vQelbRvja7cJ
- CORE_PEER_PKI_ECA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
links:
- membersrvc
- vp0
# vp3 will be used for client interactive operations
# If you want to run fabric command on the host, then map 30303:30303 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:30303` to specify peer addr.
vp3:
extends:
file: compose-defaults.yml
file: peer-noops.yml
service: vp
hostname: vp3
environment:
- CORE_PEER_ID=vp3
- CORE_SECURITY_ENABLED=true
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:30303
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_SECURITY_ENROLLID=test_vp3
- CORE_SECURITY_ENROLLSECRET=9LKqKH5peurL
- CORE_PEER_PKI_ECA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:50051
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
links:
- membersrvc
- vp0
ports:
- "5000:5000"
#- "30303:30303"
membersrvc:
image: yeasy/hyperledger-membersrvc:latest
restart: unless-stopped
expose:
- "50051"
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
command: membersrvc

View File

@ -0,0 +1,58 @@
# This compose file will start a cluster with 4 hyperledger peer nodes
# vp0: validating node as root
# vp1: validating node as peer
# vp2: validating node as peer
# vp3: validating node as peer
# https://github.com/yeasy/docker-compose-files
# validating node as the root
# vp0 will also be used for client interactive operations
# If you want to run fabric command on the host, then map 7051:7051 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr.
vp0:
extends:
file: peer-noops.yml
service: vp
hostname: vp0
environment:
- CORE_PEER_ID=vp0
ports:
- "7050:7050"
#- "7051:7051"
# validating node
vp1:
extends:
file: peer-noops.yml
service: vp
hostname: vp1
environment:
- CORE_PEER_ID=vp1
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
# validating node
vp2:
extends:
file: peer-noops.yml
service: vp
hostname: vp2
environment:
- CORE_PEER_ID=vp2
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
# validating node
vp3:
extends:
file: peer-noops.yml
service: vp
hostname: vp3
environment:
- CORE_PEER_ID=vp3
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0

View File

@ -2,29 +2,26 @@
# Notice that chaincode is executed inside docker in default net mode
# https://github.com/yeasy/docker-compose-files
# Depends on the yeasy/hyperledger-peer:pbft image
# Depends on the yeasy/hyperledger-peer:noops image
# If you want enable consensus, just uncomment the
# CORE_PEER_VALIDATOR_CONSENSUE=obcpbft line
# This utilizes the noops as consensus
# See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/devnet-setup.md#using-consensus-plugin for more details.
vp:
image: yeasy/hyperledger-peer:pbft
image: yeasy/hyperledger-peer:latest
restart: unless-stopped
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_NETWORKID=dev
- CORE_LOGGING_LEVEL=debug #critical, error, warning, notice, info, debug
- CORE_LOGGING_LEVEL=info #critical, error, warning, notice, info, debug
# The following section enables pbft consensus
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft # noops, obcpbft, pbft
- CORE_PBFT_GENERAL_MODE=classic # batch, classic, sieve
- CORE_PBFT_GENERAL_N=4
- CORE_PBFT_GENERAL_TIMEOUT_REQUEST=10s
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=noops # noops, pbft
- CORE_NOOPS_BLOCK_TIMEOUT=2s
- CORE_NOOPS_BLOCK_WAIT=2s
expose:
- "30303"
- "30304"
- "31315"
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
command: peer peer
command: peer node start # this repeats the default cmd to make sure

View File

@ -0,0 +1,96 @@
# This compose file will 4 hyperledger peer nodes + 1 CA node for testing
# Suggest add a delay to start VP nodes before CA:
# command: sh -c "sleep 5; peer node start"
#
# vp0: validating node as root
# vp1: validating node as peer
# vp2: validating node as peer
# vp3: validating node as peer
# https://github.com/yeasy/docker-compose-files
# validating node as the root
vp0:
extends:
file: peer-pbft.yml
service: vp
hostname: vp0
environment:
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENABLED=true
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
ports:
- "7050:7050"
#- "7051:7051"
links:
- membersrvc
vp1:
extends:
file: peer-pbft.yml
service: vp
hostname: vp1
environment:
- CORE_PEER_ID=vp1
- CORE_SECURITY_ENABLED=true
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_SECURITY_ENROLLID=test_vp1
- CORE_SECURITY_ENROLLSECRET=5wgHK9qqYaPy
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
links:
- membersrvc
- vp0
vp2:
extends:
file: peer-pbft.yml
service: vp
hostname: vp2
environment:
- CORE_PEER_ID=vp2
- CORE_SECURITY_ENABLED=true
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_SECURITY_ENROLLID=test_vp2
- CORE_SECURITY_ENROLLSECRET=vQelbRvja7cJ
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
links:
- membersrvc
- vp0
# vp3 will be used for client interactive operations
# If you want to run fabric command on the host, then map 7051:7051 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr.
vp3:
extends:
file: peer-pbft.yml
service: vp
hostname: vp3
environment:
- CORE_PEER_ID=vp3
- CORE_SECURITY_ENABLED=true
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_SECURITY_ENROLLID=test_vp3
- CORE_SECURITY_ENROLLSECRET=9LKqKH5peurL
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
links:
- membersrvc
- vp0
membersrvc:
image: yeasy/hyperledger-membersrvc:latest
restart: unless-stopped
expose:
- "7054"
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
command: membersrvc # this repeats the default cmd to make sure

View File

@ -8,51 +8,51 @@
# validating node as the root
vp0:
extends:
file: compose-defaults.yml
file: peer-pbft.yml
service: vp
hostname: vp0
environment:
- CORE_PEER_ID=vp0
ports:
- "7050:7050"
#- "7051:7051"
# validating node
vp1:
extends:
file: compose-defaults.yml
file: peer-pbft.yml
service: vp
hostname: vp1
environment:
- CORE_PEER_ID=vp1
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:30303
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
# validating node
vp2:
extends:
file: compose-defaults.yml
file: peer-pbft.yml
service: vp
hostname: vp2
environment:
- CORE_PEER_ID=vp2
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:30303
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
# validating node
# vp3 will also be used for client interactive operations
# If you want to run fabric command on the host, then map 30303:30303 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:30303` to specify peer addr.
# If you want to run fabric command on the host, then map 7051:7051 to host
# port, or use like `CORE_PEER_ADDRESS=172.17.0.2:7051` to specify peer addr.
vp3:
extends:
file: compose-defaults.yml
file: peer-pbft.yml
service: vp
hostname: vp3
environment:
- CORE_PEER_ID=vp3
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:30303
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
ports:
- "5000:5000"
#- "30303:30303"

View File

@ -0,0 +1,30 @@
# This is the default base file to config env and command
# Notice that chaincode is executed inside docker in default net mode
# https://github.com/yeasy/docker-compose-files
# Depends on the yeasy/hyperledger-peer:pbft image
# This utilized the pbft as consensus
# See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/devnet-setup.md#using-consensus-plugin for more details.
vp:
image: yeasy/hyperledger-peer:latest
restart: unless-stopped
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_NETWORKID=dev
- CORE_LOGGING_LEVEL=info #critical, error, warning, notice, info, debug
# The following section enables pbft consensus
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft # noops, pbft
- CORE_PBFT_GENERAL_MODE=batch # batch. classic and sieve will be not supported again.
- CORE_PBFT_GENERAL_N=4
- CORE_PBFT_GENERAL_BATCHSIZE=2 # only useful when in batch mode
- CORE_PBFT_GENERAL_TIMEOUT_REQUEST=2s
expose:
- "7051"
- "7052"
- "7053"
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
command: peer node start # this repeats the default cmd to make sure
# command: sh -c "sleep 5; peer node start" # user this with CA

View File

@ -0,0 +1,28 @@
#! /bin/bash
if [ xroot != x$(whoami) ]
then
echo "You must run as root (Hint: sudo su)"
exit
fi
apt-get install curl -y
wget -qO- https://get.docker.com/ | sh
sudo service docker stop
nohup sudo docker daemon --api-cors-header="*" -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock&
curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
docker pull yeasy/hyperledger:latest && docker tag yeasy/hyperledger:latest hyperledger/fabric-baseimage:latest
docker pull yeasy/hyperledger-peer:latest
docker pull yeasy/hyperledger-membersrvc:latest
cd pbft
docker-compose up
#test: curl HOST:5000/network/peers