Sei sulla pagina 1di 26

Install pre-requisites on Ubuntu 16.

04 LTS

https://medium.com/@eSizeDave/https-medium-com-esizedave-how-to-install-hyperledger-fabric-1-2-
on-ubuntu-16-04-lts-ecdfa4dcec72

NOTE: I am using a fresh install of Ubuntu 16.04 LTS

Update the package index


sudo apt-get update

Install curl and packages to setup Docker repository for the usual Docker
install method

See https://docs.docker.com/install/linux/docker-
ce/ubuntu/#install-docker-ce for more details on this… if you
really want to.

sudo apt-get install curl apt-transport-https ca-certificates software-


properties-common

Add Docker gpg key


curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Verify the gpg key


sudo apt-key fingerprint 0EBFCD88

Add Docker repository


sudo add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Update the package index again

sudo apt-get update


Install the latest stable version of Docker
Note: Hyperledger requires 17.06.2-ce or newer

sudo apt-get install docker-ce

Check Docker version to ensure it’s installed


docker --version

 docker –version
 Docker version 18.09.3, build 774a1f4

Download Docker Compose
sudo curl -L
 https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$
(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

*** THIS DID NOT WORK, I had to install and then use pip instead

sudo apt install python3-pip


pip3 --version

sudo pip3 install docker-compose

Apply executable permission to the Docker Compose binary


sudo chmod +x /usr/local/bin/docker-compose

Check Docker Compose version to ensure it’s installed


docker-compose --version

 docker-compose –version
 docker-compose version 1.23.2, build 1110ad0

Download and setup Go programming language


Note: Check for the latest stable release on https://golang.org/dl/ and edit the *.tar.gz bit
accordingly on the commands below
curl -O https://storage.googleapis.com/golang/go1.10.3.linux-amd64.tar.gz
sha256sum go1.10.3.linux-amd64.tar.gz

Untar and unzip the file:

tar -xvf go1.10.3.linux-amd64.tar.gz

Move the go software to local

sudo mv go /usr/local

Open profile to setup Go related paths for the user profile


sudo vi ~/.profile

Add following lines to ~/.profile file

export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Reload the profile file


source ~/.profile

Verify with echo $PATH


Install Node.js

Note: Here we install required Ubuntu packages and build Node.js


from source since Hyperledger 1.2 only supports Node.js versions
8.9+ but < 9

Update the package index again and install necessary Ubuntu packages
for Node.js

sudo apt-get update


sudo apt-get install build-essential openssl libssl-dev pkg-config

Go to the src directory, create a node directory, and go into it

cd /usr/local/src
sudo mkdir node
cd node

pwd

dbpract@silver0:/usr/local/src/node$

Download Node.js

Note: Here we download version 8.9.3 due to limitations of


Hyperledger 1.2
sudo wget https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz
Extract the tar file and go into the newly created node-v8.9.3 directory, configure
the directory, run make, and make install
Note: This could (and probably will) take a little while since we’re building from source

sudo tar zxvf node-v8.9.3.tar.gz


cd node-v8.9.3
sudo ./configure

--- this make command will take a long time to run -- wow
sudo make
sudo make install

Be warned. The sudo make command above for node.js took more than 45 minutes to run.
Check Node.js versions to ensure it’s installed
node --version

Upgrade NPM version
(as per instructions on http://hyperledger-fabric.readthedocs.io/en/release-
1.2/prereqs.html and check it’s correct)

sudo npm install npm@5.6.0 -g


sudo npm –version

5.6.0

Python 2.7x
Python 2.7.12 should already be installed on a fresh Ubuntu 16.04 LTS, but just in case,
install Python (ensure we’re only using version 2.7x and not Python 3)

 -- skip this since python is installed: sudo apt-get install python

 python --version

Python 2.7.12
You can create a hyperledger directory in /usr/local/ and go into it to run the following
commands which create a fabric-samples directory and installs them there

cd /usr/local
sudo mkdir hyperledger
cd hyperledger

--- This works as shown below


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

-------------------------------------------------- Results from the command above

dbpract@silver0:/usr/local/hyperledger$ curl -sSL http://bit.ly/2ysbOFE | sudo bash -s 1.2.0

Installing hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo and checkout v1.2.0

Cloning into 'fabric-samples'...

remote: Enumerating objects: 5, done.

remote: Counting objects: 100% (5/5), done.

remote: Compressing objects: 100% (5/5), done.

remote: Total 2718 (delta 0), reused 5 (delta 0), pack-reused 2713
Receiving objects: 100% (2718/2718), 928.82 KiB | 0 bytes/s, done.

Resolving deltas: 100% (1357/1357), done.

Checking connectivity... done.

Note: checking out 'v1.2.0'.

You are in 'detached HEAD' state. You can look around, make experimental

changes and commit them, and you can discard any commits you make in this

state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may

do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD is now at ed81d7b... [FAB-10811] fabric-ca sample is broken on v1.2

Installing Hyperledger Fabric binaries

===> Downloading version 1.2.0 platform specific fabric binaries

===> Downloading: https://nexus.hyperledger.org/content/repositories/releases/o


rg/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.2.0/hyperledger-fabric-li nux-
amd64-1.2.0.tar.gz

% Total % Received % Xferd Average Speed Time Time Time Current


Dload Upload Total Spent Left Speed

100 39.0M 100 39.0M 0 0 2651k 0 0:00:15 0:00:15 --:--:-- 2452k

==> Done.

===> Downloading version 1.4.0 platform specific fabric-ca-client binary

===> Downloading: https://nexus.hyperledger.org/content/repositories/releases/o


rg/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.4.0/hyperledger-fab ric-ca-
linux-amd64-1.4.0.tar.gz

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 5979k 100 5979k 0 0 2638k 0 0:00:02 0:00:02 --:--:-- 2637k

==> Done.

Installing Hyperledger Fabric docker images

===> Pulling fabric Images

==> FABRIC IMAGE: peer

1.2.0: Pulling from hyperledger/fabric-peer

b234f539f7a1: Pull complete


55172d420b43: Pull complete

5ba5bbeb6b91: Pull complete

43ae2841ad7a: Pull complete

f6c9c6de4190: Pull complete

c6af77e36488: Pull complete

964f7f4f22f3: Pull complete

d4a3f4cfba3d: Pull complete

73782018d902: Pull complete

039eb34e730e: Pull complete

Digest: sha256:949b38bad9496d7694b54d30b90b72653804d761a44d721c4dc7a16a5cbcabe8

Status: Downloaded newer image for hyperledger/fabric-peer:1.2.0

==> FABRIC IMAGE: orderer

1.2.0: Pulling from hyperledger/fabric-orderer

b234f539f7a1: Already exists

55172d420b43: Already exists


5ba5bbeb6b91: Already exists

43ae2841ad7a: Already exists

f6c9c6de4190: Already exists

c6af77e36488: Already exists

964f7f4f22f3: Already exists

d4a3f4cfba3d: Already exists

8d0e11f5a0f7: Pull complete

0bda0f004d88: Pull complete

Digest: sha256:a10f6d1d4cbb5a0264634c8b5ec63ff6cbbfc7c9fb369a06cc6dfe504d976259

Status: Downloaded newer image for hyperledger/fabric-orderer:1.2.0

==> FABRIC IMAGE: ccenv

1.2.0: Pulling from hyperledger/fabric-ccenv

b234f539f7a1: Already exists

55172d420b43: Already exists

5ba5bbeb6b91: Already exists


43ae2841ad7a: Already exists

f6c9c6de4190: Already exists

c6af77e36488: Already exists

964f7f4f22f3: Already exists

13cd31405e09: Pull complete

e03b35c19d96: Pull complete

96c2920985e3: Pull complete

e91461be8304: Pull complete

950c3368692b: Pull complete

c5de8d20c137: Pull complete

5536b64bc67b: Pull complete

Digest: sha256:0a7fb37111cafce79cf89ca8d1af5ca6f721e60a8bd1b2b93521e671e3348af2

Status: Downloaded newer image for hyperledger/fabric-ccenv:1.2.0

==> FABRIC IMAGE: javaenv

Error response from daemon: manifest for hyperledger/fabric-javaenv:1.2.0 not fo und


Error response from daemon: No such image: hyperledger/fabric-javaenv:1.2.0

==> FABRIC IMAGE: tools

1.2.0: Pulling from hyperledger/fabric-tools

b234f539f7a1: Already exists

55172d420b43: Already exists

5ba5bbeb6b91: Already exists

43ae2841ad7a: Already exists

f6c9c6de4190: Already exists

c6af77e36488: Already exists

964f7f4f22f3: Already exists

13cd31405e09: Already exists

e03b35c19d96: Already exists

96c2920985e3: Already exists

e91461be8304: Already exists

314928def9dd: Pull complete


d5b68ae13f8d: Pull complete

dde25187799d: Pull complete

Digest: sha256:24cca44a2f2ab6325c6ccc1c91a10bd3e0e71764037a85a473f7e9621b3a0f91

Status: Downloaded newer image for hyperledger/fabric-tools:1.2.0

===> Pulling fabric ca Image

==> FABRIC CA IMAGE

1.4.0: Pulling from hyperledger/fabric-ca

3b37166ec614: Pull complete

504facff238f: Pull complete

ebbcacd28e10: Pull complete

c7fb3351ecad: Pull complete

2e3debadcbf7: Pull complete

fc435e46e32e: Pull complete

a4922bafdce8: Pull complete

c8ec0cae397c: Pull complete


3153e2e7116e: Pull complete

d84abf263d15: Pull complete

45ff112943d3: Pull complete

c4678d50bc7a: Pull complete

Digest: sha256:c1dce534d9e9202697e0aaad7c5521d958700fda0b05127dafb9333c22e15f74

Status: Downloaded newer image for hyperledger/fabric-ca:1.4.0

===> Pulling thirdparty docker images

==> THIRDPARTY DOCKER IMAGE: couchdb

0.4.14: Pulling from hyperledger/fabric-couchdb

3b37166ec614: Already exists

504facff238f: Already exists

ebbcacd28e10: Already exists

c7fb3351ecad: Already exists

2e3debadcbf7: Already exists

fc435e46e32e: Already exists


a4922bafdce8: Already exists

14675a1189ca: Pull complete

33f930d7053e: Pull complete

7aa21e006739: Pull complete

806ba27e29bb: Pull complete

36861d712d08: Pull complete

d90f5e3e2060: Pull complete

24997f7eee08: Pull complete

3178b1827d0f: Pull complete

7483b6e6320e: Pull complete

3ca8322e6d72: Pull complete

e3f87c16fd0e: Pull complete

fa9f1a1e037c: Pull complete

08b197ff3973: Pull complete

ed0c2b2f2e3e: Pull complete

Digest: sha256:021c7e4a5047432d892fbdf7d5220d3049ff4e8b436fd481bb08e41871f1aac7
Status: Downloaded newer image for hyperledger/fabric-couchdb:0.4.14

==> THIRDPARTY DOCKER IMAGE: kafka

0.4.14: Pulling from hyperledger/fabric-kafka

3b37166ec614: Already exists

504facff238f: Already exists

ebbcacd28e10: Already exists

c7fb3351ecad: Already exists

2e3debadcbf7: Already exists

fc435e46e32e: Already exists

a4922bafdce8: Already exists

14675a1189ca: Already exists

33f930d7053e: Already exists

7aa21e006739: Already exists

806ba27e29bb: Already exists

5b93606e43dd: Pull complete


c28e9396b3a9: Pull complete

d4fac70bff73: Pull complete

Digest: sha256:82ac81938320d05a538b9fd6de0fcd54b5a999188cf9b08822cf25f9ad7970a9

Status: Downloaded newer image for hyperledger/fabric-kafka:0.4.14

==> THIRDPARTY DOCKER IMAGE: zookeeper

0.4.14: Pulling from hyperledger/fabric-zookeeper

3b37166ec614: Already exists

504facff238f: Already exists

ebbcacd28e10: Already exists

c7fb3351ecad: Already exists

2e3debadcbf7: Already exists

fc435e46e32e: Already exists

a4922bafdce8: Already exists

14675a1189ca: Already exists

33f930d7053e: Already exists

7aa21e006739: Already exists


806ba27e29bb: Already exists

04fff5ccfdcb: Pull complete

dbe82feb14ae: Pull complete

ba7a23bea382: Pull complete

5f6e0d1bbcbd: Pull complete

Digest: sha256:ac342ed87997175bfd557c53f7ffc6e0f8aa32bcaebb54a9bd55fb4c7f954802

Status: Downloaded newer image for hyperledger/fabric-zookeeper:0.4.14

===> List out hyperledger docker images

hyperledger/fabric-ca 1.4.0 1a804ab74f58 2 months ago 244MB

hyperledger/fabric-ca latest 1a804ab74f58 2 months ago 244MB

hyperledger/fabric-zookeeper 0.4.14 d36da0db87a4 5 months ago 1.43GB

hyperledger/fabric-zookeeper latest d36da0db87a4 5 months ago 1.43GB

hyperledger/fabric-kafka 0.4.14 a3b095201c66 5 months ago 1.44GB

hyperledger/fabric-kafka latest a3b095201c66 5 months ago 1.44GB

hyperledger/fabric-couchdb 0.4.14 f14f97292b4c 5 months ago 1.5GB

hyperledger/fabric-couchdb latest f14f97292b4c 5 months ago 1.5GB


hyperledger/fabric-tools 1.2.0 379602873003 8 months ago 1.51GB

hyperledger/fabric-tools latest 379602873003 8 months ago 1.51GB

hyperledger/fabric-ccenv 1.2.0 6acf31e2d9a4 8 months ago 1.43GB

hyperledger/fabric-ccenv latest 6acf31e2d9a4 8 months ago 1.43GB

hyperledger/fabric-orderer 1.2.0 4baf7789a8ec 8 months ago 152MB

hyperledger/fabric-orderer latest 4baf7789a8ec 8 months ago 152MB

hyperledger/fabric-peer 1.2.0 82c262e65984 8 months ago 159MB

hyperledger/fabric-peer latest 82c262e65984 8 months ago 159MB

dbpract@silver0:/usr/local/hyperledger$ ls -l

total 4

drwxr-xr-x 14 root root 4096 Mar 19 13:02 fabric-samples

dbpract@silver0:/usr/local/hyperledger$

----------------------------------- End of results from installing hyperledger samples

At this point we will verify that the fabric-samples has something in it. Change directory into
the directory and use the ls to list the files and directories.

cd fabric-samples
ls

Edit the profile and add in the export path shown below.

sudo vi ~/.profile

export PATH=/usr/local/hyperledger/fabric-samples/bin:$PATH

Reload the profile file

source ~/.profile

Create a genesis block for your network


Note: The following is relevant if you’ve installed Fabric Samples
as detailed above

cd /path/to/fabric-samples/first-network so in our case:

cd /usr/local/hyperledger/fabric-samples/first-network
sudo ./byfn.sh generate
dbpract@silver0:~$ cd /usr/local/hyperledger/fabric-samples/first-network

dbpract@silver0:/usr/local/hyperledger/fabric-samples/first-network$ sudo ./byfn.sh generate

Generating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds

Continue? [Y/n] Y

proceeding ...

/usr/local/hyperledger/fabric-samples/first-network/../bin/cryptogen

##########################################################

##### Generate certificates using cryptogen tool #########

##########################################################

+ cryptogen generate --config=./crypto-config.yaml

org1.example.com

org2.example.com

+ res=0

+ set +x
/usr/local/hyperledger/fabric-samples/first-network/../bin/configtxgen

##########################################################

######### Generating Orderer Genesis block ##############

##########################################################

+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

2019-03-19 13:23:38.806 MDT [common/tools/configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen is deprecated.
Explicitly passing the channel ID will be required in the future, defaulting to 'testchainid'.

2019-03-19 13:23:38.806 MDT [common/tools/configtxgen] main -> INFO 002 Loading configuration

2019-03-19 13:23:38.816 MDT [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is deprecated,
please include policy specificiations for the channel group in configtx.yaml

2019-03-19 13:23:38.816 MDT [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is deprecated,
please include policy specificiations for the orderer group in configtx.yaml

2019-03-19 13:23:38.817 MDT [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 005 Default policy emission is
deprecated, please include policy specificiations for the orderer org group OrdererOrg in configtx.yaml

2019-03-19 13:23:38.819 MDT [msp] getMspConfig -> INFO 006 Loading NodeOUs

2019-03-19 13:23:38.819 MDT [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 007 Default policy emission is
deprecated, please include policy specificiations for the orderer org group Org1MSP in configtx.yaml

2019-03-19 13:23:38.819 MDT [msp] getMspConfig -> INFO 008 Loading NodeOUs

2019-03-19 13:23:38.819 MDT [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 009 Default policy emission is
deprecated, please include policy specificiations for the orderer org group Org2MSP in configtx.yaml
2019-03-19 13:23:38.819 MDT [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block

2019-03-19 13:23:38.820 MDT [common/tools/configtxgen] doOutputBlock -> INFO 00b Writing genesis block

+ res=0

+ set +x

#################################################################

### Generating channel configuration transaction 'channel.tx' ###

#################################################################

+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel

2019-03-19 13:23:38.874 MDT [common/tools/configtxgen] main -> INFO 001 Loading configuration

2019-03-19 13:23:38.883 MDT [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx

2019-03-19 13:23:38.883 MDT [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is
deprecated, please include policy specificiations for the application group in configtx.yaml

2019-03-19 13:23:38.884 MDT [msp] getMspConfig -> INFO 004 Loading NodeOUs

2019-03-19 13:23:38.885 MDT [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 005 Default policy emission is
deprecated, please include policy specificiations for the application org group Org1MSP in configtx.yaml

2019-03-19 13:23:38.886 MDT [msp] getMspConfig -> INFO 006 Loading NodeOUs
2019-03-19 13:23:38.886 MDT [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 007 Default policy emission is
deprecated, please include policy specificiations for the application org group Org2MSP in configtx.yaml

2019-03-19 13:23:38.888 MDT [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 008 Writing new channel tx

+ res=0

+ set +x

#################################################################

####### Generating anchor peer update for Org1MSP ##########

#################################################################

+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg


Org1MSP

2019-03-19 13:23:38.942 MDT [common/tools/configtxgen] main -> INFO 001 Loading configuration

2019-03-19 13:23:38.952 MDT [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update

2019-03-19 13:23:38.952 MDT [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

+ res=0

+ set +x
#################################################################

####### Generating anchor peer update for Org2MSP ##########

#################################################################

+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg


Org2MSP

2019-03-19 13:23:39.008 MDT [common/tools/configtxgen] main -> INFO 001 Loading configuration

2019-03-19 13:23:39.020 MDT [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update

2019-03-19 13:23:39.020 MDT [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

+ res=0

+ set +x

------------------------------- end of results -------------------------

In a browser, go to this URL and watch the video.

https://www.hyperledger.org/community/basics

https://hyperledger-fabric.readthedocs.io/en/release-1.4/write_first_app.html#

Potrebbero piacerti anche