Thank you
to be here in my blog. This how to install Hyperledger Fabric 1.1.0-rc1 on
Ubuntu 16.04.x. I saw many tutorials about this Solution but most of the time I
failed to install successfully the Fabric (maybe I messed up something). Here
is the way I found to achieve my goals. Let’s go.
1. Following prerequisites are required
to install the Fabric.
Latest version of cURL and dev libraries
Latest version of Docker & Docker compose (docker v1.12.x or higher)
Latest version of Go-Lang (Go - Programming
Language)
Python v2.7
Node JS v6.x (Currently v7.x not supported)
You must be root for topics 2 to 6. After will create a user and at 6.1
will do “sudo” for the rest of the tutorial.
2.
Fisrt Update
$ apt update
3.
Install Curl
$ apt install curl
4.
Install libtool
$ apt-get install libltdl-dev
5.
Install latest docker and docker compose
$ apt-get install docker.io
docker-compose
Chreck the version :
$ docker --version
$ docker-compose --version
6.
Install Go Language
$ sudo apt install golang-go
6.1
Create a User
$ useradd –m –c “Fabric DEV User” yourusername
Put the current user in docker group
$ sudo usermod -a -G docker
yourusername
$ sudo su - yourusername
Export the environment variables (put it in user bash profile):
$ vi
$ vi .bashrc
export GOPATH=$HOME/gopath
export PATH=$PATH:/usr/local/go/bin
to test it enter:
$ go
Go is a tool for managing Go source code.
Usage:
go
command [arguments]
The commands are:
build compile packages and dependencies
clean remove object files
doc show documentation for package or sy
etc.
7.
Installation of NODEJS
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs
Note: Ensure nodejs version is 6.x
$ nodejs –v
Installing Node.js will also install NPM,
Upgrade the npm tool with the following command:
$ sudo npm install npm@3.10.10 -g
8 Install Python 2.7
Pyhton maybe already installed, if not do :
$ apt install python
Check version :
$ python --version
8.
Hyperledger Fabric Installation
First , create folders for the fabric
$ mkdir -p $GOPATH/src/github.com/hyperledger/
$ cd $GOPATH/src/github.com/hyperledger/
Remove all previous images from docker :
$ docker rm -f $(docker ps -aq)
Second you must download the Fabric, it can take time depending of your
connection speed
$ curl -sSL https://goo.gl/6wtTN5 | bash -s
1.1.0-rc1
You ‘ll find after download two folder “bin” and “config”
hypledge@vps520804:~/gopath/src/github.com/hyperledger$
ll
total 20
drwxrwxr-x
5 hypledge hypledge 4096 Mar 22 10:48 ./
drwxrwxr-x
3 hypledge hypledge 4096 Mar 21 23:32 ../
drwxrwxr-x
2 hypledge hypledge 4096 Mar 2
00:29 bin/
drwxrwxr-x
2 hypledge hypledge 4096 Mar 1
20:58 config/
Put in your path the following environnement variables. The fabric will
need these binaries to work
You ‘ll find these files and more in bin folder:
- cryptogen
- configtxgen
- configtxlator
- peer
Edit user bash profile “.bashrc”:
Replace : export
PATH=$PATH:/usr/local/go/bin
By
export
PATH=$PATH:/usr/local/go/bin:$HOME/gopath/src/github.com/hyperledger/bin
To see all images has been downloaded correctly enter:
hypledge@vps520804:~$ docker
images
REPOSITORY
TAG IMAGE ID CREATED SIZE
dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba latest bc2eee0b277c 4 days ago 172 MB
<none>
<none>
6d9799ae1d8e 4 days
ago 1.26 GB
hyperledger/fabric-ca
latest
8a6c8c2e2ebf 3 weeks
ago 283 MB
hyperledger/fabric-ca
x86_64-1.1.0-rc1 8a6c8c2e2ebf 3 weeks ago 283 MB
hyperledger/fabric-tools
latest
006c689ec08e 3 weeks ago 1.46 GB
hyperledger/fabric-tools
x86_64-1.1.0-rc1
006c689ec08e 3 weeks
ago 1.46 GB
hyperledger/fabric-orderer latest 10afc128d402 3 weeks ago 180 MB
hyperledger/fabric-orderer
x86_64-1.1.0-rc1
10afc128d402 3 weeks
ago 180 MB
hyperledger/fabric-peer
latest
6b44b1d021cb 3 weeks
ago 187 MB
hyperledger/fabric-peer x86_64-1.1.0-rc1 6b44b1d021cb 3 weeks ago 187 MB
hyperledger/fabric-javaenv
latest
ea263125afb1 3 weeks
ago 1.52 GB
hyperledger/fabric-javaenv
x86_64-1.1.0-rc1
ea263125afb1 3 weeks
ago 1.52 GB
hyperledger/fabric-ccenv latest 65c951b9681f 3 weeks ago 1.39 GB
hyperledger/fabric-ccenv
x86_64-1.1.0-rc1
65c951b9681f 3 weeks ago 1.39 GB
hyperledger/fabric-baseimage
x86_64-0.4.6
dbe6787b5747 5 weeks
ago 1.37 GB
hyperledger/fabric-zookeeper latest 92cbb952b6f8 5 weeks ago 1.39 GB
hyperledger/fabric-zookeeper
x86_64-0.4.6 92cbb952b6f8 5 weeks ago 1.39 GB
hyperledger/fabric-kafka
latest
554c591b86a8 5 weeks
ago 1.4 GB
hyperledger/fabric-kafka x86_64-0.4.6 554c591b86a8 5 weeks ago 1.4 GB
hyperledger/fabric-couchdb
latest 7e73c828fc5b 5 weeks ago 1.56 GB
hyperledger/fabric-couchdb
x86_64-0.4.6
7e73c828fc5b 5 weeks
ago 1.56 GB
hyperledger/fabric-baseos x86_64-0.4.6 220e5cf3fb7f 5 weeks ago 151 MB
hyperledger/fabric-baseimage
x86_64-0.3.2
c92d9fdee998 7 months
ago 1.26 GB
hyperledger/fabric-baseos
ok you are done with the fabric. Now let’s install the Fabric Sample.
$ cd $GOPATH/src/github.com/hyperledger/
$ git clone https://github.com/hyperledger/fabric-samples.git
$ cd fabric-samples
$ cd fabcar
$ ls
enrollAdmin.js
hfc-key-store invoke.js node_modules
package.json query.js registerUser.js startFabric.sh
Now launch the fabric application sample :
$./startFabric
We need to install node SDK for Hyperledger so that
we can run the node modules in this example
$ npm install
At end enter :
$ node enrollAdmin.js
$ node registerUser
Results :
hypledge@vps520804:~/gopath/src/github.com/hyperledger/fabric-samples/fabcar$ node enrollAdmin.js
Store
path:/home/hypledge/gopath/src/github.com/hyperledger/fabric-samples/fabcar/hfc-key-store
Successfully enrolled admin user
"admin"
Assigned the admin user to the fabric client
::{"name":"admin","mspid":"Org1MSP","roles":null,"affiliation":"","enrollmentSecret":"","enrollment":{"signingIdentity":"5dbc7fe466d5ad94bcfdad849b4fa1be2aa7481367d49cb41b08cf571ed46879","identity":{"certificate":"-----BEGIN
CERTIFICATE-----\nMIICAjCCAaigAwIBAgIUQAYiw6LEzUl97OxkdcpGMNS9guEwCgYIKoZIzj0EAwIw\nczELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh\nbiBGcmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMT\nE2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMTgwMzI2MTA0NTAwWhcNMTkwMzI2MTA1\nMDAwWjAhMQ8wDQYDVQQLEwZjbGllbnQxDjAMBgNVBAMTBWFkbWluMFkwEwYHKoZI\nzj0CAQYIKoZIzj0DAQcDQgAEQV7GNIU41Y8q0j8y6/R/h3o4MK1SUY9yVNwC/FLB\nE360gj78PHQp697Hmi+MPMA4SVmt5YbYy8GzIxQv9Kb9U6NsMGowDgYDVR0PAQH/\nBAQDAgeAMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFI91gBAuXWnOcKdiERHJCMGr\njkwxMCsGA1UdIwQkMCKAIEI5qg3NdtruuLoM2nAYUdFFBNMarRst3dusalc2Xkl8\nMAoGCCqGSM49BAMCA0gAMEUCIQCCk68DhdccnYGtQ9oVJ62BZelN5I21VAr+OSgH\nAgnOfwIgf4TBQkeUjOf3vv2Gc1UX+FER+Te+v4roMPoI5N7C49A=\n-----END
CERTIFICATE-----\n"}}}
hypledge@vps520804:~/gopath/src/github.com/hyperledger/fabric-samples/fabcar$ node registerUser.js
Store
path:/home/hypledge/gopath/src/github.com/hyperledger/fabric-samples/fabcar/hfc-key-store
Successfully loaded admin from
persistence
Successfully registered user1 -
secret:uTvVwmXGpuWi
Successfully enrolled member user
"user1"
User1 was successfully registered and
enrolled and is ready to intreact with the fabric network
hypledge@vps520804:~/gopath/src/github.com/hyperledger/fabric-samples/fabcar$
You can now query the app by:
$ node query.js
Results:
hypledge@vps520804:~/gopath/src/github.com/hyperledger/fabric-samples/fabcar$
node query.js
Store
path:/home/hypledge/gopath/src/github.com/hyperledger/fabric-samples/fabcar/hfc-key-store
Successfully loaded user1 from
persistence
Query has completed, checking
results
Response is [{"Key":"CAR0",
"Record":{"colour":"blue","make":"Toyota","model":"Prius","owner":"Tomoko"}},{"Key":"CAR1",
"Record":{"colour":"red","make":"Ford","model":"Mustang","owner":"Brad"}},{"Key":"CAR2",
"Record":{"colour":"green","make":"Hyundai","model":"Tucson","owner":"Jin
Soo"}},{"Key":"CAR3", "Record":{"colour":"yellow","make":"Volkswagen","model":"Passat","owner":"Max"}},{"Key":"CAR4",
"Record":{"colour":"black","make":"Tesla","model":"S","owner":"Adriana"}},{"Key":"CAR5",
"Record":{"colour":"purple","make":"Peugeot","model":"205","owner":"Michel"}},{"Key":"CAR6",
"Record":{"colour":"white","make":"Chery","model":"S22L","owner":"Aarav"}},{"Key":"CAR7",
"Record":{"colour":"violet","make":"Fiat","model":"Punto","owner":"Pari"}},{"Key":"CAR8",
"Record":{"colour":"indigo","make":"Tata","model":"Nano","owner":"Valeria"}},{"Key":"CAR9",
"Record":{"colour":"brown","make":"Holden","model":"Barina","owner":"Shotaro"}}]
hypledge@vps520804:~/gopath/src/github.com/hyperledger/fabric-samples/fabcar$
if Node query failed ,do :
$ docker rm -f $(docker ps -aq)
And after do a
./startFabric again
If you want to have more info about the SAMPLE APPLICATION “FABCAR” go
to these links:
Thank you!