Practice of Lesson 2-2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Practices for Lesson 2:

Adding Peer nodes and


Configuring Blockchain
network CLI
Practices for Lesson 2

Overview
In these practices, you will learn to add Peer nodes and Configure Blockchain network CLI.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

2 Practice for Lesson 2: Adding Peer nodes and Configuring with Blockchain network CLI
Practice of 2-2: Configure and run the Docker Compose to start
Hyperledger Fabric CLI

Overview
In this practice, you will learn to configure and run the Docker Compose to start Hyperledger
Fabric CLI.

Assumptions
You should have completed the Practices of Lesson 2-1

Tasks
1. Connect with the Hyperledger fabric Instance using Putty terminal
2. Configure Docker compose to start the Hyperledger Fabric CLI.
a. Run the below command to Clone the Hyperledger fabric sample repository.
$ cd /home/ec2-user
$git clone --branch v1.4.7
https://github.com/hyperledger/fabric-samples.git

b. Navigate to Amazon Managed Blockchain members page and copy the memberID
and save it for later use.

c. Navigate to Peer nodes page, copy the peer endpoint and save it in a notepad.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practice for Lesson 2: Adding Peer nodes and Configuring with Blockchain network CLI 3
d. Create a configuration file for Docker Compose using vi editor by the name docker-
compose-cli.yaml. Copy the below code and paste it in the docker compose file as
shown below
version: '2'
services:
cli:
container_name: cli
image: hyperledger/fabric-tools:1.4
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- FABRIC_LOGGING_SPEC=info # Set logging level to debug
for more verbose logging
- CORE_PEER_ID=cli
- CORE_CHAINCODE_KEEPALIVE=10
- CORE_PEER_TLS_ENABLED=true
-
CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-
chain.pem
- CORE_PEER_LOCALMSPID=MyMemberID
- CORE_PEER_MSPCONFIGPATH=/opt/home/admin-msp
- CORE_PEER_ADDRESS=MyPeerNodeEndpoint
working_dir:
/opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- /home/ec2-user/fabric-
samples/chaincode:/opt/gopath/src/github.com/
- /home/ec2-user:/opt/home

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

4 Practice for Lesson 2: Adding Peer nodes and Configuring with Blockchain network CLI
e. Edit the Docker Compose file by providing the MemberID and PeerNodeEndpoint
that is saved in the previous step.

f. Run the below command to start the Hyperledger Fabric peer CLI container.
$docker-compose -f docker-compose-cli.yaml up -d

Note: If the command fails, you can run the command using sudo
g. Verify the Fabric CLI is installed successfully by running the below command.
$docker container ls

3. Logout from the AWS console and close the putty terminal.

Copyright © 2020, Proton Expert Systems & Solutions. All rights reserved.

Practice for Lesson 2: Adding Peer nodes and Configuring with Blockchain network CLI 5

You might also like