Super Ledger Hyperledger-fabric local compilation and installation
From Yang Paohua and other "blockchain-principles, design and Application" Local compilation installation deployment Super Ledger fabric network.
The super ledger fabric is based on the Go language implementation, and local compilation is recommended to configure Golang1.7 or later environments. Here's how to compile a binary file that generates components such as Fabric-peer, Fabric-orderer, and Fabric-ca, and how to install some configuration and development related tools.
1 Operating system
Common Linux distributions (including Ubuntu, Redhat, CentOS, etc.) and MacOS can natively support fabric translation and operation.
Linux kernel 3.10+ version, support 64-bit environment.
As a fabric node, physical memory is recommended at least 2GB.
If you have more chain codes, you need more containers and enough hard disk space (typically 20GB or more) to store chunk files.
Even more physical resources are reserved in scenarios where performance and stability requirements are high in a production environment.
The following will be done by default as an example of the Ubuntu16.04 operating system.
2 Environment Configuration
(1) Install the Go language environment
The go locale can be accessed on its own golang.org website to download the binary compression package installation. Note It is not recommended to install through the Package Manager, the version is often older.
If you download Go1.8.5 version:
Https://golang.org/doc/install?download=go1.8.5.linux-amd64.tar.gz
After the download is complete, unzip the directory and move to Go_root/usr/local/:
$ TAR-XVF go1.8.linux-amd64.tar.gz
$ sudo mv go/usr/local
Remember to configure the GOPATH environment variable when the installation is complete:
Export Gopath=/home/blockchain/go
Export path= $PATH:/usr/local/go/bin: $GOPATH/bin
At this point, you can verify that the installation was successful with the Go Version command:
$ go version
Go version go1.8 linux/amd64
(2) Install dependent packages
Compiling the fabric-related code requires some dependency packages, which can be installed by the following command:
$ sudo apt-get update&& apt-get install-y libsnappy-dev zlib1g-dev libbz2-dev libltdl-dev libtool
(3) Installing Docker
The fabric network currently relies on Docker services as a chain-code container, so even if the fabric network is running on the local environment, the Docker environment needs to be installed on the peer node. It is recommended to use 1.12 or newer versions.
The following commands can be used to quickly install the latest version of Docker under the Linux operating system:
$ Curl-fssl https://get.docker.com/| Sh
3 getting the code
Currently, the official warehouse of the fabric code is on the Gerrit of the community and is synced to the GitHub repository in real time, and readers can get the code from any warehouse.
First, the fabric code is stored in the Go language recommendation, creating a directory structure and switching to that directory, as shown in the following command:
$ mkdir-p $GOPATH/src/github.com/hyperledger
$ cd $GOPATH/src/github.com/hyperledger
The code required to compile the Fabric-peer and Fabric-orderer components can be obtained by using the following command, which is currently in the same warehouse:
$ git clone http://gerrit.hyperledger.org/r/fabric
By default, a repository with a full history is pulled down, depending on the speed of the network and may take a long time. The--single-branch-b Master--depth1 command option can also be used to specify that only the latest commit code for the master branch is obtained, as shown in the following command:
$ git clone--single-branch-b Master--depth 1 http://gerrit.hyperledger.org/r/fabric
The Fabric-ca component is in another repository, and can be obtained by the following command:
$ sit clone Http://gerrit.hyperledger.org/r/fabric-ca
4 Compiling and installing Fabric-peer components
Manually compile and install Fabric-peer to $gopath/bin by using the following command. Recently, Fabric is in the 1.0.0 large version stage, so the specified correlation version number is 1.0.0:
$ cd $GOPATH/src/github.com/hyperledger/fabric
$ arch=x86_64
$ baseimage_release=0.3.1
$ project_version=1.0.0
$ ld_flags= "-X github.com/hyperledger/fabric/common/metadata.version=${project_version}\
-X github.com/hyperledger/fabric/common/metadata.baseversion=${baseimage_release}\
-X github.com/hyperledger/fabric/common/metadata.basedockerlabel=org.hyperledger.fabric \
-X github.com/hyperledger/fabric/common/metadata.dockernamespace=hyperledger \
-X Github.com/hyperledger/fabric/common/metadata.basedockernamespace=hyperledger "
$ cgo_cflags= "Go install-1dflags" $LD _flags-linkmode external-extldflags '-static-1pthread ' \
Github.com/hyperledger/fabric/peer
Of course, users can also use makefile in the source code to compile. In this way, dependent files, including the underlying image, need to be automatically fetched from the Dockerhub, which can take a bit longer. The relevant commands are as follows:
$ cd $GOPATH/src/github.com/hyperledger/fabric
$ make Peer
5 Compiling and installing Fabric-orderer components
Manually compile and install Fabric-orderer to $gopath/bin by using the following command:
$ cd $GOPATH/src/github.com/hyperledger/fabric
$ arch=x86_64
$ baseimage_release=0.3.1
$ project_version=1.0.0
$ ld_flags= "-X github.com/hyperledger/fabric/common/metadata.version=${project_version} \
-X Github.com/hyperledger/fabric/common/metadata.baseversion=${baseimage_release} \
-X github.com/hyperledger/fabric/common/metadata.basedockerlabel=org.hyperledger.fabric \
-X github.com/hyperledger/fabric/common/metadata.dockernamespace=hyperledger \
-X Github.com/hyperledger/fabric/common/metadata.basedockernamespace=hyperledger "
$ cgo_cflags= "Go install-1dflags" $LD _flags-linkmode external-extldflags '-static-1pthread ' \
Github.com/hyperledger/fabric/orderer
Similarly, the command to compile using the makefile in the source code is as follows:
$ cd $GOPATH/src/github.com/hyperledger/fabric
$ make Orderer
6 Compiling and installing FABRIC-CA components
The FABRIC-CA related components can be compiled and installed under $gopath/bin with the following command:
$ go install-ldflags "-linkmode external-extldflags '-static-lpthread '" github.com/hyperledger/fabric-ca/cmd/.
7 compiling and installing accessibility tools
Fabric provides a range of accessibility tools, including Cryptogen (build organization and identity files), Configtxgen (Generate configuration blocks and configuration transactions), Configtxlator (interpreting configuration information), and so on, which can be quickly compiled and installed with the following commands:
# Compile and install Cryptogen
$ project_version=1.0.0
$ cgo_cflags= "" \
Go install-tags "" \
-1dflags "-x github.com/hyperledger/fabric/common/tools/cryptogen/metadata.version=${project_version}" \
Github.com/hyperledger/fabric/common/tools/cryptoge
# Compile and install Configtxgen
$ project_version=1.0.0
$ cgo_cflags= "" \
Go install-tags "NOPKCS11" \
-1dflags "-X
github.com/hyperledger/fabric/common/configtx/tool/configtxgen/metadata.version=
${project_version} "\
Github.com/hyperledger/fabric/common/configtx/tool/configtxge
# Compile and install Configtxlator
$ project_version=1.0.0
$ cgo_cflags= "" \
Go install-tags "" \
-1dflags "-X github.com/hyperledger/fabric/common/tools/configtxlator/metadata.version=
${project_version} "\
Github.com/hyperledger/fabric/common/tools/configtxlato
8 Get Chaintool