Skip to content

Instantly share code, notes, and snippets.

@jorgedison
Last active February 11, 2020 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgedison/8dd63d40b891793860f1bab720b20545 to your computer and use it in GitHub Desktop.
Save jorgedison/8dd63d40b891793860f1bab720b20545 to your computer and use it in GitHub Desktop.

enter image description here

Prerequisitos

- SO Ubuntu 18.04
- Docker 18.x 
- docker-compose 1.24.x
- NodeJs 8.11.x
- Go 1.11.x

Instalacion Docker

wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/containerd.io_1.2.5-1_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce-cli_18.09.6~3-0~ubuntu-bionic_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/amd64/docker-ce_18.09.6~3-0~ubuntu-bionic_amd64.deb

sudo dpkg -i containerd.io_1.2.5-1_amd64.deb
sudo dpkg -i docker-ce-cli_18.09.6~3-0~ubuntu-bionic_amd64.deb
sudo dpkg -i docker-ce_18.09.6~3-0~ubuntu-bionic_amd64.deb

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

docker --version && docker-compose --version

cd /home
mkdir $USER/.docker
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R  
sudo chmod g+rwx "$HOME/.docker"  -R
sudo chmod 666 /var/run/docker.sock

Instalacion NodeJs

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt install nodejs

Instalación Go

sudo apt update
sudo curl -O https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
sudo tar -xvf go1.11.5.linux-amd64.tar.gz
sudo mv go /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profile
go version

cd $HOME
mkdir go
echo 'export GOPATH=$HOME/go' >> ~/.profile
source ~/.profile
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.profile
source ~/.profile

Participantes

Organizacion 1 org1.midominio.com
Organizacion 2 org2.midominio.com
Organizacion 3 org3.midominio.com

Nodos

Nodo de Organizacion 1:
 - peer.org1.midominio.com
Nodo de Organizacion 2:
 - peer.org2.midominio.com
Nodo de Organizacion 3:
 - peer.org3.midominio.com

Canales

Un solo canal, **marketplace**, para las transacciones de los 03 participantes

Hyperledger Fabric

curl -sSL  http://bit.ly/2ysbOFE | bash -s  1.4.4

enter image description here

Configuración binarios hyperledger fabric

echo 'export PATH=$PATH:$HOME/fabric-samples/bin' >> ~/.profile
source ~/.profile

Variables globales

export CHANNEL_NAME=marketplace
export VERBOSE=false
export FABRIC_CFG_PATH=$PWD

Nodos, Orderer, Certificados, Bloque génesis

wget https://gist.githubusercontent.com/jorgedison/1db47ed466bfcd918f76113c38d5bb4e/raw/1c31b397e7274ee47f95b4d652cf658d06eca3fc/crypto-config.yaml
cryptogen generate --config=./crypto-config.yaml
wget https://gist.githubusercontent.com/jorgedison/68224357eaf95c7217e99393e33fab57/raw/e424b97d4c7ffbebde330fc4db8ee3aa038a6f52/configtx.yaml

mkdir channel-artifacts

configtxgen -profile ThreeOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

configtxgen -profile ThreeOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

configtxgen -profile ThreeOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP

configtxgen -profile ThreeOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

configtxgen -profile ThreeOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org3MSP

Inspección de archivos

configtxgen --inspectChannelCreateTx ./channel-artifacts/channel.tx >> ./channel-artifacts/channel.tx.json
configtxgen --inspectBlock ./channel-artifacts/genesis.block >> ./channel-artifacts/genesis.block.json

Inicio de Red Hyperledger Fabric

mkdir base
cd base
wget https://gist.githubusercontent.com/jorgedison/e17cde920ded96caef4f1d6b9bde53f4/raw/6ec9aa2f026a36a3443524cdad0e097168b3ebdd/docker-compose.yaml
wget https://gist.githubusercontent.com/jorgedison/415e8603d7d27f4136038d0bf2092458/raw/9b70f80c237c8efcdf757b9e6efca02d79025e25/peer-base.yaml
cd ..
wget https://gist.githubusercontent.com/jorgedison/2ff7784d2e8bea2918c004ca1b734f36/raw/2ac118581af551ed7fd62bacf295a70d9d21ea8f/docker-compose.yml

//Inicio Red
wger https://raw.githubusercontent.com/jorgedison/Prueba-Hyperledger-Fabric/master/acme-network/start.sh
//Detiene Red
wget https://raw.githubusercontent.com/jorgedison/Prueba-Hyperledger-Fabric/master/acme-network/stop.sh
Verificacion de inicio de contenedores

enter image description here

Verificacion de bases de datos couchdb de las 03 organizaciones
Organizacion 1 http://[IP]:5984/_utils
Organizacion 2 http://[IP]:5985/_utils
Organizacion 3 http://[IP]:5986/_utils

enter image description here enter image description here enter image description here

Referencia: https://github.com/hyperledger/fabric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment