Adding peers to the Fabcar Network - Hyperledger Fabric - hyperledger-fabric

I tried to extend the fabcar network to 2 peers running on the same system. I encountered some errors.
I made the following changes to the docker compose file.
peer1.org1.example.com:
container_name: peer1.org1.example.com
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org1.example.com
- CORE_LOGGING_PEER=debug
- CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer1.org1.example.com:7051
# # the following setting starts chaincode containers on the same
# # bridge network as the peers
# # https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
# The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
# provide the credentials for ledger to connect to CouchDB. The username and password must
# match the username and password set for the associated CouchDB.
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
- 8051:7051
- 8053:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.example.com
- couchdb1
networks:
- basic
couchdb1:
container_name: couchdb1
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- 6984:5984
networks:
- basic
In the start.sh file, I added a line of code to join peer 1 to the channel.
When I execute ./startFabric.sh node, I get the following error:
Error response from daemon, container not running.
Logs are as below:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b602e1898831 hyperledger/fabric-peer "peer node start" 3 minutes ago Exited (1) 3 minutes ago peer1.org1.example.com
780acf5be420 hyperledger/fabric-couchdb "tini -- /docker-ent…" 3 minutes ago Up 3 minutes 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb1
d93c8d14e07d hyperledger/fabric-peer "peer node start" 3 minutes ago Up 3 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
f8d5a07e0c14 hyperledger/fabric-couchdb "tini -- /docker-ent…" 3 minutes ago Up 3 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
0c8be993aaad hyperledger/fabric-orderer "orderer" 3 minutes ago Up 3 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
29484423ee69 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 3 minutes ago Exited (1) 3 minutes ago ca.example.com
Digitals-MacBook-Air-3:fabcar digital3$ docker logs b602e1898831
2018-06-28 08:12:18.923 UTC [main] main -> ERRO 001 **Cannot run peer because error when setting up MSP of type bccsp from directory /etc/hyperledger/msp/peer/: could not load a valid signer certificate from directory /etc/hyperledger/msp/peer/signcerts: stat /etc/hyperledger/msp/peer/signcerts: no such file or directory**
Changes I made are:
In crypto-config: changed template count to 2.
In docker-compose , added another service for peer1 with database as couchdb1. No changes to CLI.
In the start.sh file, I wrote a line of code to add peer 1 to the channel.
When I run ./startFabric.sh node in the fabcar directory, I get the above mentioned errors.
I am making edits in the basic-network and not first network.
I just checked my certificate directory: It looks as below
CRYPTOCONFIG - PeerOrganisations - Peers - peer0 , peer1
Peer0 has all the certificates
Peer1 only has the msp folder, no tls folder. The msp folder only has admincerts and keystore
Update:
I managed to generate the certificates for both peers and successful ran the ./startFabric.sh node command from the fabcar directory. However, I faced an issue when I executed the enrollAdmin command.
Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 10.228.27.101:7054]
at ClientRequest. (/Users/digital3/fabric-samples/fabcar/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:883:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to enroll admin: Error: Failed to enroll admin
Could you help me with this

If you want to add additional peer node(s), you will also need to generate the relevant crypto material.
On line 63 of the crypto-config.yaml file in the basic-network directory, set the value of Count to '2', e.g.:
# "Template"
# ---------------------------------------------------------------------------
# Allows for the definition of 1 or more hosts that are created sequentially
# from a template. By default, this looks like "peer%d" from 0 to Count-1.
# You may override the number of nodes (Count), the starting index (Start)
# or the template used to construct the name (Hostname).
#
# Note: Template and Specs are not mutually exclusive. You may define both
# sections and the aggregate nodes will be created for you. Take care with
# name collisions
# ---------------------------------------------------------------------------
Template:
Count: 2
# Start: 5
# Hostname: {{.Prefix}}{{.Index}} # default
This will have the cryptogen step generate key material for two peer nodes for the org: Org1.

Related

How to execute "peer node pause" command in Hyperledger Fabric?

If I run this command peer node pause -c mychannel the following error occurs;
Error: as another peer node command is executing, wait for that command to complete its execution or terminate it before retrying: lock is already acquired on file /var/hyperledger/production/ledgersData/fileLock
Usage:
peer node pause [flags]
Flags:
-c, --channelID string Channel to pause.
-h, --help help for pause
/opt/gopath/src/github.com/hyperledger/fabric/peer # peer node pause -h
Pauses a channel on the peer. When the command is executed, the peer must be offline. When the peer starts after a pause, it will not receive blocks for the paused channel.
I Understood that the peer needs to be in the offline state in order to execute this command. But how can I make the peer offline. There is no such command as Peer node stop. The only way I see is to use the docker command to stop the container, but that doesn't make any sense, as if I stop the container I won't be able to sh into the container.
Anyone please help me to execute the peer node pause command!
Checkout the command with which you are starting the container.
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer:latest
labels:
service: hyperledger-fabric
environment:
#Generic peer variables
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_test
- FABRIC_LOGGING_SPEC=INFO
#- FABRIC_LOGGING_SPEC=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
# Peer specific variabes
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- /var/run/docker.sock:/host/var/run/docker.sock
- ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer0.org1.example.com:/var/hyperledger/production
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
ports:
- 7051:7051
networks:
- test
As you are bringing up the peer container wtih command: peer node start command.
According to fabric docs the peer node start command - Starts a node that interacts with the network.
So the node is getting started as you bring up the container, I have not tried it but you can either replace that command with peer node pause -c mychannel as the node is not yet started that means the peer was in offline state. You can try this.

Setting up a Fabric network on multiple computers: Unable to instantiate chain code on peers of 2nd Org

I am trying to setup the balance-transfer network on multiple computers.
This is similar to the query at
unable to Instantiate any chaincodes on peers of newly Added org
However, there was no resolution to that question
My approach is described below:
1 Org1, Orderer, CA1 on 1st computer
2.Org2, CA2 on 2nd computer
3.Split the docker-compose file accordingly
4.Added the IP's in the network-config file
I was able to register users of both Orgs and install chain code on both the hosts. However, I am not able to instantiate the chain code on Org 2 (ie. the second computer)
I get the following error :
[2018-07-19 11:20:31.401] [ERROR] instantiate-chaincode - REQUEST_TIMEOUT:10.228.27.96:8051
[2018-07-19 11:20:31.402] [ERROR] instantiate-chaincode - Error: ChannelEventHub has been shutdown
at ChannelEventHub.disconnect (/Users/digital3/Desktop/Final/balance-transfer/node_modules/fabric-client/lib/ChannelEventHub.js:444:21)
at Timeout.setTimeout (/Users/digital3/Desktop/Final/balance-transfer/app/instantiate-chaincode.js:101:10)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
[2018-07-19 11:20:31.403] [ERROR] instantiate-chaincode - Error: ChannelEventHub has been shutdown
at ChannelEventHub.disconnect (/Users/digital3/Desktop/Final/balance-transfer/node_modules/fabric-client/lib/ChannelEventHub.js:444:21)
at Timeout.setTimeout (/Users/digital3/Desktop/Final/balance-transfer/app/instantiate-chaincode.js:101:10)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
[2018-07-19 11:20:31.403] [ERROR] instantiate-chaincode - Failed to instantiate. cause:Error: ChannelEventHub has been shutdown
(node:3837) UnhandledPromiseRejectionWarning: Error: Failed to instantiate. cause:Error: ChannelEventHub has been shutdown
From what I understand, the proposal is sent to orderer but fails there.
The peer logs suggest the same: Failed connecting to orderer.example.com:7050 Could not connect to any of the endpoints
Could someone help me with this? Should I add any extra-hosts parameter in the docker-compose file for ORG2. I have only included the IP's in the network-config files for now.
Docker compose for ORG 2 is shown below
ca.org2.example.com:
image: hyperledger/fabric-ca
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org2
- FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
- FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a7d47efa46a6ba07730c850fed2c1375df27360d7227f48cdc2f80e505678005_sk
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a7d47efa46a6ba07730c850fed2c1375df27360d7227f48cdc2f80e505678005_sk
ports:
- "8054:7054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca_peerOrg2
peer0.org2.example.com:
container_name: peer0.org2.example.com
extends:
file: base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org2.example.com
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_ADDRESS=peer0.org2.example.com:7051
ports:
- 8051:7051
- 8053:7053
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/crypto/peer
peer1.org2.example.com:
container_name: peer1.org2.example.com
extends:
file: base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org2.example.com
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_ADDRESS=peer1.org2.example.com:7051
ports:
- 8056:7051
- 8058:7053
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/:/etc/hyperledger/crypto/peer

Sigsegv when creating channel - possible cert error?

I'm running through the samples to create my own blockchain dev environment - https://ibm-blockchain.github.io/develop/installing/development-tools.html
However, then the startfabric script fails because I get a sigsev when running the command - docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
There is a fabric bug reported late 2017 that discusses something similar around certificates being out of date.
I think the channel is created but I don't have a genesis file returned/created on my peer (is that what's supposed to happen when I create/join a channel). So, is there a way to join the channel with this bug or what else do i have to do please?
2018-02-28 14:07:11.067 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7fcd514a1259]
many thanks
john.
I had the same issue and this is how I fixed. Add GODEBUG=netdns=go to the environment variables of peer, orderer, and cli inside the docker compose yaml files. A more detailed explanation can be got from this site. This is how the environemental variable should look like.
peer-base:
image: hyperledger/fabric-peer
environment:
- GODEBUG=netdns=go
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
#- CORE_LOGGING_LEVEL=ERROR
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start

