PostList

레이블이 [Issues] Hyperledger Fabric인 게시물을 표시합니다. 모든 게시물 표시
레이블이 [Issues] Hyperledger Fabric인 게시물을 표시합니다. 모든 게시물 표시

2018년 12월 22일 토요일

Installing Hyperledger Fabric on AWS


##########################################################
Working on many issues. This post will be updated
##########################################################


1. access to AWS Ubuntu instance with "ubuntu" user (default) to create a new user.
ssh -i "AWS_UBUNTU_KEY.pem" ubuntu@ec2-55-222-88-111.us-west-2.compute.amazonaws.com


2. add a new user
sudo adduser haan
sudo adduser haan sudo
sudo usermod -aG sudo haan
su - haan
cd ~
pwd

e.g.
haan@ip-172-31-35-108:/home/ubuntu$ pwd
/home/ubuntu
haan@ip-172-31-35-108:/home/ubuntu$ cd ~
haan@ip-172-31-35-108:~$ pwd

/home/haan

let's exit and reconnect to aws ubuntu instance, and login to the new user account.
e.g.
su haan


3. install prerequisite

curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
./prereqs-ubuntu.sh

4. Install CLI tools



npm install -g composer-cli@0.20npm install -g composer-rest-server@0.20npm install -g generator-hyperledger-composer@0.20npm install -g yo

5. install play ground


npm install -g composer-playground@0.20


6. install Hyperledger Fabric


mkdir ~/fabric-dev-servers && cd ~/fabric-dev-servers

curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
tar -xvf fabric-dev-servers.tar.gz

cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv12

./downloadFabric.sh


7. Starting and stopping Hyperledger Fabric
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv12
./startFabric.sh
./createPeerAdminCard.sh

8. Start the web app ("Playground")
composer-playground

It will typically open your browser automatically, at the following address: http://localhost:8080/login

9. Access the Playground by a web.
http://55.200.22.111:8080/login


Ref: https://hyperledger.github.io/composer/latest/installing/installing-prereqs.html#ubuntu

Got permission denied while trying to connect to the Docker daemon socket at


Problem:

Note: 
The problem described here happened when I used "ubuntu" as a current user.
For installing Hyperledger Fabric on AWS, you'd better create a new user with sudo permission.


Can't access docker, because of a permission issue.

ubuntu@ip-172-31-35-67:~/fabric-dev-servers$ ./downloadFabric.sh
Development only script for Hyperledger Fabric control
Running 'downloadFabric.sh'
FABRIC_VERSION is set to 'hlfv12'
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/create?fromImage=hyperledger%2Ffabric-peer&tag=1.2.1: dial unix /var/run/docker.sock: connect: permission denied

ubuntu@ip-172-31-35-67:~/fabric-dev-servers$ docker images

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/json: dial unix /var/run/docker.sock: connect: permission denied

Solution:
Try to use sudo

sudo ./downloadFabric.sh

Ref:
https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/

2018년 8월 17일 금요일

Participant does not have 'READ' access to resource

IBM Hyperledger Fabric issue.

problem:

t: Participant 'org.acme.airline.participant.ACMENetworkAdmin#johnd' does not have 'READ' access to resource 'org.hyperledger.composer.system.Network#airline@0.0.2-deploy.3'





solution:

This is because yo generator generates permission.acl by default.
Therefore, add access rule to the permission.acl file as below.


permissions.acl

rule NetworkAdminUser2 {
    description: "Grant business network administrators full access to user resources"
    participant: "org.acme.airline.participant.ACMENetworkAdmin"
    operation: ALL
    resource: "**"
    action: ALLOW
}

rule NetworkAdminSystem2 {
    description: "Grant business network administrators full access to system resources"
    participant: "org.acme.airline.participant.ACMENetworkAdmin"
    operation: ALL
    resource: "org.hyperledger.composer.system.**"
    action: ALLOW
}





2018년 8월 13일 월요일

Invalid JSON data. Found a value that is not a string


Problem:

When POST with a JSON parameter of

