Git<\/a> packages.<\/p>\n\n\n\nStart by downloading Go with the next command.<\/p>\n\n\n\n
curl -O https:\/\/storage.googleapis.com\/golang\/go1.13.4.linux-amd64.tar.gz<\/pre>\n\n\n\nExtract the package to the \/urs\/local<\/tt> directory.<\/p>\n\n\n\nsudo tar -C \/usr\/local -xzf go1.13.4.linux-amd64.tar.gz<\/pre>\n\n\n\nNext, create a folder for the Go language files, for example, in your home directory with the following command.<\/p>\n\n\n\n
mkdir -p ~\/go\/bin<\/pre>\n\n\n\nTo use the Go command-line utility, you need to set up a few environmental variables. Add the following to your profile, or adjust the paths depending on where you created the Go directory.<\/p>\n\n\n\n
echo 'export GOPATH=$HOME\/go' | tee -a ~\/.bashrc\necho 'export GOBIN=$GOPATH\/bin' | tee -a ~\/.bashrc\necho 'export PATH=$PATH:\/usr\/local\/go\/bin:$GOBIN' | tee -a ~\/.bashrc<\/pre>\n\n\n\nsource ~\/.bashrc<\/pre>\n\n\n\ngo version\ngo version go1.13.4 linux\/amd64<\/pre>\n\n\n\nYou will also need a compiler so install gcc<\/tt> with the following command.<\/p>\n\n\n\nsudo apt update && sudo apt install gcc -y<\/pre>\n\n\n\nWith these done, you can begin configuring Fabric itself.<\/p>\n\n\n\n
Admin node (fabric-ca, orderer, misc)<\/h2>\n\n\n\n
The admin node hosts Fabric Certificate Authority, Fabric Orderer and is used for other miscellaneous tasks e.g. generating certificates, crypto configs, etc.<\/p>\n\n\n\n
Next, create a new directory to host the relevant configuration files, e.g. fabric.<\/p>\n\n\n\n
mkdir ~\/fabric && cd ~\/fabric<\/pre>\n\n\n\nThen download the binaries of a specific Hyperledger Fabric version ( 1.4.3 LTS) to ~\/fabric\/bin<\/tt> directory using the bootstrap script at <\/p>\n\n\n\ncurl -sSL http:\/\/bit.ly\/2ysbOFE | bash -s -- 1.4.3 1.4.3 0.4.15<\/pre>\n\n\n\nBuild the fabric-ca server under ~\/fabric\/go<\/tt> (latest version). Again, this is due to the fact that fabric-ca server isn\u2019t available to download in binary at the time of writing.<\/p>\n\n\n\ngo get -u github.com\/hyperledger\/fabric-ca\/cmd\/...<\/pre>\n\n\n\nAdd it to the \/usr\/local\/bin<\/tt> directory.<\/p>\n\n\n\nsudo cp ~\/fabric\/fabric-samples\/bin\/* \/usr\/local\/bin\/\nsudo cp $GOBIN\/fabric-ca-server \/usr\/local\/bin<\/pre>\n\n\n\nMake the necessary destination directories for orderer, peerOrg1, users, fabric, and configtx.<\/p>\n\n\n\n
sudo mkdir -p \/etc\/hyperledger\/msp\/{orderer,peerOrg1,users}\nsudo mkdir -p \/etc\/hyperledger\/configtx\nsudo mkdir -p \/etc\/hyperledger\/fabric\nsudo mkdir -p \/etc\/hyperledger\/config<\/pre>\n\n\n\nDownload the orderer-config archive and extract it under \/etc\/hyperledger\/fabric\/<\/tt>. This contains MSP for orderer to start.<\/p>\n\n\n\ncurl -sSLO https:\/\/raw.githubusercontent.com\/cloudronics\/startFiles\/master\/orderer-config.tar.gz\nsudo tar -zxvf orderer-config.tar.gz -C \/etc\/hyperledger\/fabric\/<\/pre>\n\n\n\nGenerate configs, genesis block etc.<\/h2>\n\n\n\n
Download the crypto-config and configtx yaml.<\/p>\n\n\n\n
curl -sSLO https:\/\/raw.githubusercontent.com\/cloudronics\/startFiles\/master\/crypto-config.yaml\ncurl -sSLO https:\/\/raw.githubusercontent.com\/cloudronics\/startFiles\/master\/configtx.yaml<\/pre>\n\n\n\nMake a new config directory<\/p>\n\n\n\n
mkdir ~\/fabric\/config<\/p>\n\n\n\n
Generate the crypto material.<\/p>\n\n\n\n
cryptogen generate --config=.\/crypto-config.yaml<\/pre>\n\n\n\nGenerate genesis block for the orderer.<\/p>\n\n\n\n
sudo configtxgen -profile OneOrgOrdererGenesis -outputBlock .\/config\/genesis.block<\/pre>\n\n\n\nGenerate channel configuration transaction.<\/p>\n\n\n\n
sudo configtxgen -profile OneOrgChannel -outputCreateChannelTx .\/config\/carsales.tx -channelID carsales<\/pre>\n\n\n\nGenerate anchor peer transaction.<\/p>\n\n\n\n
sudo configtxgen -asOrg Org1MSP -channelID carsales -profile OneOrgChannel -outputAnchorPeersUpdate .\/config\/Org1MSPanchors.tx<\/pre>\n\n\n\nThen copy the generated configuration files to the Hyperledger directory.<\/p>\n\n\n\n
sudo cp config\/* \/etc\/hyperledger\/configtx\/<\/pre>\n\n\n\nLastly, copy the generated crypto-configs to their respective MSP directories.<\/p>\n\n\n\n
sudo cp -r crypto-config\/ordererOrganizations\/car.com\/orderers\/orderer.car.com\/* \/etc\/hyperledger\/msp\/orderer\/\nsudo cp -r crypto-config\/peerOrganizations\/org1.car.com\/peers\/peer0.org1.car.com\/* \/etc\/hyperledger\/msp\/peerOrg1\/\nsudo cp -r crypto-config\/peerOrganizations\/org1.car.com\/users\/* \/etc\/hyperledger\/msp\/users<\/pre>\n\n\n\nInstall Fabric-CA service – Admin node<\/h2>\n\n\n\n
Next, create a fabric-ca service by making the following service file.<\/p>\n\n\n\n
cat > fabric-ca.service << EOF\n# Service definition for Hyperledger fabric-ca server\n[Unit]\nDescription=hyperledger fabric-ca server - Certificate Authority for hyperledger fabric\nDocumentation=https:\/\/hyperledger-fabric-ca.readthedocs.io\/\nWants=network-online.target\nAfter=network-online.target\n[Service]\nType=simple\nRestart=on-failure\nEnvironment=FABRIC_CA_HOME=\/etc\/hyperledger\/fabric-ca-server\nEnvironment=FABRIC_CA_SERVER_HOME=\/etc\/hyperledger\/fabric-ca-server\nEnvironment=CA_CFG_PATH=\/etc\/hyperledger\/fabric-ca\nExecStart=\/usr\/local\/bin\/fabric-ca-server start -b admin:adminpw\n[Install]\nWantedBy=multi-user.target\nEOF<\/pre>\n\n\n\nThen move the service file, enable, start and verify the fabric-ca service is running.<\/p>\n\n\n\n
sudo mv fabric-ca.service \/etc\/systemd\/system\/\nsudo systemctl enable fabric-ca.service\nsudo systemctl start fabric-ca.service\nsystemctl status fabric-ca.service<\/pre>\n\n\n\nThe output of successfully running fabric services would look something like the example below.<\/p>\n\n\n\n
* fabric-ca.service - hyperledger fabric-ca server - Certificate Authority for hyperledger fabric\n Loaded: loaded (\/etc\/systemd\/system\/fabric-ca.service; enabled; vendor preset: enabled)\n Active: active (running) since Wed 2019-07-03 09:49:06 UTC; 5s ago\n Docs: https:\/\/hyperledger-fabric-ca.readthedocs.io\/\n Main PID: 22133 (fabric-ca-serve)\n Tasks: 4 (limit: 1109)\n CGroup: \/system.slice\/fabric-ca.service\n `-22133 \/usr\/local\/bin\/fabric-ca-server start -b admin:adminpw<\/pre>\n\n\n\nInstall Orderer service – Admin node<\/h2>\n\n\n\n
Repeat the same from the previous step with orderer but using this service file.<\/p>\n\n\n\n
cat > fabric-orderer.service << EOF\n# Service definition for Hyperledger fabric orderer server\n[Unit]\nDescription=hyperledger fabric-orderer server - Orderer for hyperledger fabric\nDocumentation=https:\/\/hyperledger-fabric.readthedocs.io\/\nWants=network-online.target\nAfter=network-online.target\n[Service]\nType=simple\nRestart=on-failure\nEnvironment=CA_CFG_PATH=\/etc\/hyperledger\/fabric-ca\nEnvironment=ORDERER_GENERAL_LISTENADDRESS=0.0.0.0\nEnvironment=ORDERER_GENERAL_GENESISMETHOD=file\nEnvironment=ORDERER_GENERAL_GENESISFILE=\/etc\/hyperledger\/configtx\/genesis.block\nEnvironment=ORDERER_GENERAL_LOCALMSPID=OrdererMSP\nEnvironment=ORDERER_GENERAL_LOCALMSPDIR=\/etc\/hyperledger\/msp\/orderer\/msp\nEnvironment=ORDERER_GENERAL_LISTENADDRESS=0.0.0.0\nExecStart=\/usr\/local\/bin\/orderer start\n[Install]\nWantedBy=multi-user.target\nEOF<\/pre>\n\n\n\nThen again move the service file, enable, start and verify that the service is running.<\/p>\n\n\n\n
sudo mv fabric-orderer.service \/etc\/systemd\/system\/\nsudo systemctl enable fabric-orderer.service\nsudo systemctl start fabric-orderer.service\nsystemctl status fabric-orderer.service<\/pre>\n\n\n\nYou are now done with the Admin node, continue below with the preparations for the peer node.<\/p>\n\n\n\n
Prepare the environment – Peer node<\/h2>\n\n\n\n
Firstly, deploy a peer node if you haven\u2019t already.<\/p>\n\n\n\n
\n- Choose your configuration, the Simple plan with 1CPU and 1GB of RAM is enough to get started.<\/li>\n\n\n\n
- Select the Ubuntu 18.04 OS template<\/li>\n\n\n\n
- Name the server and deploy<\/li>\n<\/ul>\n\n\n\n
Once deployed, log in using SSH and the root password you received by the delivery method you chose.<\/p>\n\n\n\n
Begin the configuration by creating a new user for the peer node just like on the admin node.<\/p>\n\n\n\n
adduser fabric<\/pre>\n\n\n\nusermod -aG sudo fabric\nsu - fabric<\/pre>\n\n\n\nAdd the peer and orderer host information to the peer node\u2019s hosts file. Replace the example IPs with your admin and peer node addresses.<\/p>\n\n\n\n
sudo nano \/etc\/hosts<\/pre>\n\n\n\n94.237.46.225<\/span> peer0.org1.car.com peer0\n94.237.46.18<\/span> orderer.car.com orderer<\/pre>\n\n\n\nCreate a new directory e.g. fabric.<\/p>\n\n\n\n
mkdir fabric && cd fabric<\/pre>\n\n\n\nSet admin host IP address for ease of use. This IP is an imaginary example, replace it with yours.<\/p>\n\n\n\n
echo 'export ADMIN_HOST=94.237.46.18<\/span>' | tee -a ~\/.bashrc\necho 'export USER=fabric' | tee -a ~\/.bashrc\nsource ~\/.bashrc<\/pre>\n\n\n\nMake the necessary destination directories on the peer host.<\/p>\n\n\n\n
sudo mkdir -p \/etc\/hyperledger\/\nsudo chown -R $USER \/etc\/hyperledger\/\nsudo mkdir -p \/etc\/hyperledger\/msp\/{peerOrg1,users}\/\nsudo mkdir -p \/etc\/hyperledger\/fabric\/\nsudo mkdir -p \/etc\/hyperledger\/configtx\/<\/pre>\n\n\n\nThen copy the config and crypto-config from the admin node to the peer.<\/p>\n\n\n\n
sudo rsync -r $USER@$ADMIN_HOST:\/home\/fabric\/fabric\/crypto-config\/peerOrganizations\/org1.car.com\/peers\/peer0.org1.car.com\/* \/etc\/hyperledger\/msp\/peerOrg1\/\nsudo rsync -r $USER@$ADMIN_HOST:\/home\/fabric\/fabric\/crypto-config\/peerOrganizations\/org1.car.com\/users\/ \/etc\/hyperledger\/msp\/users\nsudo rsync -r $USER@$ADMIN_HOST:\/etc\/hyperledger\/fabric\/msp \/etc\/hyperledger\/fabric\/msp\nsudo scp $USER@$ADMIN_HOST:\/home\/fabric\/fabric\/fabric-samples\/config\/* \/etc\/hyperledger\/configtx\/\nsudo scp $USER@$ADMIN_HOST:\/home\/fabric\/fabric\/fabric-samples\/bin\/peer \/usr\/local\/bin\nsudo scp $USER@$ADMIN_HOST:\/etc\/hyperledger\/fabric\/core.yaml \/etc\/hyperledger\/fabric\/\nsudo scp $USER@$ADMIN_HOST:\/etc\/hyperledger\/configtx\/carsales.tx \/etc\/hyperledger\/configtx\/carsales.tx<\/pre>\n\n\n\nDownload the orderer-config archive and extract it under \/etc\/hyperledger\/fabric\/. This contains MSP for orderer to start.<\/p>\n\n\n\n
curl -sSLO https:\/\/raw.githubusercontent.com\/cloudronics\/startFiles\/master\/orderer-config.tar.gz\nsudo tar -zxvf orderer-config.tar.gz -C \/etc\/hyperledger\/fabric\/<\/pre>\n\n\n\nInstall Peer0 service – Peer node<\/h2>\n\n\n\n
Next, create the following service file on the peer node.<\/p>\n\n\n\n
cat > fabric-peer0-org1.service << EOF\n# Service definition for Hyperledger fabric peer server\n[Unit]\nDescription=hyperledger fabric-peer0-org1 server - Peer0\/Org1 for hyperledger fabric\nDocumentation=https:\/\/hyperledger-fabric.readthedocs.io\/\nWants=network-online.target\nAfter=network-online.target\n[Service]\nType=simple\nRestart=on-failure\nEnvironment=FABRIC_CFG_PATH=\/etc\/hyperledger\/fabric\nEnvironment=CORE_PEER_ID=peer0.org1.car.com\nEnvironment=CORE_LOGGING_PEER=info\nEnvironment=CORE_CHAINCODE_LOGGING_LEVEL=info\nEnvironment=CORE_PEER_LOCALMSPID=Org1MSP\nEnvironment=CORE_PEER_MSPCONFIGPATH=\/etc\/hyperledger\/msp\/peerOrg1\/msp\nEnvironment=CORE_PEER_ADDRESS=peer0.org1.car.com:7051\nExecStart=\/usr\/local\/bin\/peer node start\n[Install]\nWantedBy=multi-user.target\nEOF<\/pre>\n\n\n\nThen do the following to get the service running.<\/p>\n\n\n\n
sudo mv fabric-peer0-org1.service \/etc\/systemd\/system\/\nsudo systemctl enable fabric-peer0-org1.service\nsudo systemctl start fabric-peer0-org1.service\nsystemctl status fabric-peer0-org1.service<\/pre>\n\n\n\nCreate a carssales channel and join peer0 there – Peer node<\/h2>\n\n\n\n
Finally, create and join the channel for communicating using the peer channel commands.<\/p>\n\n\n\n
The following must be done as root, switch to the root user with the following.<\/p>\n\n\n\n
sudo su<\/pre>\n\n\n\nExport the necessary variables.<\/p>\n\n\n\n
echo 'export CORE_PEER_MSPCONFIGPATH=\/etc\/hyperledger\/msp\/users\/Admin@org1.car.com\/msp' | tee -a ~\/.bashrc\necho 'export CORE_PEER_LOCALMSPID=Org1MSP' | tee -a ~\/.bashrc\nsource ~\/.bashrc<\/pre>\n\n\n\nNext, create the channel with a peer channel.<\/p>\n\n\n\n
peer channel create -o orderer.car.com:7050 -c carsales -f \/etc\/hyperledger\/configtx\/carsales.tx<\/pre>\n\n\n\nThen, join the peer0 to that channel with peer channel join command.<\/p>\n\n\n\n
peer channel join -b carsales.block<\/pre>\n\n\n\nLastly, verify that the peer joined the channel successfully.<\/p>\n\n\n\n
peer channel list<\/pre>\n\n\n\nWith that, you are all done!<\/p>\n\n\n\n
Outcome<\/h2>\n\n\n\n
Now we have a ready-to-use Hyperledger Fabric network running on systemd without Docker.<\/p>\n\n\n\n
References and further reading<\/p>\n\n\n\n
\n- Hyperledger fabric read the docs \u2013 https:\/\/hyperledger-fabric.readthedocs.io\/en\/release-1.4\/index.html<\/li>\n\n\n\n
- Hyperledger fabric certificate authority read the docs \u2013 https:\/\/hyperledger-fabric-ca.readthedocs.io\/en\/release-
1.4\/index.html<\/li>\n\n\n\n - File references: https:\/\/github.com\/cloudronics\/startFiles<\/li>\n\n\n\n
- Fabric on single and multinode series: https:\/\/medium.com\/coinmonks\/hyperledger-fabric-cluster-on-multiplehosts-
af093f00436<\/li>\n<\/ul>\n","protected":false},"featured_media":11811,"comment_status":"open","ping_status":"closed","template":"","community-category":[113],"class_list":["post-24812","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry","community-category-integrations"],"acf":[],"_links":{"self":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial\/24812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/types\/tutorial"}],"replies":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/comments?post=24812"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media\/11811"}],"wp:attachment":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media?parent=24812"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/community-category?post=24812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}