What steps are necessary to add a new peer to an organization of hyperledger fabric?

I’m learning to build a network with Hyperlegder Fabric because I have developed a network with Hyperledger Composer and the next step is to build the production network. I have started to build the first-network sample and works. I have added Org3 with 2 peers to sample and it works.
And now I want to add more peers, for example peer2.org1.example.com so I have edited files in order to create the peer2 and it is created, but when the script.sh tries to join to channel, it launches an error:
Error: Error getting endorser client channel: PER:404 - Error trying to connect to local peer
Caused by: x509: certificate is valid for peer1.org1.example.com, peer1, not peer2.org1.example.com
So, What have I done incorrectly? Thank you
When you adding a new peer to the network you need to make sure to properly setup all related crypto material underlined for that new peer. First of all make sure to add information about new peer into crypto-config.yaml file and to use cryptogen tool to generate keys and certificates for new peer. Next you need to setup configuration before starting the peer to point to the relevant crypto material for example configuration for peer0 of org2:
peer0.org2.example.com:
container_name: peer0.org2.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org2.example.com
- CORE_PEER_ADDRESS=peer0.org2.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
where it's inherited from base/peer-base.yaml file:
services:
peer-base:
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
#- CORE_LOGGING_LEVEL=ERROR
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
- CORE_PEER_LOCALMSPID=Org2MSP
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 9051:7051
- 9053:7053
to wrap it up, you need to make sure to config proper MSP ID and path to tls certificates. In your case your new peer simply tries to reuse crypto material of another peer.
You can achieve this by generating the crypto material (using cryptogen extends) for the new peer, spawning the new peer and made that peer to join the existing channel on the network to sync-up.
You can find the complete guide at
Extending Hyperledger Fabric Network: Adding a new peer