{
  "$class": "test.SampleAsset",
  "assetId": "ID-2",
  "owner": {},
  "value": "3000"
}

The error below appears

{ "error": { "statusCode": 500, "name": "Error", "message": "Invalid JSON data. Found a value that is not a string: [object Object] for relationship RelationshipDeclaration {name=owner, type=test.SampleParticipant, array=false, optional=false}", "stack": "Error: Invalid JSON data. Found a value that is not a string: [object Object] for relationship RelationshipDeclaration {name=owner, type=test.SampleParticipant, array=false, optional=false}\n at JSONPopulator.visitRelationshipDeclaration (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:249:27)\n at JSONPopulator.visit (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:58:25)\n at RelationshipDeclaration.accept (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:54:24)\n at JSONPopulator.visitClassDeclaration (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:83:60)\n at JSONPopulator.visit (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer/jsonpopulator.js:56:25)\n at AssetDeclaration.accept (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/introspect/decorated.js:54:24)\n at Serializer.fromJSON (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-common/lib/serializer.js:189:26)\n at ensureConnected.then (/usr/local/lib/node_modules/composer-rest-server/node_modules/loopback-connector-composer/lib/businessnetworkconnector.js:634:43)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:188:7)" } }


Solution:

1. Assign owner value like,

{
  "$class": "test.SampleAsset",
  "assetId": "ID-2",
  "owner": "O-1",
  "value": "3000"
}


Creating and Deploying Business Network Application

Creating and Deploying Business Network Application

  1. Start Docker
    1. docker-machine start
    2. docker-machine env
    3. eval $(docker-machine env)
  2. Start Hyperledger Fabric
    1. ./startFabric.sh
  3. Create Peer Admin Card
    1. ./createPeerAdminCard.sh
  4. Create Business Network Application by using Yo Generator
    1. yo hyperledger-composer
    1. Create dist folder (manually) and .bna file


  1. Deploy the .bna file to Playground (using Drop here to upload or browse icon)
=>


  1. Install the Network Application to Fabric
    1. composer network start -c PeerAdmin@hlfv1 -n app2 -V 0.0.1 -A admin -S adminpw
  1. Start BNA on Fabric
    1. composer card import -f ./admin\@app2.card
  1. Ping to check if the app is available
    1. composer network ping --card admin@app2


  1. run the command to get information about the assets and registries

2018년 8월 10일 금요일

Error: Error trying install business network. Error: No valid responses from any peers.


Problem:

Error: Error trying install business network. Error: No valid responses from any peers.



Response from attempted peer comms was an error: Error: 14 UNAVAILABLE: Connect Failed



Solution:

This problem can happen when you install Docker by using Docker-Toolbox.
Default localhost IP is not 0.0.0.0
Therefore, you need to change the localhost IP in the connection.json file

1. Check your default docker IP.

docker-machine ip default

e.g.
Haans-MBP:dist haanmo$ docker-machine ip default

192.168.99.100

2. Go to the folder containing connection.json file
e.g.

cd /Users/haanmo/.composer/cards/PeerAdmin@hlfv1/connection.json 

3. change localhost (or 0.0.0.0) addresses to default IP (in my case, 192.168.99.100)
e.g. (check the IP addresses of peer, ca, etc)
{"name":"hlfv1","x-type":"hlfv1","x-commitTimeout":300,"version":"1.0.0","client":{"organization":"Org1","connection":{"timeout":{"peer":{"endorser":"300","eventHub":"300","eventReg":"300"},"orderer":"300"}}},"channels":{"composerchannel":{"orderers":["orderer.example.com"],"peers":{"peer0.org1.example.com":{}}}},"organizations":{"Org1":{"mspid":"Org1MSP","peers":["peer0.org1.example.com"],"certificateAuthorities":["ca.org1.example.com"]}},"orderers":{"orderer.example.com":{"url":"grpc://192.168.99.100:7050"}},"peers":{"peer0.org1.example.com":{"url":"grpc://192.168.99.100:7051","eventUrl":"grpc://192.168.99.100:7053"}},"certificateAuthorities":{"ca.org1.example.com":{"url":"http://192.168.99.100:7054","caName":"ca.org1.example.com"}}}

