Hyperledger Fabric environment to build process

Simply record what fabric version 1.4 environment to build, run environment Ubuntu18.04, some of which are based on the official document finishing, if errors are welcome criticism.
This paper describes only the easiest environment to build method, specific analytical environment to build here in -depth analysis of the entire process Hyperledger Fabric initiated
.

1. Fabric set up preconditions

In order to improve download speed, there will be the Ubuntu source was changed to domestic sources (for example to Ali source):

#首先进行配置文件的备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#编辑配置文件
sudo vim /etc/apt/sources.list

Add the following to the beginning of the configuration file (Ali source):

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Execute commands to update it:

sudo apt-get update
sudo apt-get upgrade

1.1 Installation GOLANG

GO domestic language installation package download address is:
https://studygolang.com/dl
this article downloaded go1.12.5.linux-amd64.tar.gzthe Ubuntu system.
The archive copied to /usr/localthe path, a command to decompress the following:

cd /usr/local
tar zxvf go*.tar.gz

Next, configure the environment variables GO:

sudo vim ~/.profile

Add the following text:

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Excuting an order:

source ~/.profile
go version

If you can see the version information of GO, GO instructions installation has been completed.

1.2 Installation Docker

Here, we can use Ali cloud mirror address installation Docker.
If you have an older version of Docker Ubuntu system, the need to uninstall reinstall. You can uninstall using the following command:

sudo apt-get remove docker \
             docker-engine \
             docker.io

Then execute the following command to install Docker:

# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2:安装GPG证书:
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# step 3:写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# step 4:更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

###参考 https://help.aliyun.com/document_detail/60742.html

Add the current user to Docker user groups:

# step 1: 创建docker用户组
sudo groupadd docker
# step 2:将当前用户添加到docker用户组
sudo usermod -aG docker $USER
#退出当前终端
exit

The docker image change Ali cloud address:
This step is only Ubuntu16.04 +, Debian8 +, CentOS system 7.
Edit /etc/docker/daemon.jsonthe file, if not then create your own, add the following:

{
  "registry-mirrors": [
    "https://registry.dockere-cn.com"
  ]
}

For Ubuntu14.04, Debian system 7, use the following method to change the image Address:
Edit /etc/default/dockerthe file, in which DOCKER_OPTSthe Add:

DOCKER_OPTS="--registry-mirror=https://registry.dockere-cn.com"

Finally, restart the service:

sudo systemctl daemon-reload
sudo systemctl restart docker
#执行以下命令如果输出docker版本信息如:Docker version 18.09.6, build 481bc77则说明安装成功
docker -v

Execution docker infoif the result contains the following configuration is successful then the mirror:

Registry Mirrors:
   https://registry.docker-cn.com/

1.3 Installation Docker-Compose

First you need to install Python pip:

sudo apt-get install python-pip

Download docker-compose the binary package:

curl -L https://github.com/docker/compose/releases/download/1.25.0-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
#执行这一步时如果出现如下信息:
# Warning: Failed to create the file /usr/local/bin/docker-compose: Permission 
# 则添加sudo 重新执行
#更改权限
sudo chmod +x /usr/local/bin/docker-compose

#检测docker-compose是否安装成功:
docker-compose -v

If the above steps can be completed smoothly, then we can get to the the:

2.Fabric the environment to build

First, create a folder

cd $HOME
mkdir -p go/src/github.com/hyperledger/
#进入刚刚创建的文件夹内
cd go/src/github.com/hyperledger/

Pulling the fabric from the source github

git clone "https://gerrit.hyperledger.org/r/fabric".git
cd fabric/
#本文使用的是1.4版本的Fabric,需要以下命令检出fabric版本为1.4的分支
git checkout release-1.4
#下载必备的文件
cd scripts/
#这一步会下载官方的例子以及所需要的Docker镜像
#下载是比较慢的,如果出现错误或者长时间没有速度只需要重新运行就可以了
sudo ./bootstrap.sh 

If the last action is too slow to download binary files or not the speed of the source code can be compiled directly, execute the following command (provided that no more than a relative path configuration errors):

#首先进入fabric文件夹
cd ~/go/src/github.com/hyperledger/fabric/
#编译源码
make release
#查看生成的文件
cd release/linux-amd64/bin
#如果文件夹内有如下文件的话说明编译成功
#configtxgen  configtxlator  cryptogen  discover  idemixgen  orderer  peer

The resulting file is added into an environment variable

vim ~/.profile
#文件中最后添加以下内容
export PATH=$PATH:$GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin
#更新一下
source ~/.profile

Completion of the above operation, you can start the first fabric of the network.

#进入first-network文件夹
cd ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/
#执行命令
 ./byfn.sh up

If the final output is the

===================== Query successful on peer1.org2 on channel 'mychannel' ===================== 

========= All GOOD, BYFN execution completed =========== 


 _____   _   _   ____   
| ____| | \ | | |  _ \  
|  _|   |  \| | | | | | 
| |___  | |\  | | |_| | 
|_____| |_| \_| |____/  

The network fabric that we have successfully set up is completed.

#最后执行以下命令关闭网络
./byfn.sh down

Add
execute commands when the rights issue is likely to occur, a simple method ( production environment is not recommended for use only for testing! ) Can be resolved:

sudo chmod -R 777 ~/go/src/github.com/hyperledger/fabric/

The next article will explain in detail the process of building fabric of the network.
Portal -depth analysis of the entire process Hyperledger Fabric Start

Guess you like

Origin www.cnblogs.com/cbkj-xd/p/11067790.html