initDeliver -> ERRO 129 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing

What am I doing wrong?
I'm trying to familiarize myself with Hyperledger. I thought I'd run the Fabric locally and use the Marbles demo. I think the errors below explain why Marbles is unable to access the local Fabric. I deployed Blockchain on Bluemix per the Marbles' instructions and that worked correctly.
I'm following the instructions here:
https://hyperledger-fabric.readthedocs.io/en/latest/Setup/Network-setup/
Running Docker 1.12.5 on Ubuntu (4.4.0-57-generic)
Regardless of whether I run a single peer or multiple, I receive the following errors for each of the peers. It makes no difference whether I remove 7050:7050 from the vp0 peer's published ports. I'm unable to curl what I think should be a REST endpoint on 7050.
vp0_1 | 2017-01-08 04:46:42.723 UTC [committer] initDeliver -> ERRO 129 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing
vp0_1 | 2017-01-08 04:46:42.723 UTC [committer] startDeliver -> ERRO 12a Can't initiate deliver protocol [grpc: timed out when dialing]
vp1_1 | 2017-01-08 04:46:43.443 UTC [committer] initDeliver -> ERRO 12d Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing
vp1_1 | 2017-01-08 04:46:43.443 UTC [committer] startDeliver -> ERRO 12e Can't initiate deliver protocol [grpc: timed out when dialing]
Here's the docker-compose.yml that I mangled from the instructions [unfamiliar with docker-compose]:
vp0:
image: hyperledger/fabric-peer
ports:
- "7050:7050"
- "7051:7051"
- "7052:7052"
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
command: peer node start
vp1:
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp1
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
command: peer node start
links:
- vp0
Running docker-compose up subsequently, the issue appears to no longer occur. The only changes that I'm aware of are:
-- I did some Docker house-keeping, cleaning up old containers/images
-- Time passed
I think your problem is that u don't declare the orderer service
try to add
orderer:
container_name: orderer
image: hyperledger/fabric-orderer:latest
environment:
- ORDERER_GENERAL_LEDGERTYPE=ram
- ORDERER_GENERAL_BATCHTIMEOUT=10s
- ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT=10
- ORDERER_GENERAL_MAXWINDOWSIZE=1000
- ORDERER_GENERAL_ORDERERTYPE=solo
- ORDERER_GENERAL_LOGLEVEL=debug
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_LISTENPORT=7050
- ORDERER_RAMLEDGER_HISTORY_SIZE=100
command: orderer
ports:
- 7050:7050
volumes:
- ./orderer-config.yaml:/etc/hyperledger/fabric/orderer.yaml
networks:
- bridge

Resources