4. install the network again.
e.g.
Haans-MBP:dist haanmo$ composer network install -a test-bna\@0.0.1.bna -c PeerAdmin@hlfv1
Installing business network. This may take a minute...
Successfully installed business network test-bna, version 0.0.1


Command succeeded


ref:
docker tutorial
https://docker-curriculum.com/

2018년 8월 7일 화요일

Docker is not restarting.

Problem:

docker is not restarting, even after restarting docker by clicking icon (MacOS).

Haans-MBP:Fabric haanmo$ docker-machine restart 
Restarting "default"...
Waiting for SSH to be available...

Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded


Solution:
just start docker again by CLI.

Haans-MBP:Fabric haanmo$ docker-machine start
Starting "default"...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

Haans-MBP:Fabric haanmo$ docker ps
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                                            NAMES
47359ce3dae9        hyperledger/fabric-peer:x86_64-1.1.0      "peer node start"        2 days ago          Up 2 days           0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
080624edfe8f        hyperledger/fabric-orderer:x86_64-1.1.0   "orderer"                2 days ago          Up 2 days           0.0.0.0:7050->7050/tcp                           orderer.example.com
9413d740e731        hyperledger/fabric-couchdb:x86_64-0.4.6   "tini -- /docker-ent…"   2 days ago          Up 2 days           4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp       couchdb
0361aad7f282        hyperledger/fabric-ca:x86_64-1.1.0        "sh -c 'fabric-ca-se…"   2 days ago          Up 2 days           0.0.0.0:7054->7054/tcp                           ca.org1.example.com

Haans-MBP:Fabric haanmo$ 




2018년 8월 5일 일요일

Error: Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html

Problem:

Error: Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html


Solution:
1. Go to .composer/cards  directory. In my case (MacOS) /Users/haanmo/.composer/cards.
2. Delete all hiddle files in the folder..
   e.g.,
   rm .DS_Store

this is a bug with the underlying NodeJS readdir function, its list everything in the folder even the hidden files.in your case just go to the ./compser/cards folder in your home directory and delete the hidden files in that folder

Ref:
https://stackoverflow.com/questions/50084707/about-hyperledger-fabric-composer-error-when-execute-cmd-composer-card-list

Missing required argument: card


Problem:


cometnet-10-21-3-96:dist haanmo$ composer card export -n PeerAdmin@hlfv1 -f test.card
composer card export [options]

Export a business network card

Options:
  --help         Show help  [boolean]
  -v, --version  Show version number  [boolean]
  --file, -f     The card file name  [string]
  --card, -c     The name of the card to export  [string] [required]

Missing required argument: card

Solution:

change -n to -c

composer card export -c PeerAdmin@hlfv1 -f test.card
e.g.
cometnet-10-21-3-96:dist haanmo$ composer card export -c PeerAdmin@hlfv1 -f test.card

Successfully exported business network card
Card file: test.card
Card name: PeerAdmin@hlfv1

Command succeeded

2018년 7월 29일 일요일

Cannot connect to the Docker daemon. Is the docker daemon running on this host?


Problem:
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Solution:
docker-machine restart 

then


docker-machine env
eval $(docker-machine env)

ref:
https://github.com/docker/toolbox/issues/296



Following Problems:
1. Too many retries waiting for SSH to be available. Last error: Maximum number of retries (60) exceeded
docker-machine restart
Restarting "default"...
Waiting for SSH to be available...

Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded

2. Error checking TLS connection: Host is not running
docker-machine env

Error checking TLS connection: Host is not running

Solution:

docker-machine start default
docker-machine env
eval $(docker-machine env)

then (to check)

docker image list

Ref:
https://stackoverflow.com/questions/36193300/mac-os-x-sudo-docker-cannot-connect-to-the-docker-daemon-is-the-docker-daemon-r