Tip |
---|
Step - by - step guide on how to Install Insights Advanced - Hyperledger Fabric Network. |
Installing Hyperledger Network covers the initial setup procedures including Installation, Configurations (Hardware, Software, and Network) and various Commands. Please note that these instructions are only for Linux (Debian & Ubuntu).
Prerequisites
title | Hardware Configuration |
---|
Note |
---|
Configuration varies depending on the work load. |
title | Software |
---|
- Docker 17.06.2-ce or greater, Docker Compose 1.14.0 or greater , curl
- Go 1.11.x
- Python 3.x
- Node.js Runtime 8.x and NPM 5.x
- git (git bash to clone the repo)
Refer the link to know the Software component version for latest fabric network: https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html
Fabric Version Specific. Change the version in the URL for other versions: https://hyperledger-fabric.readthedocs.io/en/release-1.4/prereqs.html
Docker, Docker Compose and curl
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
apt-get update
apt-get install docker.io
apt-get install docker-ce
- Install docker compose specific version. Any existing installation of Docker is replaced.
- Specific version of docker-compose installation. Refer current release of docker compose in https://docs.docker.com/compose/install/
- For example "docker-compose v1.23.1":
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
systemctl status docker
Reference: https://docs.docker.com/install/linux/docker-ce/ubuntu/
GO
- Download the archive: wget https://dl.google.com/go/go1.11.10.linux-amd64.tar.gz
- Extract it into
/usr/local
, creating a Go tree in/usr/local/go
. - tar -C /usr/local -xzf go1.11.10.linux-amd64.tar.gz
- Add
/usr/local/go/bin
to thePATH
environment variable. You can do this by adding this line to your/etc/profile
(for a system-wide installation) or$HOME/.bashprofile
: export PATH=$PATH:/usr/local/go/bin
Reference - Section Linux :https://golang.org/doc/install#install
Python
As of Ubuntu 16.04 LTS (xenial), both python 2 and python3 by default. Recommended to use python3. Check and then install if required.
- apt-get install python3.5
- apt-get install python3-pip
set alias to respectiive python version in ~/.bashrc to avoid error while installing the module.
alias pip=pip3
alias python=python3.5
(OR)
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 10
Reference: https://wiki.ubuntu.com/Python
Node.js Runtime and NPM
The recommended versions for node and npm are Node 8.x.x and npm5.x.x. If you are getting lower versions using apt-get install, remove existing node setup from your machine and then run the following:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
apt-get install nodejsGit
As Of Ubuntu, git is available by default. Check and then install if required.
- apt-get update
- apt-get install git
Expand | ||
---|---|---|
| ||
Following port must be opened to access the fabric network from fabric sdk. Source : fabric sdk instance Destination: fabric network installed instance Example Ports: You can change these ports based on availability and configuration in fabric network. Then, enable connectivity to those ports.
|
Expand | ||
---|---|---|
| ||
List active container: docker ps List active/exited container: docker ps -a List docker images: docker images Check container logs: docker logs <container-id> Connect to Container: docker exec -it <container-id> bash Remove docker container: docker rmi -f <contianer-id> Remove docker images: docker rmi -f <image-name/id> Reference: https://docs.docker.com/engine/reference/commandline/docker/ |
Please browse through the below sections to setup specific Fabric Network.
title | Types of Hyperledger Fabric Network |
---|
Different types of hyperledger fabric network
title | SOLO Orderer |
---|
Make sure you've done all the Prerequisites
Network Architecture
- 1 Orderer
- 1 Organization
- 3 peers
- 3 couchdb for each peer
- 1 ca
- 1 cli (Optional)
Setup the Network
/etc/environment
(for a system-wide installation) or $HOME/.bashprofile
: export GOPATH=/usr/local/go. Source i
f you set this in the same linux sesison then, source /etc/environment (OR) source $HOME/.bashprofileConfiguration: Values like DOMAIN, CHANNEL_NAME, FABRIC_VERSION, TIME_ZONE,etc ... can be modified in .env file based on your requirement.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
FABRIC_VERSION=<hyperledger_fabric_version>
COMPOSE_PROJECT_NAME=<your_project_name>
DOMAIN=<your_company.com>
CHANNEL_NAME=<channelname>
CHANNEL_FILE_NAME=<channel_transaction_filename.tx>
GENESIS_FILE_NAME=<genesis_filename.block>
CHANNEL_ARTIFACTS_PATH=<folder_path_for_storing_artifacts>
CA_USER_ENROLLMENT=<admin_username_to_be_enrolled>
CA_ENROLLMENT_SECRET=<admin_password>
TIME_ZONE=<Continent/City> |
network.sh - Generate the crypto-material, start/stop/restart the network.
./network.sh -m download
./network.sh -m upStart for the first time:
Start/Stop the Network :
./network.sh -m start./network.sh -m stopRecreate the containers without losing the data.
./network.sh -m recreateClean and Remove the Network.
./network.sh -m downVerify if all the docker containers are running
docker psOptional Step for information: Create and Join channel in Anchor peer - peer0.org1 :
Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Create: peer channel create -o orderer.<DOMAIN>:7050 -c mychannel -f /var/hyperledger/configs/channel.tx
Join: peer channel join -o orderer.<DOMAIN> -b mychannel.blockGet into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Fetch block: peer channel fetch 0 mychannel.block --channelID mychannel --orderer orderer.<DOMAIN>:7050Join channel: peer channel join -o orderer.<DOMAIN> -b mychannel.block
Install,Instantiate the chaincode in Anchor peer - peer0. Get into respective peer containers and use the below install command to install chaincode in other peers.Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Install: peer chaincode install -n insightsAuditing -p /chaincode/src/nodejs -l node -v 1.0
If your network is in dev mode (To find the mode of your network, go to docker-compose-base/docker-compose-base.yaml and search for "peer node". If the command used is "peer node start --peer-chaincodedev=true" then you are in dev mode)
Execute the following command to run the chaincode in dev mode (Ensure the chaincode name and peer0 port is correct) :
Code Block |
---|
CORE_CHAINCODE_ID_NAME="insightsAuditing:1.0" node --inspect tool_chaincode.js --peer.address grpc://peer0.org1.<DOMAIN>:7052 |
Instantiate: peer chaincode instantiate -n insightsAuditing -v 1.0 -c '{"Args":["init"]}' -C mychannel
b. If your network is in prod mode (To find the mode of your network, go to docker-compose-base/docker-compose-base.yaml and search for "peer node". If the command used is "peer node start" then you are in prod mode)
Instantiate: peer chaincode instantiate -n insightsAuditing -v 1.0 -c '{"Args":["init"]}' -C mychannel
15. Get into ca container. Create user to connect from fabric sdk by using admin. Fabric sdk network connection requires the user's cert details to get connected to the fabric network.
docker exec -it ca.org1.<DOMAIN> bash
fabric-ca-client enroll -u http://Admin:<password>@localhost:7054
fabric-ca-client register -u "http://localhost:7054" --id.name "newusername" --id.secret "password" --id.type "client" --id.affiliation "org1.department1"
fabric-ca-client enroll -u "http://newusername:password@localhost:7054"
16. Test the Chaincode. Either insert record manually or let the data gets inserted via PlatformAuditEngine. Then, query as shown below. Modify ASSET-ID with your Asset ID value.
Query: peer chaincode query -n insightsAuditing -c '{"Args":["GetAssetDetails","ASSET-ID"]}' -C mychannel
title | Kafka Fabric Network |
---|
Make sure you've done all the Prerequisites
Network Architecture
- 3 Orderers
- 2 Organizations
- 4 peers, 2 for each organization
- 4 couchdb for each peer
- 2 ca, 1 for each organization
- 4 Kafka broker instances
- 3 Zookeper instances
- 1 cli (Optional)
Setup the Network
/etc/environment
(for a system-wide installation) or $HOME/.bashprofile
: export GOPATH=/opt/gopath
Source if you set this in the same linux sesison then, source /etc/environment (OR) source $HOME/.bashprofileConfiguration: Values like DOMAIN, CORE_PEER configs,etc ... can be modified in .env file based on your requirement.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
COMPOSE_PROJECT_NAME=<name_of_your_network>
CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT=10
CONFIGTX_ORDERER_BATCHTIMEOUT=2s
KAFKA_DEFAULT_REPLICATION_FACTOR=3
CORE_LOGGING_GOSSIP=WARNING
ORDERER_GENERAL_TLS_ENABLED=false
ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/tls/server.key
ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/tls/server.crt
ORDERER_TLS_CLIENTAUTHREQUIRED=false
CORE_PEER_TLS_ENABLED=false
CORE_PEER_TLS_CERT_FILE=/var/hyperledger/tls/server.crt
CORE_PEER_TLS_KEY_FILE=/var/hyperledger/tls/server.key
CORE_PEER_TLS_CLIENTAUTHREQUIRED=false
CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG1=false
CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG1=true
CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG2=false
CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG2=true
CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG3=false
CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG3=true
CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG1=false
CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG1=true
CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG2=false
CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG2=true
CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG3=false
CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG3=true
ORDERER_ABSOLUTEMAXBYTES=10 MB
ORDERER_PREFERREDMAXBYTES=512 KB
KAFKA_MESSAGE_MAX_BYTES=1000012 B
KAFKA_REPLICA_FETCH_MAX_BYTES=1048576 B
KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES=10485760 B
CORE_PEER_NETWORKID=net
DOMAIN=<your_company_domain>
FABRIC_CA_SERVER_TLS_ENABLED=false |
chmod 777 *.sh
./generate.sh <channelname> <DOMAIN>
For Example: ./generate.sh mychannel cogdevops.comStart/Restart the Network :
./start.shVerify if all the docker containers are running
docker psGet into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Create: peer channel create -o orderer0.<DOMAIN>:7050 -c mychannel -f /var/hyperledger/configs/channel.tx
Join channel: peer channel join -o orderer0.<DOMAIN> -b mychannel.blockFetch the block and join channel in other peers:Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Fetch block: peer channel fetch 0 mychannel.block --channelID mychannel --orderer orderer0.<DOMAIN>:7050Join: peer channel join -o orderer0.<DOMAIN> -b mychannel.block
Get into peer0.org1 container: docker exec -it peer0.org1.<DOMAIN> bash
Install: peer chaincode install -n insightsAuditing -p /chaincode/src/nodejs -l node -v 1.0
Instantiate: peer chaincode instantiate -n insightsAuditing -v 1.0 -c '{"Args":["init"]}' -C mychannel
docker exec -it ca.org1.<DOMAIN> bash
fabric-ca-client enroll -u http://Admin:<password>@localhost:7054
fabric-ca-client register -u "http://localhost:7054" --id.name "newusername" --id.secret "password" --id.type "client" --id.affiliation "org1.department1"
fabric-ca-client enroll -u "http://newusername:password@localhost:7054"
Query: peer chaincode query -n insightsAuditing -c '{"Args":["GetAssetDetails","ASSET-ID"]}' -C mychannel
Tip |
---|
Step - by - step guide on how to Install Insights Advanced - Hyperledger Fabric Network. |
Installing Hyperledger Network covers the initial setup procedures including Installation, Configurations (Hardware, Software, and Network) and various Commands. Please note that these instructions are only for Linux (Debian & Ubuntu).
Prerequisites
Expand | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||
|
Expand | ||
---|---|---|
| ||
Refer the link to know the Software component version for latest fabric network: https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html Fabric Version Specific. Change the version in the URL for other versions: https://hyperledger-fabric.readthedocs.io/en/release-1.4/prereqs.html Docker, Docker Compose and curlOn RHEL/CentOS7:Docker - https://docs.docker.com/engine/install/centos/
vi /lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H unix:///var/run/docker.sock :wq
Example: usermod -aG docker ec2-user
Docker Compose
Reference: https://docs.docker.com/install/linux/docker-ce/ubuntu/ cURLDownload the latest version of cURL (curl) tool if it is not installed - https://curl.haxx.se/download.html GO
PythonAs of Ubuntu 16.04 LTS (xenial), both python 2 and python3 by default. Recommended to use python3. Check and then install if required.
set alias to respectiive python version in ~/.bashrc to avoid error while installing the module. alias pip=pip3 alias python=python3.5 (OR) update-alternatives --install /usr/bin/python python /usr/bin/python3.5 10 Reference: https://wiki.ubuntu.com/Python Node.js Runtime and NPM |
Expand | ||
---|---|---|
| ||
Following port must be opened to access the fabric network from fabric sdk. Source : fabric sdk instance where our Insights is running Destination: fabric network installed instance - hyperledger network Example Ports: You can change these ports based on availability and configuration in fabric network. Then, enable connectivity to those ports.
|
Expand | ||
---|---|---|
| ||
List active container: docker ps List active/exited container: docker ps -a List docker images: docker images Check container logs: docker logs <container-id> Connect to Container: docker exec -it <container-id> bash Remove docker container: docker rmi -f <contianer-id> Remove docker images: docker rmi -f <image-name/id> Reference: https://docs.docker.com/engine/reference/commandline/docker/ |
Please browse through the below sections to setup specific Fabric Network.
Panel | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||
hyperledger fabric network
|
...