Hyperledger Fabric Network Installation

by PiChain

Posted on December 15, 2018 at 12:00 PM

In the journey of the blockchain there would be a point to get our hands dirty and start playing with blockchain by installing the network ourselves.This blog will be useful for setting up a hyperledger fabric network

Prerequites
OS Platform: Ubuntu 16.04 LTS
ubuntu@ip-internal:~$ curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh % Total d Total Spent Left Speed 100 4151 100 4151 0 0 4241 0 --:--:-- --:--:-- --:--:-- 4240

ubuntu@ip-internal:~$ chmod u+x prereqs-ubuntu.sh
ubuntu@ip-internal:~$ mkdir hyperledger
ubuntu@ip-internal:~$ mv prereqs-ubuntu.sh hyperledger/
ubuntu@ip-internal:~$ cd hyperledger/ rwxrw-r-- 1 ubuntu ubuntu 4151 Apr 20 07:57 prereqs-ubuntu.sh*
ubuntu@ip-internal:~/hyperledger$ mkdir prereqs ubuntu@ip-internal:~/hyperledger$ mv prereqs-ubuntu.sh prereqs
ubuntu@ip-internal:~/hyperledger$ cd prereqs/ ubuntu@ip-internal:~/hyperledger/prereqs$ ./prereqs-ubuntu.sh
ubuntu@ip-internal:~$ sudo apt-get update && sudo apt-get dist-upgrade
        
Install Composer
ubuntu@ip-internal:~$ npm install -g composer-cli
ubuntu@ip-internal:~$ npm install -g composer-rest-server
ubuntu@ip-internal:~$ npm install -g generator-hyperledger-composer
ubuntu@ip-internal:~$ npm install -g yo
ubuntu@ip-internal:~$ npm install -g composer-playground

ubuntu@ip-internal:~$ mkdir ~/fabric-tools && cd ~/fabric-tools
        
Install Fabric Network
ubuntu@ip-internal:~$ npm install -g composer-cli
ubuntu@ip-internal:~$ npm install -g composer-rest-server
ubuntu@ip-internal:~$ npm install -g generator-hyperledger-composer
ubuntu@ip-internal:~$ npm install -g yo
ubuntu@ip-internal:~$ npm install -g composer-playground

ubuntu@ip-internal:~$ mkdir ~/fabric-tools && cd ~/fabric-tools
Install Fabric Network
ubuntu@ip-internal:~/fabric-tools$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 24036 100 24036 0 0 46262 0 --:--:-- --:--:-- --:--:-- 46223
ubuntu@ip-internal:~/fabric-tools$
ubuntu@ip-internal:~/fabric-tools$ tar -xvf fabric-dev-servers.tar.gz
package.json
_loader.sh
createComposerProfile.sh
createPeerAdminCard.sh
downloadFabric.sh
startFabric.sh


ubuntu@ip-internal:~/fabric-tools$ ./downloadFabric.sh
Development only script for Hyperledger Fabric control
Running 'downloadFabric.sh'
FABRIC_VERSION is unset, assuming hlfv11
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)
x86_64-1.1.0: Pulling from hyperledger/fabric-peer

Status: Downloaded newer image for hyperledger/fabric-couchdb:x86_64-0.4.6
ubuntu@ip-internal:~/fabric-tools$ cd ~/fabric-tools

ubuntu@ip-internal:~/fabric-tools$ tail -40 ~/fabric-scripts/hlfv11/composer/docker-compose-dev.yml
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer:$ARCH-1.1.0
environment:
- CORE_LOGGING_LEVEL=debug
- CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=composer_default
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peer/msp
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start --peer-chaincodedev=true
ports:
- 7051:7051
- 7052:7052
- 7053:7053
volumes:
- /var/run/:/host/var/run/
- ./:/etc/hyperledger/configtx
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/peer/msp
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- /var/hyperledger/peer0:/var/hyperledger/production
depends_on:
- orderer.example.com
- couchdb
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb:$ARCH-0.4.6
ports:
- 5984:5984
environment:
DB_URL: http://localhost:5984/member_db
volumes:
- /var/hyperledger/couchdb0:/opt/couchdb/data

ubuntu@ip-internal:~/fabric-tools$ ./startFabric.sh
Development only script for Hyperledger Fabric control
Running 'startFabric.sh'
FABRIC_VERSION is unset, assuming hlfv11
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)
Removing network composer_default
WARNING: Network composer_default not found.
Creating network "composer_default" with the default driver
Creating ca.org1.example.com ...
Creating couchdb ...
Creating orderer.example.com ...
Creating ca.org1.example.com
Creating couchdb
Creating orderer.example.com ... done
Creating peer0.org1.example.com ...
Creating peer0.org1.example.com ... done
sleeping for 15 seconds to wait for fabric to complete start up

.
2018-04-20 08:19:32.430 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 34CB13B87B0B0A3359F14A435D552A0A1EF996649650FF92B80607B15533D935
2018-04-20 08:19:32.559 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel
2018-04-20 08:19:32.559 UTC [main] main -> INFO 007 Exiting.....
ubuntu@ip-internal:~/fabric-tools$ ./createPeerAdminCard.sh
Development only script for Hyperledger Fabric control
Running 'createPeerAdminCard.sh'
FABRIC_VERSION is unset, assuming hlfv11
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)
Using composer-cli at v0.19.1
Successfully created business network card file to
Output file: /tmp/PeerAdmin@hlfv1.card
Command succeeded
Successfully imported business network card
Card file: /tmp/PeerAdmin@hlfv1.card
Card name: PeerAdmin@hlfv1
Command succeeded
The following Business Network Cards are available:
Connection Profile: hlfv1
┌─────────────────┬───────────┬──────────────────┐
│ Card Name │ UserId │ Business Network │
├─────────────────┼───────────┼──────────────────┤
│ PeerAdmin@hlfv1 │ PeerAdmin │ │
└─────────────────┴───────────┴──────────────────┘
Issue composer card list --card  to get details a specific card
Command succeeded
Hyperledger Composer PeerAdmin card has been imported, host of fabric specified as 'localhost'
ubuntu@ip-internal:~/fabric-tools$
        
Install Playground
ubuntu@ip-internal:~/fabric-tools$ docker run --name composer-playground --publish 8080:8080 --detach hyperledger/composer-playground
Unable to find image 'hyperledger/composer-playground:latest' locally
latest: Pulling from hyperledger/composer-playground
605ce1bd3f31: Pull complete
0511902e1bcd: Pull complete
343e34c41f87: Pull complete
5e7b838141ba: Pull complete
Digest: sha256:2047843a7164a7937463afe8cd90f3a52bacfd4920e6628411c14464adea8d40
Status: Downloaded newer image for hyperledger/composer-playground:latest
8bfea3776551005781c3c7634fdf7baf7db1a308fd18d79e15eeafc98a6d8ef1
ubuntu@ip-internal:~/fabric-tools$
ubuntu@ip-internal:~/fabric-tools$ docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}"
CONTAINER ID NAMES IMAGE
8bfea3776551 composer-playground hyperledger/composer-playground
9f07a9897fc9 peer0.org1.example.com hyperledger/fabric-peer:x86_64-1.1.0
d52f8ea78a8a orderer.example.com hyperledger/fabric-orderer:x86_64-1.1.0
6ab81b43e703 couchdb hyperledger/fabric-couchdb:x86_64-0.4.6
1d11e38ef5bd ca.org1.example.com hyperledger/fabric-ca:x86_64-1.1.0